gpt4 book ai didi

org.opendaylight.yangtools.yang.model.parser.api.YangParser.addLibSource()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 19:25:31 27 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.yangtools.yang.model.parser.api.YangParser.addLibSource()方法的一些代码示例,展示了YangParser.addLibSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangParser.addLibSource()方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.model.parser.api.YangParser
类名称:YangParser
方法名:addLibSource

YangParser.addLibSource介绍

[英]Add library sources. Only library sources required by main sources are present in resulting SchemaContext. Any other library sources are ignored and this also applies to error reporting.

Note: Library sources are not supported in semantic version mode currently.
[中]添加库源。结果文本中只存在主源所需的库源。忽略任何其他库源,这也适用于错误报告。
注意:目前语义版本模式不支持库源。

代码示例

代码示例来源:origin: opendaylight/yangtools

default YangParser addLibSources(final Collection<SchemaSourceRepresentation> sources) throws IOException,
    YangSyntaxErrorException {
  for (SchemaSourceRepresentation source : sources) {
    addLibSource(source);
  }
  return this;
}

代码示例来源:origin: opendaylight/yangtools

/**
 * Add library sources. Only library sources required by main sources are present in resulting SchemaContext.
 * Any other library sources are ignored and this also applies to error reporting.
 *
 * <p>
 * Note: Library sources are not supported in semantic version mode currently.
 *
 * @param sources YANG sources which should be added into library sources
 * @throws YangSyntaxErrorException when one of the sources fails syntactic analysis
 * @throws IOException when an IO error occurs
 * @throws IllegalArgumentException if the representation is not supported
 */
default YangParser addLibSources(final SchemaSourceRepresentation... sources) throws IOException,
    YangSyntaxErrorException {
  for (SchemaSourceRepresentation source : sources) {
    addLibSource(source);
  }
  return this;
}

代码示例来源:origin: opendaylight/yangtools

ContextHolder toContext() throws IOException, YangParserException {
  for (YangTextSchemaSource source : toUniqueSources(dependencies)) {
    // This source is coming from a dependency:
    // - its identifier should be accurate, as it should have been processed into a file with accurate name
    // - it is not required to be parsed, hence we add it just as a library source
    parser.addLibSource(source);
  }
  final SchemaContext schemaContext = Verify.verifyNotNull(parser.buildSchemaContext());
  final Set<Module> modules = new HashSet<>();
  for (Module module : schemaContext.getModules()) {
    final SourceIdentifier modId = Util.moduleToIdentifier(module);
    LOG.debug("Looking for source {}", modId);
    if (modelsInProject.containsKey(modId)) {
      LOG.debug("Module {} belongs to current project", module);
      modules.add(module);
      for (Module sub : module.getSubmodules()) {
        final SourceIdentifier subId = Util.moduleToIdentifier(sub);
        if (!modelsInProject.containsKey(subId)) {
          LOG.warn("Submodule {} not found in input files", sub);
        }
      }
    }
  }
  return new ContextHolder(schemaContext, modules, modelsInProject.keySet());
}

代码示例来源:origin: opendaylight/yangtools

static SchemaContext parseYangSources(final Set<QName> supportedFeatures, final List<File> testFiles,
    final List<File> libFiles) throws IOException, YangParserException {
  checkArgument(!testFiles.isEmpty(), "No yang sources");
  final YangParser parser = PARSER_FACTORY.createParser();
  if (supportedFeatures != null) {
    parser.setSupportedFeatures(supportedFeatures);
  }
  for (File file : testFiles) {
    parser.addSource(YangTextSchemaSource.forFile(file));
  }
  for (File file : libFiles) {
    parser.addLibSource(YangTextSchemaSource.forFile(file));
  }
  return parser.buildSchemaContext();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com