gpt4 book ai didi

org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource.openStream()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 08:06:40 28 4
gpt4 key购买 nike

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

YangTextSchemaSource.openStream介绍

暂无

代码示例

代码示例来源:origin: org.opendaylight.yangtools/yang-model-util

@Override
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
  justification = "https://github.com/spotbugs/spotbugs/issues/600")
protected void storeAsType(final File file, final YangTextSchemaSource cast) {
  try (InputStream castStream = cast.openStream()) {
    Files.copy(castStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
  } catch (final IOException e) {
    throw new IllegalStateException("Cannot store schema source " + cast.getIdentifier() + " to " + file,
        e);
  }
}

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

@Override
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
  justification = "https://github.com/spotbugs/spotbugs/issues/600")
protected void storeAsType(final File file, final YangTextSchemaSource cast) {
  try (InputStream castStream = cast.openStream()) {
    Files.copy(castStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
  } catch (final IOException e) {
    throw new IllegalStateException("Cannot store schema source " + cast.getIdentifier() + " to " + file,
        e);
  }
}

代码示例来源:origin: org.opendaylight.controller/netconf-testtool

private Map<ModuleBuilder, String> toModuleBuilders(final Map<SourceIdentifier, Map.Entry<ASTSchemaSource, YangTextSchemaSource>> sources) {
  final Map<SourceIdentifier, ParserRuleContext> asts = Maps.transformValues(sources, new Function<Map.Entry<ASTSchemaSource, YangTextSchemaSource>, ParserRuleContext>() {
    @Override
    public ParserRuleContext apply(final Map.Entry<ASTSchemaSource, YangTextSchemaSource> input) {
      return input.getKey().getAST();
    }
  });
  final Map<String, NavigableMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
      asts.values(), Optional.<SchemaContext>absent());
  final ParseTreeWalker walker = new ParseTreeWalker();
  final Map<ModuleBuilder, String> sourceToBuilder = new HashMap<>();
  for (final Map.Entry<SourceIdentifier, ParserRuleContext> entry : asts.entrySet()) {
    final ModuleBuilder moduleBuilder = YangParserListenerImpl.create(namespaceContext, entry.getKey().getName(),
        walker, entry.getValue()).getModuleBuilder();
    try(InputStreamReader stream = new InputStreamReader(sources.get(entry.getKey()).getValue().openStream(), Charsets.UTF_8)) {
      sourceToBuilder.put(moduleBuilder, CharStreams.toString(stream));
    } catch (final IOException e) {
      throw new RuntimeException(e);
    }
  }
  return sourceToBuilder;
}

代码示例来源:origin: org.opendaylight.netconf/mdsal-netconf-connector

private static Optional<YangModuleCapability> moduleToCapability(
    final Module module, final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency) {
  final SourceIdentifier moduleSourceIdentifier = SourceIdentifier.create(module.getName(),
      (SimpleDateFormatUtil.DEFAULT_DATE_REV == module.getRevision() ? Optional.<String>absent() :
          Optional.of(SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision()))));
  InputStream sourceStream = null;
  String source;
  try {
    sourceStream = rootSchemaSourceProviderDependency.getSource(moduleSourceIdentifier).checkedGet().openStream();
    source = CharStreams.toString(new InputStreamReader(sourceStream, StandardCharsets.UTF_8));
  } catch (IOException | SchemaSourceException e) {
    LOG.warn("Ignoring source for module {}. Unable to read content", moduleSourceIdentifier, e);
    source = null;
  }
  try {
    if (sourceStream != null) {
      sourceStream.close();
    }
  } catch (IOException e) {
    LOG.warn("Error closing yang source stream {}. Ignoring", moduleSourceIdentifier, e);
  }
  if(source !=null) {
    return Optional.of(new YangModuleCapability(module, source));
  } else {
    LOG.warn("Missing source for module {}. This module will not be available from netconf server",
        moduleSourceIdentifier);
  }
  return Optional.absent();
}

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

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