Interface YangParser
Configurable single-use YANG parser. Each instance can be configured to use a different set of models after
which it is built. Models once added cannot be removed. Implementations are expected to be NOT thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionaddLibSource
(SourceRepresentation source) default @NonNull YangParser
addLibSources
(Collection<SourceRepresentation> sources) default @NonNull YangParser
addLibSources
(SourceRepresentation... sources) Add library sources.@NonNull YangParser
addSource
(SourceRepresentation source) Add main source.default @NonNull YangParser
addSources
(Collection<? extends SourceRepresentation> sources) default @NonNull YangParser
addSources
(SourceRepresentation... sources) Add main sources.@NonNull List
<DeclaredStatement<?>> Build the declared view of a combined view of declared statements.@NonNull EffectiveModelContext
Build the effective view of a combined view of effective statements.@NonNull YangParser
setModulesWithSupportedDeviations
(@NonNull SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules) Set YANG modules which can be deviated by specified modules during the parsing process.@NonNull YangParser
setSupportedFeatures
(@NonNull FeatureSet supportedFeatures) Set supported features based on which all if-feature statements in the parsed YANG modules will be resolved.@NonNull Collection
<Class<? extends SourceRepresentation>> Return enumeration of concrete types ofSourceRepresentation
parsers created from this factory support.
-
Method Details
-
supportedSourceRepresentations
@NonNull Collection<Class<? extends SourceRepresentation>> supportedSourceRepresentations()Return enumeration of concrete types ofSourceRepresentation
parsers created from this factory support. Users can use this information prepare the source they have to a representation which will be accepted by this parser.- Returns:
- Enumeration of supported schema source representations.
-
addSource
@NonNull YangParser addSource(SourceRepresentation source) throws IOException, YangSyntaxErrorException Add main source. All main sources are present in resulting SchemaContext.- Parameters:
source
- which should be added into main sources- Throws:
YangSyntaxErrorException
- when one of the sources fails syntactic analysisIOException
- when an IO error occursIllegalArgumentException
- if the representation is not supported
-
addSources
default @NonNull YangParser addSources(SourceRepresentation... sources) throws IOException, YangSyntaxErrorException Add main sources. All main sources are present in resulting SchemaContext.- Parameters:
sources
- which should be added into main sources- Throws:
YangSyntaxErrorException
- when one of the sources fails syntactic analysisIOException
- when an IO error occursIllegalArgumentException
- if the representation is not supported
-
addSources
default @NonNull YangParser addSources(Collection<? extends SourceRepresentation> sources) throws IOException, YangSyntaxErrorException - Throws:
IOException
YangSyntaxErrorException
-
addLibSource
- Throws:
IOException
YangSyntaxErrorException
-
addLibSources
default @NonNull YangParser addLibSources(SourceRepresentation... sources) throws IOException, YangSyntaxErrorException Add library sources. Only library sources required by main sources are present in resulting SchemaContext. Any other library sources are ignored and this also applies to error reporting.Note: Library sources are not supported in semantic version mode currently.
- Parameters:
sources
- YANG sources which should be added into library sources- Throws:
YangSyntaxErrorException
- when one of the sources fails syntactic analysisIOException
- when an IO error occursIllegalArgumentException
- if the representation is not supported
-
addLibSources
default @NonNull YangParser addLibSources(Collection<SourceRepresentation> sources) throws IOException, YangSyntaxErrorException - Throws:
IOException
YangSyntaxErrorException
-
setSupportedFeatures
Set supported features based on which all if-feature statements in the parsed YANG modules will be resolved. If this method is not invoked, all features will be supported.- Parameters:
supportedFeatures
- Set of supported features in the final SchemaContext. If the set is empty, no features encountered will be supported.
-
setModulesWithSupportedDeviations
@NonNull YangParser setModulesWithSupportedDeviations(@NonNull SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules) Set YANG modules which can be deviated by specified modules during the parsing process. Map key (QNameModule) denotes a module which can be deviated by the modules in the Map value.- Parameters:
modulesDeviatedByModules
- Map of YANG modules (Map key) which can be deviated by specified modules (Map value) in the final SchemaContext. If the map is empty, no deviations encountered will be supported.
-
buildDeclaredModel
Build the declared view of a combined view of declared statements.- Returns:
- Ordered collection of declared statements from requested sources.
- Throws:
YangSyntaxErrorException
- When a syntactic error is encountered.YangParserException
-
buildEffectiveModel
Build the effective view of a combined view of effective statements. Note that this representation, unlikebuildDeclaredModel()
does not expose submodules as top-level contracts. These are available from their respective parent modules.- Returns:
- Effective module statements indexed by their QNameModule.
- Throws:
YangSyntaxErrorException
- When a syntactic error is encountered.YangParserException
-