gpt4 book ai didi

org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource类的使用及代码示例

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

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

YangStatementStreamSource介绍

[英]This class represents implementation of StatementStreamSource in order to emit YANG statements using supplied StatementWriter.
[中]此类表示StatementStreamSource的实现,以便使用提供的StatementWriter发出YANG语句。

代码示例

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

public static YangStatementStreamSource create(final SourceIdentifier identifier, final StatementContext context,
  final String symbolicName) {
  return new YangStatementStreamSource(identifier, context, symbolicName);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

@Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("identifier", getIdentifier()).toString();
  }
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

@Override
public void writeFull(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
    final PrefixToModule prefixes) {
  writeFull(writer, stmtDef, prefixes, YangVersion.VERSION_1);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

/**
 * Create a {@link YangStatementStreamSource} for a {@link ASTSchemaSource}.
 *
 * @param source YangTextSchemaSource, must not be null
 * @return A new {@link YangStatementStreamSource}
 */
public static YangStatementStreamSource create(final ASTSchemaSource source) {
  final ParserRuleContext ast = source.getAST();
  checkArgument(ast instanceof StatementContext,
      "Unsupported context class %s for source %s", ast.getClass(), source.getIdentifier());
  return create(source.getIdentifier(), (StatementContext) ast, source.getSymbolicName().orElse(null));
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

/**
 * Extracts {@link YangModelDependencyInfo} from input stream containing a YANG model. This parsing does not
 * validate full YANG module, only parses header up to the revisions and imports.
 *
 * @param refClass Base search class
 * @param resourceName resource name, relative to refClass
 * @return {@link YangModelDependencyInfo}
 * @throws YangSyntaxErrorException If the resource does not pass syntactic analysis
 * @throws IOException When the resource cannot be read
 * @throws IllegalArgumentException
 *             If input stream is not valid YANG stream
 */
@VisibleForTesting
public static YangModelDependencyInfo forResource(final Class<?> refClass, final String resourceName)
    throws IOException, YangSyntaxErrorException {
  final YangStatementStreamSource source = YangStatementStreamSource.create(
    YangTextSchemaSource.forResource(refClass, resourceName));
  final ParserRuleContext ast = source.getYangAST();
  checkArgument(ast instanceof StatementContext);
  return parseAST((StatementContext) ast, source.getIdentifier());
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

public static ASTSchemaSource transformText(final YangTextSchemaSource text) throws SchemaSourceException,
      IOException, YangSyntaxErrorException {
    final YangStatementStreamSource src = YangStatementStreamSource.create(text);
    final ParserRuleContext ctx = src.getYangAST();
    LOG.debug("Model {} parsed successfully", text);

    // TODO: missing validation (YangModelBasicValidationListener should be re-implemented to new parser)

    return ASTSchemaSource.create(text.getIdentifier(), text.getSymbolicName().orElse(null), ctx);
  }
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

/**
 * Create a {@link YangStatementStreamSource} for a {@link YangTextSchemaSource}.
 *
 * @param source YangTextSchemaSource, must not be null
 * @return A new {@link YangStatementStreamSource}
 * @throws IOException When we fail to read the source
 * @throws YangSyntaxErrorException If the source fails basic parsing
 */
public static YangStatementStreamSource create(final YangTextSchemaSource source) throws IOException,
    YangSyntaxErrorException {
  final StatementContext context;
  try (InputStream stream = source.openStream()) {
    context = parseYangSource(source.getIdentifier(), stream);
  }
  return new YangStatementStreamSource(source.getIdentifier(), context, source.getSymbolicName().orElse(null));
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

@Override
public void writeLinkageAndStatementDefinitions(final StatementWriter writer,
    final QNameToStatementDefinition stmtDef, final PrefixToModule prefixes) {
  writeLinkageAndStatementDefinitions(writer, stmtDef, prefixes, YangVersion.VERSION_1);
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-rfc7950

@Override
public void writeLinkage(final StatementWriter writer, final QNameToStatementDefinition stmtDef,
    final PrefixToModule preLinkagePrefixes) {
  writeLinkage(writer, stmtDef, preLinkagePrefixes, YangVersion.VERSION_1);
}

代码示例来源:origin: org.onap.ccsdk.sli.plugins/restconf-client-provider

/**
 * Returns the schema context of the YANG files present in a directory.
 *
 * @param di directory path
 * @return YANG schema context
 * @throws SvcLogicException when YANG file reading fails
 */
static SchemaContext getSchemaCtxFromDir(String di)
    throws SvcLogicException {
  Path d = Paths.get(di);
  File dir = d.toFile();
  List<File> yangFiles = new LinkedList<>();
  getYangFiles(dir, yangFiles);
  final Collection<YangStatementStreamSource> sources =
      new ArrayList<>(yangFiles.size());
  for (File file : yangFiles) {
    try {
      sources.add(create(forFile(file)));
    } catch (IOException | YangSyntaxErrorException e) {
      throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e);
    }
  }
  final CrossSourceStatementReactor.BuildAction reactor = defaultReactor()
      .newBuild(DEFAULT_MODE).addSources(sources);
  try {
    return reactor.buildEffective();
  } catch (ReactorException e) {
    throw new SvcLogicException(YANG_FILE_ERR + e.getMessage(), e);
  }
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-impl

private static StatementStreamSource sourceToStatementStream(final SchemaSourceRepresentation source)
      throws IOException, YangSyntaxErrorException {
    requireNonNull(source);
    if (source instanceof ASTSchemaSource) {
      return YangStatementStreamSource.create((ASTSchemaSource) source);
    } else if (source instanceof YangTextSchemaSource) {
      return YangStatementStreamSource.create((YangTextSchemaSource) source);
    } else if (source instanceof YinDomSchemaSource) {
      return YinStatementStreamSource.create((YinDomSchemaSource) source);
    } else if (source instanceof YinTextSchemaSource) {
      try {
        return YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
          (YinTextSchemaSource) source));
      } catch (SAXException e) {
        throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0, "Failed to parse XML text", e);
      }
    } else if (source instanceof YinXmlSchemaSource) {
      try {
        return YinStatementStreamSource.create((YinXmlSchemaSource) source);
      } catch (TransformerException e) {
        throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0,
          "Failed to assemble in-memory representation", e);
      }
    } else {
      throw new IllegalArgumentException("Unsupported source " + source);
    }
  }
}

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

private static StatementStreamSource sourceToStatementStream(final SchemaSourceRepresentation source)
      throws IOException, YangSyntaxErrorException {
    requireNonNull(source);
    if (source instanceof ASTSchemaSource) {
      return YangStatementStreamSource.create((ASTSchemaSource) source);
    } else if (source instanceof YangTextSchemaSource) {
      return YangStatementStreamSource.create((YangTextSchemaSource) source);
    } else if (source instanceof YinDomSchemaSource) {
      return YinStatementStreamSource.create((YinDomSchemaSource) source);
    } else if (source instanceof YinTextSchemaSource) {
      try {
        return YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
          (YinTextSchemaSource) source));
      } catch (SAXException e) {
        throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0, "Failed to parse XML text", e);
      }
    } else if (source instanceof YinXmlSchemaSource) {
      try {
        return YinStatementStreamSource.create((YinXmlSchemaSource) source);
      } catch (TransformerException e) {
        throw new YangSyntaxErrorException(source.getIdentifier(), 0, 0,
          "Failed to assemble in-memory representation", e);
      }
    } else {
      throw new IllegalArgumentException("Unsupported source " + source);
    }
  }
}

代码示例来源:origin: org.opendaylight.yangtools/yang-parser-impl

parserRuleCtx.getClass(), e.getKey());
reactor.addSource(YangStatementStreamSource.create(e.getKey(), (StatementContext) parserRuleCtx,
  ast.getSymbolicName().orElse(null)));

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

parserRuleCtx.getClass(), e.getKey());
reactor.addSource(YangStatementStreamSource.create(e.getKey(), (StatementContext) parserRuleCtx,
  ast.getSymbolicName().orElse(null)));

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