@Override public QName apply(final SchemaNode input) { return input.getQName(); } };
@Override public QName apply(final SchemaNode rpcDefinition) { return rpcDefinition.getQName(); } };
@Override public QName getQName() { return schemaNode.getQName(); }
@Override public QName getQName() { return schemaNode.getQName(); }
@Override public boolean apply(final SchemaNode input) { return input.getQName().equals(qname); } }
private static <T extends SchemaNode> Optional<T> tryFind(final Collection<T> nodes, final QName qname) { return nodes.stream().filter(node -> qname.equals(node.getQName())).findFirst(); } }
private static <T extends SchemaNode> Optional<T> tryFind(final Collection<T> nodes, final QName qname) { return nodes.stream().filter(node -> qname.equals(node.getQName())).findFirst(); } }
LeafRefPathParserListenerImpl(final SchemaContext schemaContext, final Module leafrefModule, final SchemaNode currentNode) { this.schemaContext = schemaContext; this.module = schemaContext.findModule(currentNode.getQName().getModule()).get(); this.leafrefModule = leafrefModule; this.node = currentNode; }
LeafRefPathParserListenerImpl(final SchemaContext schemaContext, final Module leafrefModule, final SchemaNode currentNode) { this.schemaContext = schemaContext; this.module = schemaContext.findModule(currentNode.getQName().getModule()).get(); this.leafrefModule = leafrefModule; this.node = currentNode; }
private static synchronized String resolveFullNameFromNode(final SchemaNode node, final SchemaContext schemaContext) { final URI namespace = node.getQName().getNamespace(); final Date revision = node.getQName().getRevision(); Map<Date, Module> revisionToModule = namespaceAndRevisionToModule.get(namespace); if (revisionToModule == null) { revisionToModule = new HashMap<>(); namespaceAndRevisionToModule.put(namespace, revisionToModule); } Module module = revisionToModule.get(revision); if (module == null) { module = schemaContext.findModuleByNamespaceAndRevision(namespace, revision); revisionToModule.put(revision, module); } if (module != null) { return module.getName() + ":" + node.getQName().getLocalName(); } return node.getQName().getLocalName(); }
@Override public void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint) throws IOException { final SchemaNode schema = tracker.startYangModeledAnyXmlNode(name); startElement(schema.getQName()); }
@Override public void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException { final SchemaNode schema = tracker.startContainerNode(name); startElement(schema.getQName()); }
public static String resolveNodesName(final SchemaNode node, final Module module, final SchemaContext schemaContext) { if (node.getQName().getNamespace().equals(module.getQNameModule().getNamespace()) && node.getQName().getRevision().equals(module.getQNameModule().getRevision())) { return node.getQName().getLocalName(); } else { return resolveFullNameFromNode(node, schemaContext); } }
/** * Find "proper" qname of unknown node in case it comes from a grouping */ private static QName findQNameFromGrouping(final DataNodeContainer subtree, final SchemaContext ctx, final UnknownSchemaNode unknownSchemaNode, final String localIdentityName) { QName identityQName = null; for (UsesNode usesNode : subtree.getUses()) { SchemaNode dataChildByName = SchemaContextUtil.findDataSchemaNode(ctx, usesNode.getGroupingPath()); Module m = SchemaContextUtil.findParentModule(ctx, dataChildByName); List<UnknownSchemaNode> unknownSchemaNodes = dataChildByName.getUnknownSchemaNodes(); if(Collections2.transform(unknownSchemaNodes, UNKNOWN_NODE_TO_STRING).contains(UNKNOWN_NODE_TO_STRING.apply(unknownSchemaNode))) { identityQName = QName.create(dataChildByName.getQName(), localIdentityName); } } return identityQName; }
/** * Creates MDSAL serializer helper with root schema node, schema context * and URI. * * @param n schema node of the URI's last node * @param c schema context * @param u URI of the request */ public MdsalSerializerHelper(SchemaNode n, SchemaContext c, String u) { super(n, c, u); Namespace ns = new Namespace(n.getQName().getLocalName(), n.getQName().getNamespace(), getRevision(n.getQName().getRevision())); propNode = new RootNode<>(n.getQName().getLocalName(), ns, getSchemaNode(), u); curSchemaNode = getSchemaNode(); }
/** * Resolve path argument name for {@code node}. * * <p>The name can contain also prefix which consists of module name followed by colon. The module * prefix is presented if namespace of {@code node} and its parent is different. In other cases * only name of {@code node} is returned. * * @return name of {@code node} */ public static String resolvePathArgumentsName(final SchemaNode node, final SchemaContext schemaContext) { Iterable<QName> schemaPath = node.getPath().getPathTowardsRoot(); Iterator<QName> it = schemaPath.iterator(); QName nodeQName = it.next(); QName parentQName = null; if (it.hasNext()) { parentQName = it.next(); } if (isEqualNamespaceAndRevision(parentQName, nodeQName)) { return node.getQName().getLocalName(); } else { return resolveFullNameFromNode(node, schemaContext); } }
/** * Write a value into a XML stream writer. This method assumes the start and end of element is * emitted by the caller. * * @param writer XML Stream writer * @param schemaNode Schema node that describes the value * @param value data value * @param parent module QName owning the leaf definition * @throws XMLStreamException if an encoding problem occurs */ void writeValue(final @NonNull ValueWriter writer, final @NonNull SchemaNode schemaNode, final @NonNull Object value, final QNameModule parent) throws XMLStreamException { checkArgument(schemaNode instanceof TypedDataSchemaNode, "Unable to write value for node %s, only nodes of type: leaf and leaf-list can be written at this point", schemaNode.getQName()); TypeDefinition<?> type = ((TypedDataSchemaNode) schemaNode).getType(); if (type instanceof LeafrefTypeDefinition) { type = getBaseTypeForLeafRef(schemaNode, (LeafrefTypeDefinition) type); } writeValue(writer, type, value, parent); }
private static String getGetterName(final SchemaNode node, final TypeDefinition<?> typeDef) { final String suffix = JavaIdentifierNormalizer.normalizeSpecificIdentifier(node.getQName().getLocalName(), JavaIdentifier.CLASS); if (typeDef instanceof BooleanTypeDefinition && (typeDef.getPath().equals(node.getPath()) || typeDef.getBaseType() == null)) { return "is" + suffix; } return "get" + suffix; }
public static String convertToJavaName(final SchemaNode schemaNode, final boolean capitalizeFirstLetter) { for (UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) { if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME .equals(unknownNode.getNodeType())) { String value = unknownNode.getNodeParameter(); return convertToJavaName(value, capitalizeFirstLetter); } } return convertToJavaName(schemaNode.getQName().getLocalName(), capitalizeFirstLetter); }
/** * Created a method signature builder as part of <code>interfaceBuilder</code>. The method signature builder is * created for the getter method of <code>schemaNodeName</code>. Also <code>comment</code> * and <code>returnType</code> information are added to the builder. * * @param interfaceBuilder generated type builder for which the getter method should be created * @param returnType type which represents the return type of the getter method * @param schemaNodeName string with schema node name. The name will be the part of the getter method name. * @param comment string with comment for the getter method * @param status status from yang file, for deprecated annotation * @return method signature builder which represents the getter method of <code>interfaceBuilder</code> */ private MethodSignatureBuilder constructGetter(final GeneratedTypeBuilder interfaceBuilder, final Type returnType, final SchemaNode node) { final MethodSignatureBuilder getMethod = interfaceBuilder.addMethod( getterMethodName(node.getQName().getLocalName(), returnType)); getMethod.setReturnType(returnType); annotateDeprecatedIfNecessary(node.getStatus(), getMethod); addComment(getMethod, node); return getMethod; }