Class YangTextSchemaContextResolver
java.lang.Object
org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver
- All Implemented Interfaces:
AutoCloseable
,SchemaSourceProvider<YangTextSchemaSource>
public final class YangTextSchemaContextResolver
extends Object
implements AutoCloseable, SchemaSourceProvider<YangTextSchemaSource>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static @NonNull YangTextSchemaContextResolver
static @NonNull YangTextSchemaContextResolver
create
(String name, YangParserFactory factory) Return the set of sources currently available in this resolved.Optional<? extends EffectiveModelContext>
Try to parse all currently available yang files and build new schema context.Optional<? extends EffectiveModelContext>
getEffectiveModelContext
(StatementParserMode statementParserMode) Try to parse all currently available yang files and build new schema context depending on specified parsing mode.@NonNull FluentFuture<YangTextSchemaSource>
getSource
(SourceIdentifier sourceIdentifier) Returns a representation a for supplied YANG source identifier.getSourceTexts
(SourceIdentifier sourceIdentifier) @NonNull YangTextSchemaSourceRegistration
registerSource
(@NonNull URL url) Register a URL containing a YANG text.@NonNull YangTextSchemaSourceRegistration
registerSource
(@NonNull YangTextSchemaSource source) Register aYangTextSchemaSource
.@NonNull Registration
registerSupportedFeatures
(QNameModule module, Set<String> features) Register aQNameModule
as a known module namespace with a set of supported features.trySchemaContext
(StatementParserMode statementParserMode)
-
Method Details
-
create
-
create
-
registerSource
public @NonNull YangTextSchemaSourceRegistration registerSource(@NonNull YangTextSchemaSource source) throws SchemaSourceException, IOException, YangSyntaxErrorException Register aYangTextSchemaSource
.- Parameters:
source
- YANG text source- Returns:
- a YangTextSchemaSourceRegistration
- Throws:
YangSyntaxErrorException
- When the YANG file is syntactically invalidIOException
- when the URL is not readableSchemaSourceException
- When parsing encounters general error
-
registerSource
public @NonNull YangTextSchemaSourceRegistration registerSource(@NonNull URL url) throws SchemaSourceException, IOException, YangSyntaxErrorException Register a URL containing a YANG text.- Parameters:
url
- YANG text source URL- Returns:
- a YangTextSchemaSourceRegistration for this URL
- Throws:
YangSyntaxErrorException
- When the YANG file is syntactically invalidIOException
- when the URL is not readableSchemaSourceException
- When parsing encounters general error
-
registerSupportedFeatures
Register aQNameModule
as a known module namespace with a set of supported features. Union of these registrations is forwarded toFeatureSet
and this is then used ingetEffectiveModelContext()
and related methods.- Parameters:
module
- Module namespacefeatures
- Features supported for that module namespace- Returns:
- a
Registration
, useRegistration.close()
to revert the effects of this method - Throws:
NullPointerException
- if any argument isnull
-
getEffectiveModelContext
Try to parse all currently available yang files and build new schema context.- Returns:
- new schema context iif there is at least 1 yang file registered and new schema context was successfully built.
-
getEffectiveModelContext
public Optional<? extends EffectiveModelContext> getEffectiveModelContext(StatementParserMode statementParserMode) Try to parse all currently available yang files and build new schema context depending on specified parsing mode.- Parameters:
statementParserMode
- mode of statement parser- Returns:
- new schema context iif there is at least 1 yang file registered and new schema context was successfully built.
-
getSource
Description copied from interface:SchemaSourceProvider
Returns a representation a for supplied YANG source identifier. The resolution criteria are as follows:- If the source identifier specifies a revision, this method returns either
a representation of that particular revision or throw
MissingSchemaSourceException
. - If the source identifier does not specify a revision, this method returns
the newest available revision, or throws
MissingSchemaSourceException
.
In either case the returned representation is required to report a non-null revision in the
SourceIdentifier
returned fromSchemaSourceRepresentation.getIdentifier()
.Implementations are not required to provide constant behavior in time, notably this different invocation of this method may produce different results.
- Specified by:
getSource
in interfaceSchemaSourceProvider<YangTextSchemaSource>
- Parameters:
sourceIdentifier
- source identifier- Returns:
- future source representation, if supplied YANG module is available
- If the source identifier specifies a revision, this method returns either
a representation of that particular revision or throw
-
getAvailableSources
Return the set of sources currently available in this resolved.- Returns:
- An immutable point-in-time view of available sources.
-
getSourceTexts
-
trySchemaContext
- Throws:
SchemaResolutionException
-
trySchemaContext
@Beta public EffectiveModelContext trySchemaContext(StatementParserMode statementParserMode) throws SchemaResolutionException - Throws:
SchemaResolutionException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-