@Beta public 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 Type
    Method
    Description
    addLibSource(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation source)
     
    default @NonNull YangParser
    addLibSources(Collection<org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation> sources)
     
    default @NonNull YangParser
    addLibSources(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation... sources)
    Add library sources.
    @NonNull YangParser
    addSource(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation source)
    Add main source.
    default @NonNull YangParser
    addSources(Collection<? extends org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation> sources)
     
    default @NonNull YangParser
    addSources(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation... sources)
    Add main sources.
    @NonNull List<org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<?>>
    Build the declared view of a combined view of declared statements.
    @NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext
    Build the effective view of a combined view of effective statements.
    @NonNull YangParser
    setModulesWithSupportedDeviations(@NonNull com.google.common.collect.SetMultimap<QNameModule,QNameModule> modulesDeviatedByModules)
    Set YANG modules which can be deviated by specified modules during the parsing process.
    @NonNull YangParser
    setSupportedFeatures(@NonNull org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet supportedFeatures)
    Set supported features based on which all if-feature statements in the parsed YANG modules will be resolved.
    @NonNull Collection<Class<? extends org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation>>
    Return enumeration of concrete types of SchemaSourceRepresentation parsers created from this factory support.
  • Method Details

    • supportedSourceRepresentations

      @NonNull Collection<Class<? extends org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation>> supportedSourceRepresentations()
      Return enumeration of concrete types of SchemaSourceRepresentation 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(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation 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 analysis
      IOException - when an IO error occurs
      IllegalArgumentException - if the representation is not supported
    • addSources

      default @NonNull YangParser addSources(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation... 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 analysis
      IOException - when an IO error occurs
      IllegalArgumentException - if the representation is not supported
    • addSources

      default @NonNull YangParser addSources(Collection<? extends org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation> sources) throws IOException, YangSyntaxErrorException
      Throws:
      IOException
      YangSyntaxErrorException
    • addLibSource

      YangParser addLibSource(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation source) throws IOException, YangSyntaxErrorException
      Throws:
      IOException
      YangSyntaxErrorException
    • addLibSources

      default @NonNull YangParser addLibSources(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation... 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 analysis
      IOException - when an IO error occurs
      IllegalArgumentException - if the representation is not supported
    • addLibSources

      default @NonNull YangParser addLibSources(Collection<org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation> sources) throws IOException, YangSyntaxErrorException
      Throws:
      IOException
      YangSyntaxErrorException
    • setSupportedFeatures

      @NonNull YangParser setSupportedFeatures(@NonNull org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet supportedFeatures)
      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 com.google.common.collect.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

      @NonNull List<org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement<?>> buildDeclaredModel() throws YangParserException
      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

      @NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext buildEffectiveModel() throws YangParserException
      Build the effective view of a combined view of effective statements. Note that this representation, unlike buildDeclaredModel() 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