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
YANG text schema source representation. Exposes an RFC6020 or RFC7950 text representation as an
InputStream
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MoreObjects.ToStringHelper
addToStringAttributes
(MoreObjects.ToStringHelper toStringHelper) Add subclass-specific attributes to the outputtoString()
output.static @NonNull YangTextSource
delegateForByteSource
(String fileName, ByteSource delegate, Charset charset) Create a new YangTextSchemaSource withSourceIdentifier
derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.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.static @NonNull YangTextSource
delegateForCharSource
(String fileName, CharSource delegate) Create a new YangTextSchemaSource withSourceIdentifier
derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.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.static @NonNull YangTextSource
Create a new YangTextSchemaSource backed by aFile
withSourceIdentifier
derived from the file name.static @NonNull YangTextSource
forPath
(Path path, SourceIdentifier identifier) Create a new YangTextSchemaSource backed by aFile
and specifiedSourceIdentifier
.static @NonNull YangTextSource
forPath
(Path path, SourceIdentifier identifier, Charset charset) Create a new YangTextSchemaSource backed by aFile
and specifiedSourceIdentifier
.static @NonNull YangTextSource
forResource
(Class<?> clazz, String resourceName) Create a newYangTextSource
backed by a resource by a resource available on the ClassLoader which loaded the specified class.static @NonNull YangTextSource
forResource
(Class<?> clazz, String resourceName, Charset charset) Create a newYangTextSource
backed by a resource by a resource available on the ClassLoader which loaded the specified class.static @NonNull YangTextSource
forResource
(String resourceName) Create a newYangTextSource
backed by a resource available in the ClassLoader where this class resides.static @NonNull YangTextSource
forURL
(URL url, SourceIdentifier identifier) Create a newYangTextSource
backed by a URL.static @NonNull YangTextSource
forURL
(URL url, SourceIdentifier identifier, Charset charset) Create a newYangTextSource
backed by a URL.final Class<YangTextSource>
getType()
Return the concrete representation type.static @NonNull SourceIdentifier
identifierFromFilename
(String name) final SourceIdentifier
sourceId()
TheSourceIdentifier
of this source.final String
toString()
Methods inherited from class com.google.common.io.CharSource
asByteSource, concat, concat, concat, copyTo, copyTo, empty, forEachLine, isEmpty, length, lengthIfKnown, lines, openBufferedStream, openStream, read, readFirstLine, readLines, readLines, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation
symbolicName
-
Constructor Details
-
YangTextSource
-
-
Method Details
-
identifierFromFilename
-
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 sourcedelegate
- Backing ByteSource instancecharset
- Expected character set- Returns:
- A new YangTextSchemaSource
-
delegateForByteSource
public static @NonNull YangTextSource delegateForByteSource(String fileName, ByteSource delegate, Charset charset) Create a new YangTextSchemaSource withSourceIdentifier
derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.- Parameters:
fileName
- File namedelegate
- 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 sourcedelegate
- Backing CharSource instance- Returns:
- A new YangTextSchemaSource
-
delegateForCharSource
Create a new YangTextSchemaSource withSourceIdentifier
derived from a supplied filename and backed by ByteSource, which provides the actual InputStreams.- Parameters:
fileName
- File namedelegate
- Backing CharSource instance- Returns:
- A new YangTextSchemaSource
- Throws:
IllegalArgumentException
- if the file name has invalid format
-
forPath
Create a new YangTextSchemaSource backed by aFile
withSourceIdentifier
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 fileNullPointerException
- if file isnull
-
forPath
Create a new YangTextSchemaSource backed by aFile
and specifiedSourceIdentifier
.- Parameters:
path
- Backing pathidentifier
- source identifier- Returns:
- A new YangTextSchemaSource
- Throws:
NullPointerException
- if any argument isnull
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 aFile
and specifiedSourceIdentifier
.- Parameters:
path
- Backing pathidentifier
- Source identifiercharset
- expected stream character set- Returns:
- A new YangTextSchemaSource
- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- if the supplied path is not a regular file
-
forResource
Create a newYangTextSource
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
Create a newYangTextSource
backed by a resource by a resource available on the ClassLoader which loaded the specified class.- Parameters:
clazz
- Class referenceresourceName
- 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 newYangTextSource
backed by a resource by a resource available on the ClassLoader which loaded the specified class.- Parameters:
clazz
- Class referenceresourceName
- Resource namecharset
- Expected character set- Returns:
- A new instance.
- Throws:
IllegalArgumentException
- if the resource does not exist or if the name has invalid format
-
forURL
Create a newYangTextSource
backed by a URL.- Parameters:
url
- Backing URLidentifier
- Source identifier- Returns:
- A new instance.
- Throws:
NullPointerException
- if any argument isnull
-
forURL
Create a newYangTextSource
backed by a URL.- Parameters:
url
- Backing URLidentifier
- Source identifiercharset
- Expected character set- Returns:
- A new instance.
- Throws:
NullPointerException
- if any argument isnull
-
getType
Description copied from interface:SourceRepresentation
Return the concrete representation type.- Specified by:
getType
in interfaceSourceRepresentation
- Specified by:
getType
in interfaceYangSourceRepresentation
- Returns:
- The type of representation.
-
sourceId
Description copied from interface:SourceRepresentation
TheSourceIdentifier
of this source.- Specified by:
sourceId
in interfaceSourceRepresentation
- Returns:
SourceIdentifier
of this source
-
toString
-
addToStringAttributes
protected MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper) Add subclass-specific attributes to the outputtoString()
output. Since subclasses are prevented from overridingtoString()
for consistency reasons, they can add their specific attributes to the resulting string by attaching attributes to the suppliedMoreObjects.ToStringHelper
.- Parameters:
toStringHelper
- ToStringHelper onto the attributes can be added- Returns:
- ToStringHelper supplied as input argument.
-