@Override public QName getQName() { return getCurrentSchema().getQName(); }
public static ContainerNode readJson(@Nonnull final SchemaContext schemaContext, @Nonnull final InputStream stream, @Nonnull final SchemaNode parentSchema) { final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> builder = Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName())); try (final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(builder); final JsonParserStream jsonParser = JsonParserStream.create(writer, schemaContext, parentSchema)) { final JsonReader reader = new JsonReader(new InputStreamReader(stream, Charsets.UTF_8)); jsonParser.parse(reader); } catch (IOException e) { LOG.warn("Unable to close json parser. Ignoring exception", e); } return builder.build(); }
static DataContainerCodecPrototype<SchemaContext> rootPrototype(final CodecContextFactory factory) { final SchemaContext schema = factory.getRuntimeContext().getSchemaContext(); final NodeIdentifier arg = NodeIdentifier.create(schema.getQName()); return new DataContainerCodecPrototype<>(DataRoot.class, arg, schema, factory); }
public static DataContainerCodecPrototype<SchemaContext> rootPrototype(final CodecContextFactory factory) { final SchemaContext schema = factory.getRuntimeContext().getSchemaContext(); final NodeIdentifier arg = NodeIdentifier.create(schema.getQName()); return new DataContainerCodecPrototype<>(TreeRoot.class, arg, schema, factory); }
/** * Returns a test document. * <p/> * <p/> * <pre> * test * outer-list * id 1 * outer-list * id 2 * inner-list * name "one" * inner-list * name "two" * * </pre> */ public static NormalizedNode<?, ?> createDocumentOne(final SchemaContext schemaContext) { return ImmutableContainerNodeBuilder .create() .withNodeIdentifier( new NodeIdentifier(schemaContext.getQName())) .withChild(createTestContainer()).build(); }
LeafRefContext buildLeafRefContextTree() throws LeafRefYangSyntaxErrorException { final LeafRefContextBuilder rootBuilder = new LeafRefContextBuilder(schemaContext.getQName(), schemaContext.getPath(), schemaContext); final Set<Module> modules = schemaContext.getModules(); for (final Module module : modules) { for (final DataSchemaNode childNode : module.getChildNodes()) { final LeafRefContext childLeafRefContext = buildLeafRefContextReferencingTree(childNode, module); if (childLeafRefContext.hasReferencingChild() || childLeafRefContext.isReferencing()) { rootBuilder.addReferencingChild(childLeafRefContext, childLeafRefContext.getNodeName()); } } } for (final Module module : modules) { final Collection<DataSchemaNode> childNodes = module.getChildNodes(); for (final DataSchemaNode childNode : childNodes) { final LeafRefContext childLeafRefContext = buildLeafRefContextReferencedByTree(childNode, module); if (childLeafRefContext.hasReferencedChild() || childLeafRefContext.isReferenced()) { rootBuilder.addReferencedByChild(childLeafRefContext, childLeafRefContext.getNodeName()); } } } // FIXME: it might be useful to merge these subtrees (i.e. referencing // and referencedBy subtree) return rootBuilder.build(); }
LeafRefContext buildLeafRefContextTree() throws LeafRefYangSyntaxErrorException { final LeafRefContextBuilder rootBuilder = new LeafRefContextBuilder(schemaContext.getQName(), schemaContext.getPath(), schemaContext); final Set<Module> modules = schemaContext.getModules(); for (final Module module : modules) { for (final DataSchemaNode childNode : module.getChildNodes()) { final LeafRefContext childLeafRefContext = buildLeafRefContextReferencingTree(childNode, module); if (childLeafRefContext.hasReferencingChild() || childLeafRefContext.isReferencing()) { rootBuilder.addReferencingChild(childLeafRefContext, childLeafRefContext.getNodeName()); } } } for (final Module module : modules) { final Collection<DataSchemaNode> childNodes = module.getChildNodes(); for (final DataSchemaNode childNode : childNodes) { final LeafRefContext childLeafRefContext = buildLeafRefContextReferencedByTree(childNode, module); if (childLeafRefContext.hasReferencedChild() || childLeafRefContext.isReferenced()) { rootBuilder.addReferencedByChild(childLeafRefContext, childLeafRefContext.getNodeName()); } } } // FIXME: it might be useful to merge these subtrees (i.e. referencing // and referencedBy subtree) return rootBuilder.build(); }