Search in sources :

Example 1 with JSONCodecFactory

use of org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory in project netconf by opendaylight.

the class NormalizedNodeJsonBodyWriter method createNormalizedNodeWriter.

private static RestconfNormalizedNodeWriter createNormalizedNodeWriter(final InstanceIdentifierContext<SchemaNode> context, final SchemaPath path, final JsonWriter jsonWriter, @Nullable final Integer depth) {
    final SchemaNode schema = context.getSchemaNode();
    final JSONCodecFactory codecs = getCodecFactory(context);
    final XMLNamespace initialNs;
    if (schema instanceof DataSchemaNode && !((DataSchemaNode) schema).isAugmenting() && !(schema instanceof SchemaContext) || schema instanceof RpcDefinition) {
        initialNs = schema.getQName().getNamespace();
    } else {
        initialNs = null;
    }
    final NormalizedNodeStreamWriter streamWriter = JSONNormalizedNodeStreamWriter.createNestedWriter(codecs, path, initialNs, jsonWriter);
    if (depth != null) {
        return DepthAwareNormalizedNodeWriter.forStreamWriter(streamWriter, depth);
    }
    return RestconfDelegatingNormalizedNodeWriter.forStreamWriter(streamWriter);
}
Also used : SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) RpcDefinition(org.opendaylight.yangtools.yang.model.api.RpcDefinition) DataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode) JSONCodecFactory(org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory) XMLNamespace(org.opendaylight.yangtools.yang.common.XMLNamespace) JSONNormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter) NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext)

Example 2 with JSONCodecFactory

use of org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory in project netconf by opendaylight.

the class JsonNormalizedNodeBodyWriter method createNormalizedNodeWriter.

private static RestconfNormalizedNodeWriter createNormalizedNodeWriter(final InstanceIdentifierContext<SchemaNode> context, final SchemaPath path, final JsonWriter jsonWriter, final DepthParam depth, final List<Set<QName>> fields) {
    final SchemaNode schema = context.getSchemaNode();
    final JSONCodecFactory codecs = getCodecFactory(context);
    final NormalizedNodeStreamWriter streamWriter = JSONNormalizedNodeStreamWriter.createNestedWriter(codecs, path, initialNamespaceFor(schema), jsonWriter);
    return ParameterAwareNormalizedNodeWriter.forStreamWriter(streamWriter, depth, fields);
}
Also used : SchemaNode(org.opendaylight.yangtools.yang.model.api.SchemaNode) JSONCodecFactory(org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory) JSONNormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter) NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)

Aggregations

NormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)2 JSONCodecFactory (org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactory)2 JSONNormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter)2 SchemaNode (org.opendaylight.yangtools.yang.model.api.SchemaNode)2 XMLNamespace (org.opendaylight.yangtools.yang.common.XMLNamespace)1 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)1 RpcDefinition (org.opendaylight.yangtools.yang.model.api.RpcDefinition)1 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)1