public static Optional<YangSourceDefinition> of(final Module module) { if (module instanceof ModuleEffectiveStatement) { final ModuleEffectiveStatement effective = (ModuleEffectiveStatement) module; final ModuleStatement declared = effective.getDeclared(); if (declared != null) { return Optional.of(new Single(effective, module)); } } return Optional.empty(); }
Map<String, String> prefixesAndNamespaces() { return Maps.transformValues(prefixToModule, module -> module.localQNameModule().getNamespace().toString()); } }
/** * Format specified statement into a {@link YangTextSnippet}. * * @param module parent module * @param statement statement to format * @return A {@link YangTextSnippet} * @throws NullPointerException if any of the arguments is null */ public YangTextSnippet toYangTextSnippet(final ModuleEffectiveStatement module, final DeclaredStatement<?> statement) { return new YangTextSnippet(statement, module.findAll(QNameModuleToPrefixNamespace.class), ignoredStatements, omitDefaultStatements); }
if ((def instanceof YangSourceDefinition.Single)) { final DocumentedNode node = ((YangSourceDefinition.Single)def).getNode(); sb.append("<p>\n").append("This class represents the following YANG schema fragment defined in module <b>").append(((YangSourceDefinition.Single)def).getModule().argument()).append("</b>\n").append("<pre>\n"); BaseTemplate.appendYangSnippet(sb, ((YangSourceDefinition.Single)def).getModule(), ((EffectiveStatement<?, ?>) node).getDeclared()); sb.append("</pre>"); if ((node instanceof SchemaNode)) { sb.append("The schema path to identify an instance is\n").append("<i>").append(BaseTemplate.formatSchemaPath(((YangSourceDefinition.Single)def).getModule().argument(), ((SchemaNode)node).getPath().getPathFromRoot())).append("</i>\n"); boolean _hasBuilderClass = BaseTemplate.hasBuilderClass(((SchemaNode)node)); if (_hasBuilderClass) {
ModuleNamespaceContext(final ModuleEffectiveStatement module) { this.prefixToModule = requireNonNull(module.getAll(PrefixToEffectiveModuleNamespace.class)); this.moduleToPrefix = requireNonNull(module.getAll(QNameModuleToPrefixNamespace.class)); final Builder<String, String> namespaces = ImmutableListMultimap.builder(); for (Entry<QNameModule, @NonNull String> e : moduleToPrefix.entrySet()) { namespaces.put(e.getKey().getNamespace().toString(), e.getValue()); } namespaceToPrefix = namespaces.build(); }
sb.append("<p>\n") .append("This class represents the following YANG schema fragment defined in module <b>") .append(def.getModule().argument()).append("</b>\n") .append("<pre>\n"); appendYangSnippet(sb, def.getModule(), ((EffectiveStatement<?, ?>) node).getDeclared()); sb.append("The schema path to identify an instance is\n") .append("<i>") .append(formatSchemaPath(def.getModule().argument(), ((SchemaNode) node).getPath() .getPathFromRoot())) .append("</i>\n");
ModuleNamespaceContext(final ModuleEffectiveStatement module) { this.prefixToModule = requireNonNull(module.getAll(PrefixToEffectiveModuleNamespace.class)); this.moduleToPrefix = requireNonNull(module.getAll(QNameModuleToPrefixNamespace.class)); final Builder<String, String> namespaces = ImmutableListMultimap.builder(); for (Entry<QNameModule, @NonNull String> e : moduleToPrefix.entrySet()) { namespaces.put(e.getKey().getNamespace().toString(), e.getValue()); } namespaceToPrefix = namespaces.build(); }
public static Optional<YangSourceDefinition> of(final Module module) { if (module instanceof ModuleEffectiveStatement) { final ModuleEffectiveStatement effective = (ModuleEffectiveStatement) module; final ModuleStatement declared = effective.getDeclared(); if (declared != null) { return Optional.of(new Single(effective, module)); } } return Optional.empty(); }
Map<String, String> prefixesAndNamespaces() { return Maps.transformValues(prefixToModule, module -> module.localQNameModule().getNamespace().toString()); } }
/** * Format specified statement into a {@link YangTextSnippet}. * * @param module parent module * @param statement statement to format * @return A {@link YangTextSnippet} * @throws NullPointerException if any of the arguments is null */ public YangTextSnippet toYangTextSnippet(final ModuleEffectiveStatement module, final DeclaredStatement<?> statement) { return new YangTextSnippet(statement, module.findAll(QNameModuleToPrefixNamespace.class), ignoredStatements, omitDefaultStatements); }
/** * Create a new XMLEventReader iterating of the YIN document equivalent of an effective module. * * @param module Effective module * @return A new XMLEventReader. * @throws NullPointerException if module is null * @throws IllegalArgumentException if the specified module does not expose declared model */ public XMLEventReader createXMLEventReader(final ModuleEffectiveStatement module) { final ModuleStatement declared = module.getDeclared(); checkArgument(declared != null, "Module %s does not expose declared model", module); return new YinXMLEventReader(eventFactory, new ModuleNamespaceContext(module), declared); }
@Override public String getNamespaceURI(final String prefix) { checkArgument(prefix != null); switch (prefix) { case XMLConstants.DEFAULT_NS_PREFIX: return YangConstants.RFC6020_YIN_NAMESPACE_STRING; case XMLConstants.XML_NS_PREFIX: return XMLConstants.XML_NS_URI; case XMLConstants.XMLNS_ATTRIBUTE: return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; default: final ModuleEffectiveStatement module = prefixToModule.get(prefix); return module != null ? module.localQNameModule().getNamespace().toString() : XMLConstants.NULL_NS_URI; } }
/** * Create a new XMLEventReader iterating of the YIN document equivalent of an effective module. * * @param module Effective module * @return A new XMLEventReader. * @throws NullPointerException if module is null * @throws IllegalArgumentException if the specified module does not expose declared model */ public XMLEventReader createXMLEventReader(final ModuleEffectiveStatement module) { final ModuleStatement declared = module.getDeclared(); checkArgument(declared != null, "Module %s does not expose declared model", module); return new YinXMLEventReader(eventFactory, new ModuleNamespaceContext(module), declared); }
@Override public String getNamespaceURI(final String prefix) { checkArgument(prefix != null); switch (prefix) { case XMLConstants.DEFAULT_NS_PREFIX: return YangConstants.RFC6020_YIN_NAMESPACE_STRING; case XMLConstants.XML_NS_PREFIX: return XMLConstants.XML_NS_URI; case XMLConstants.XMLNS_ATTRIBUTE: return XMLConstants.XMLNS_ATTRIBUTE_NS_URI; default: final ModuleEffectiveStatement module = prefixToModule.get(prefix); return module != null ? module.localQNameModule().getNamespace().toString() : XMLConstants.NULL_NS_URI; } }
tmp.put(qnameModule, localPrefix); for (Entry<String, ModuleEffectiveStatement> e : prefixToModule.entrySet()) { tmp.putIfAbsent(e.getValue().localQNameModule(), e.getKey());