gpt4 book ai didi

org.opendaylight.yangtools.yang.model.parser.api.YangParser类的使用及代码示例

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

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

YangParser介绍

[英]Configurable single-use YANG parser. Each instance can be configured to use a different set of models after which it is built. Models once added cannot be removed.
[中]可配置的单用语法分析器。每个实例都可以配置为使用一组不同的模型来构建。模型一旦添加就不能删除。

代码示例

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

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

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

default YangParser addSources(final Collection<? extends SchemaSourceRepresentation> sources) throws IOException,
  YangSyntaxErrorException {
  for (SchemaSourceRepresentation source : sources) {
    addSource(source);
  }
  return this;
}

代码示例来源: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();
}

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

public static SchemaContext parseSources(final StatementParserMode parserMode, final Set<QName> supportedFeatures,
    final Collection<? extends SchemaSourceRepresentation> sources) {
  final YangParser parser = PARSER_FACTORY.createParser(parserMode);
  if (supportedFeatures != null) {
    parser.setSupportedFeatures(supportedFeatures);
  }
  try {
    parser.addSources(sources);
  } catch (YangSyntaxErrorException e) {
    throw new IllegalArgumentException("Malformed source", e);
  } catch (IOException e) {
    throw new IllegalArgumentException("Failed to read a source", e);
  }
  try {
    return parser.buildSchemaContext();
  } catch (YangParserException e) {
    throw new IllegalStateException("Failed to assemble SchemaContext", e);
  }
}

代码示例来源: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

/**
 * Add main sources. All main sources are present in resulting SchemaContext.
 *
 * @param sources which should be added into main 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 addSources(final SchemaSourceRepresentation... sources) throws IOException,
  YangSyntaxErrorException {
  for (SchemaSourceRepresentation source : sources) {
    addSource(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

final ASTSchemaSource astSource = TextToASTTransformer.transformText(textSource);
parser.addSource(astSource);

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