Package uk.ac.starlink.util
Class ByteArrayDataSource
- java.lang.Object
-
- uk.ac.starlink.util.DataSource
-
- uk.ac.starlink.util.ByteArrayDataSource
-
public class ByteArrayDataSource extends DataSource
DataSource implementation that uses an internal byte buffer to store the data.- Since:
- 1 Feb 2007
- Author:
- Mark Taylor
-
-
Field Summary
-
Fields inherited from class uk.ac.starlink.util.DataSource
DEFAULT_INTRO_LIMIT, MARK_WORKAROUND_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description ByteArrayDataSource(java.lang.String name, byte[] buffer)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getName()
Returns a name for this source.java.io.InputStream
getRawInputStream()
Provides a new InputStream for this data source.long
getRawLength()
Returns the length in bytes of the stream returned by getRawInputStream, if known.-
Methods inherited from class uk.ac.starlink.util.DataSource
close, forceCompression, getCompression, getHybridInputStream, getInputStream, getInputStream, getIntro, getIntroLimit, getLength, getMarkWorkaround, getPosition, getSystemId, getURL, makeDataSource, makeDataSource, makeDataSource, setCompression, setIntroLimit, setMarkWorkaround, setName, setPosition, toString
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from class:DataSource
Returns a name for this source. This name is mainly intended as a label identifying the source for use in informational messages; it is not in general intended to be used to provide an absolute reference to the source. Thus, for instance, if the source references a file, its name might be a relative pathname or simple filename, rather than its absolute pathname. To identify the source absolutely, theDataSource.getURL()
method (or some suitable class-specific method) should be used. If this source has a position, it should probably form part of this name.- Overrides:
getName
in classDataSource
- Returns:
- a name
-
getRawInputStream
public java.io.InputStream getRawInputStream()
Description copied from class:DataSource
Provides a new InputStream for this data source. This method should be implemented by subclasses to provide a new InputStream giving the raw content of the source each time it is called. The general contract of this method is that each time it is called it will return a stream with the same content.- Specified by:
getRawInputStream
in classDataSource
- Returns:
- an InputStream containing the data of this source
-
getRawLength
public long getRawLength()
Description copied from class:DataSource
Returns the length in bytes of the stream returned by getRawInputStream, if known. If the length is not known then -1 should be returned. The implementation of this method in DataSource returns -1; subclasses should override it if they can determine their length.- Overrides:
getRawLength
in classDataSource
- Returns:
- the length of the raw input stream, or -1
-
-