public URI findNamespaceByModuleName(final String moduleName) { final Module module = this.findModuleByName(moduleName); return module == null ? null : module.getNamespace(); }
public URI findNamespaceByModuleName(final DOMMountPoint mountPoint, final String moduleName) { final Module module = this.findModuleByName(mountPoint, moduleName); return module == null ? null : module.getNamespace(); }
private static URI getModuleNamespace(final SchemaContext ctx, final String moduleName) { for (final Module module : ctx.getModules()) { if (moduleName.equals(module.getName())) { return module.getNamespace(); } } throw new IllegalArgumentException("Module " + moduleName + "does not exists in provided schema context"); }
private static URI getModuleNamespace(final SchemaContext ctx, final String moduleName) { for (final Module module : ctx.getModules()) { if (moduleName.equals(module.getName())) { return module.getNamespace(); } } throw new IllegalArgumentException("Module " + moduleName + "does not exists in provided schema context"); }
/** * Returns module instance (from the context) with concrete namespace. Returned Set is required to have its * iteration order guarantee that the latest revision is encountered first. * * @param namespace * URI instance with specified namespace * @return module instance which has namespace equal to the * <code>namespace</code> or <code>null</code> in other cases */ default Set<Module> findModules(final URI namespace) { return Sets.filter(getModules(), m -> namespace.equals(m.getNamespace())); }
/** * Returns module instance (from the context) with concrete namespace. Returned Set is required to have its * iteration order guarantee that the latest revision is encountered first. * * @param namespace * URI instance with specified namespace * @return module instance which has namespace equal to the * <code>namespace</code> or <code>null</code> in other cases */ default Set<Module> findModules(final URI namespace) { return Sets.filter(getModules(), m -> namespace.equals(m.getNamespace())); }
public static QName getQName(final Module currentModule) { return QName.create(currentModule.getNamespace(), currentModule.getRevision(), currentModule.getName()); } }
public static String writeIdentityNs(final IdentitySchemaNode identity) { boolean _equals = Objects.equal(YangTemplate.module, null); if (_equals) { return ""; } QName _qName = identity.getQName(); final URI identityNs = _qName.getNamespace(); URI _namespace = YangTemplate.module.getNamespace(); boolean _equals_1 = _namespace.equals(identityNs); boolean _not = (!_equals_1); if (_not) { return (identityNs + ":"); } return ""; }
private static String toCapabilityURI(final Module module) { return String.valueOf(module.getNamespace()) + "?module=" + module.getName() + "&revision=" + SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()); }
@Override public QName deserialize(final IdentityValuesDTO data) { final IdentityValue valueWithNamespace = data.getValuesWithNamespaces().get(0); final Module module = getModuleByNamespace(valueWithNamespace.getNamespace(), mountPoint); if (module == null) { logger.info("Module was not found for namespace {}", valueWithNamespace.getNamespace()); logger.info("Idenetityref will be translated as NULL for data - {}", String.valueOf(valueWithNamespace)); return null; } return QName.create(module.getNamespace(), module.getRevision(), valueWithNamespace.getValue()); }
private static String toCapabilityURI(final Module module) { return String.valueOf(module.getNamespace()) + "?module=" + module.getName() + "&revision=" + SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()); }
@Override public boolean apply(final Module input) { final ModuleIdentifierImpl id = new ModuleIdentifierImpl(input.getName(), Optional.fromNullable(input.getNamespace()), Optional.fromNullable(input.getRevision())); return id.equals(moduleIdentifier); } }).getSource();
private static Map<String, URI> prefixToNamespace(final SchemaContext ctx, final Module module) { final BiMap<String, URI> prefixMap = HashBiMap.create(module.getImports().size() + 1); prefixMap.put(module.getPrefix(), module.getNamespace()); for (final ModuleImport imp : module.getImports()) { final String prefix = imp.getPrefix(); final URI namespace = getModuleNamespace(ctx, imp.getModuleName()); prefixMap.put(prefix, namespace); } return prefixMap; }
public YangModuleCapability(final Module module, final String moduleContent) { super(toCapabilityURI(module)); this.content = moduleContent; this.moduleName = module.getName(); this.moduleNamespace = module.getNamespace().toString(); this.revision = SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()); }
public YangModuleCapability(final Module module, final String moduleContent) { super(toCapabilityURI(module)); this.content = moduleContent; this.moduleName = module.getName(); this.moduleNamespace = module.getNamespace().toString(); this.revision = SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()); }
private static Map<String, URI> prefixToNamespace(final SchemaContext ctx, final Module module) { final BiMap<String, URI> prefixMap = HashBiMap.create(module.getImports().size() + 1); prefixMap.put(module.getPrefix(), module.getNamespace()); for (final ModuleImport imp : module.getImports()) { final String prefix = imp.getPrefix(); final URI namespace = getModuleNamespace(ctx, imp.getModuleName()); prefixMap.put(prefix, namespace); } return prefixMap; }
private static void writeModuleToOutputStream(final SchemaContext ctx, final Module module, final XMLStreamWriter xmlStreamWriter, final boolean emitInstantiated) { final URI moduleNs = module.getNamespace(); final Map<String, URI> prefixToNs = prefixToNamespace(ctx, module); final StatementTextWriter yinWriter = SingleModuleYinStatementWriter.create(xmlStreamWriter, moduleNs, prefixToNs); SchemaContextEmitter.writeToStatementWriter(module, ctx, yinWriter, emitInstantiated); }
private void emitModuleHeader(final Module input) { emitYangVersionNode(input.getYangVersion()); emitNamespace(input.getNamespace()); emitPrefixNode(input.getPrefix()); }
private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module createModuleEntryFromModule(final Module module) { final ModuleBuilder moduleBuilder = new ModuleBuilder(); // TODO Conformance type is always set to Implement value, but it should it really be like this? // TODO Add also deviations and features lists to module entries moduleBuilder.setName(new YangIdentifier(module.getName())) .setRevision(new OptionalRevision(SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()))) .setNamespace(new Uri(module.getNamespace().toString())) .setConformanceType(ConformanceType.Implement) .setSubmodules(createSubmodulesForModule(module)); return moduleBuilder.build(); }
private RootNode createRootNode(String lastNodeName, String rootUri) { Module m = SchemaContextUtil.findParentModule(schemaCtx(), curSchema); Namespace ns = new Namespace(m.getName(), m.getNamespace(), getRevision(m.getRevision())); return new RootNode(lastNodeName, ns, schemaNode(), rootUri); }