本文整理了Java中org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource.forResource()
方法的一些代码示例,展示了YangTextSchemaSource.forResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangTextSchemaSource.forResource()
方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource
类名称:YangTextSchemaSource
方法名:forResource
[英]Create a new YangTextSchemaSource backed by a resource by a resource available on the ClassLoader which loaded the specified class.
[中]通过加载指定类的类加载器上可用的资源创建一个新的YangTextSchemaSource,该资源由一个资源支持。
代码示例来源:origin: opendaylight/yangtools
/**
* Create a new {@link YangTextSchemaSource} backed by a resource available in the ClassLoader where this
* class resides.
*
* @param resourceName Resource name
* @return A new instance.
* @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
*/
// FIXME: 3.0.0: YANGTOOLS-849: return YangTextSchemaSource
public static @NonNull ResourceYangTextSchemaSource forResource(final String resourceName) {
return forResource(YangTextSchemaSource.class, resourceName);
}
代码示例来源:origin: org.opendaylight.yangtools/yang-model-api
/**
* Create a new {@link YangTextSchemaSource} backed by a resource available in the ClassLoader where this
* class resides.
*
* @param resourceName Resource name
* @return A new instance.
* @throws IllegalArgumentException if the resource does not exist or if the name has invalid format
*/
// FIXME: 3.0.0: YANGTOOLS-849: return YangTextSchemaSource
public static @NonNull ResourceYangTextSchemaSource forResource(final String resourceName) {
return forResource(YangTextSchemaSource.class, resourceName);
}
代码示例来源:origin: opendaylight/yangtools
public static SchemaContext parseYangResources(final Class<?> clazz, final Collection<String> resources) {
final List<YangTextSchemaSource> sources = new ArrayList<>(resources.size());
for (final String r : resources) {
sources.add(YangTextSchemaSource.forResource(clazz, r));
}
return parseSources(StatementParserMode.DEFAULT_MODE, null, sources);
}
代码示例来源:origin: opendaylight/yangtools
/**
* Creates a new effective schema context containing the specified YANG source.
*
* @param resource relative path to the YANG file to be parsed
* @param supportedFeatures set of supported features based on which all if-feature statements in the parsed YANG
* model are resolved
* @param parserMode mode of statement parser
* @return effective schema context
*/
public static SchemaContext parseYangResource(final String resource, final StatementParserMode parserMode,
final Set<QName> supportedFeatures) {
final YangTextSchemaSource source = YangTextSchemaSource.forResource(YangParserTestUtils.class, resource);
return parseYangSources(parserMode, supportedFeatures, source);
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!