Class YangTextSource

java.lang.Object
com.google.common.io.CharSource
org.opendaylight.yangtools.yang.model.spi.source.YangTextSource
All Implemented Interfaces:
Immutable, SourceRepresentation, YangSourceRepresentation
Direct Known Subclasses:
StringYangTextSource

public abstract class YangTextSource extends CharSource implements YangSourceRepresentation
YANG text schema source representation. Exposes an RFC6020 or RFC7950 text representation as an InputStream.
  • Constructor Details

  • Method Details

    • identifierFromFilename

      public static @NonNull SourceIdentifier identifierFromFilename(String name)
    • delegateForByteSource

      public static @NonNull YangTextSource delegateForByteSource(SourceIdentifier identifier, ByteSource delegate, Charset charset)
      Create a new YangTextSchemaSource with a specific source identifier and backed by ByteSource, which provides the actual InputStreams.
      Parameters:
      identifier - SourceIdentifier of the resulting schema source
      delegate - Backing ByteSource instance
      charset - Expected character set
      Returns:
      A new YangTextSchemaSource
    • delegateForByteSource

      public static @NonNull YangTextSource delegateForByteSource(String fileName, ByteSource delegate, Charset charset)
      Create a new YangTextSchemaSource with SourceIdentifier derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.
      Parameters:
      fileName - File name
      delegate - Backing ByteSource instance
      Returns:
      A new YangTextSchemaSource
      Throws:
      IllegalArgumentException - if the file name has invalid format
    • delegateForCharSource

      public static @NonNull YangTextSource delegateForCharSource(SourceIdentifier identifier, CharSource delegate)
      Create a new YangTextSchemaSource with a specific source identifier and backed by ByteSource, which provides the actual InputStreams.
      Parameters:
      identifier - SourceIdentifier of the resulting schema source
      delegate - Backing CharSource instance
      Returns:
      A new YangTextSchemaSource
    • delegateForCharSource

      public static @NonNull YangTextSource delegateForCharSource(String fileName, CharSource delegate)
      Create a new YangTextSchemaSource with SourceIdentifier derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.
      Parameters:
      fileName - File name
      delegate - Backing CharSource instance
      Returns:
      A new YangTextSchemaSource
      Throws:
      IllegalArgumentException - if the file name has invalid format
    • forPath

      public static @NonNull YangTextSource forPath(Path path)
      Create a new YangTextSchemaSource backed by a File with SourceIdentifier derived from the file name.
      Parameters:
      path - Backing path
      Returns:
      A new YangTextSchemaSource
      Throws:
      IllegalArgumentException - if the file name has invalid format or if the supplied File is not a file
      NullPointerException - if file is null
    • forPath

      public static @NonNull YangTextSource forPath(Path path, SourceIdentifier identifier)
      Create a new YangTextSchemaSource backed by a File and specified SourceIdentifier.
      Parameters:
      path - Backing path
      identifier - source identifier
      Returns:
      A new YangTextSchemaSource
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if the supplied path is not a regular file
    • forPath

      public static @NonNull YangTextSource forPath(Path path, SourceIdentifier identifier, Charset charset)
      Create a new YangTextSchemaSource backed by a File and specified SourceIdentifier.
      Parameters:
      path - Backing path
      identifier - Source identifier
      charset - expected stream character set
      Returns:
      A new YangTextSchemaSource
      Throws:
      NullPointerException - if any argument is null
      IllegalArgumentException - if the supplied path is not a regular file
    • forResource

      public static @NonNull YangTextSource forResource(String resourceName)
      Create a new YangTextSource backed by a resource available in the ClassLoader where this class resides.
      Parameters:
      resourceName - Resource name
      Returns:
      A new instance.
      Throws:
      IllegalArgumentException - if the resource does not exist or if the name has invalid format
    • forResource

      public static @NonNull YangTextSource forResource(Class<?> clazz, String resourceName)
      Create a new YangTextSource backed by a resource by a resource available on the ClassLoader which loaded the specified class.
      Parameters:
      clazz - Class reference
      resourceName - Resource name
      Returns:
      A new instance.
      Throws:
      IllegalArgumentException - if the resource does not exist or if the name has invalid format
    • forResource

      public static @NonNull YangTextSource forResource(Class<?> clazz, String resourceName, Charset charset)
      Create a new YangTextSource backed by a resource by a resource available on the ClassLoader which loaded the specified class.
      Parameters:
      clazz - Class reference
      resourceName - Resource name
      charset - Expected character set
      Returns:
      A new instance.
      Throws:
      IllegalArgumentException - if the resource does not exist or if the name has invalid format
    • forURL

      public static @NonNull YangTextSource forURL(URL url, SourceIdentifier identifier)
      Create a new YangTextSource backed by a URL.
      Parameters:
      url - Backing URL
      identifier - Source identifier
      Returns:
      A new instance.
      Throws:
      NullPointerException - if any argument is null
    • forURL

      public static @NonNull YangTextSource forURL(URL url, SourceIdentifier identifier, Charset charset)
      Create a new YangTextSource backed by a URL.
      Parameters:
      url - Backing URL
      identifier - Source identifier
      charset - Expected character set
      Returns:
      A new instance.
      Throws:
      NullPointerException - if any argument is null
    • getType

      public final Class<YangTextSource> getType()
      Description copied from interface: SourceRepresentation
      Return the concrete representation type.
      Specified by:
      getType in interface SourceRepresentation
      Specified by:
      getType in interface YangSourceRepresentation
      Returns:
      The type of representation.
    • sourceId

      public final SourceIdentifier sourceId()
      Description copied from interface: SourceRepresentation
      The SourceIdentifier of this source.
      Specified by:
      sourceId in interface SourceRepresentation
      Returns:
      SourceIdentifier of this source
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • addToStringAttributes

      protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper)
      Add subclass-specific attributes to the output toString() output. Since subclasses are prevented from overriding toString() for consistency reasons, they can add their specific attributes to the resulting string by attaching attributes to the supplied MoreObjects.ToStringHelper.
      Parameters:
      toStringHelper - ToStringHelper onto the attributes can be added
      Returns:
      ToStringHelper supplied as input argument.