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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
static @NonNull YangTextSchemaContextResolver
create(String name)
static @NonNull YangTextSchemaContextResolver
create(String name, YangParserFactory factory)
Set<SourceIdentifier>
getAvailableSources()
Return the set of sources currently available in this resolved.Optional<? extends EffectiveModelContext>
getEffectiveModelContext()
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.FluentFuture<YangTextSchemaSource>
getSource(SourceIdentifier sourceIdentifier)
Returns a representation a for supplied YANG source identifier.Collection<YangTextSchemaSource>
getSourceTexts(SourceIdentifier sourceIdentifier)
@NonNull YangTextSchemaSourceRegistration
registerSource(@NonNull URL url)
Register a URL containing a YANG text.@NonNull YangTextSchemaSourceRegistration
registerSource(@NonNull YangTextSchemaSource source)
Register aYangTextSchemaSource
.EffectiveModelContext
trySchemaContext()
EffectiveModelContext
trySchemaContext(StatementParserMode statementParserMode)
-
-
-
Method Detail
-
create
public static @NonNull YangTextSchemaContextResolver create(String name)
-
create
public static @NonNull YangTextSchemaContextResolver create(String name, YangParserFactory factory)
-
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
-
getEffectiveModelContext
public Optional<? extends EffectiveModelContext> 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
public FluentFuture<YangTextSchemaSource> getSource(SourceIdentifier sourceIdentifier)
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
public Set<SourceIdentifier> getAvailableSources()
Return the set of sources currently available in this resolved.- Returns:
- An immutable point-in-time view of available sources.
-
getSourceTexts
@Beta public Collection<YangTextSchemaSource> getSourceTexts(SourceIdentifier sourceIdentifier)
-
trySchemaContext
@Beta public EffectiveModelContext trySchemaContext() throws SchemaResolutionException
- Throws:
SchemaResolutionException
-
trySchemaContext
@Beta public EffectiveModelContext trySchemaContext(StatementParserMode statementParserMode) throws SchemaResolutionException
- Throws:
SchemaResolutionException
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-