Package uk.ac.starlink.fits
Class InputFactory
java.lang.Object
uk.ac.starlink.fits.InputFactory
- All Implemented Interfaces:
Closeable
,AutoCloseable
Represents a sequence of bytes, and can create BasicInput objects
to read it.
- Since:
- 2 Dec 2014
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic InputFactory
createByteStoreFactory
(uk.ac.starlink.table.ByteStore byteStore) Returns an input factory based on a populated bytestore.static InputFactory
createFactory
(uk.ac.starlink.util.DataSource datsrc, long offset, long leng) Constructs an instance of this class to read a given data source.static InputFactory
createFileFactory
(File uncompressedFile, long offset, long leng) Constructs an instance of this class to read a given uncompressed file.abstract BasicInput
createInput
(boolean isSeq) Returns a BasicInput instance to read this object's byte stream.static InputFactory
createRandomFactory
(uk.ac.starlink.util.DataSource datsrc, long offset, long leng, uk.ac.starlink.table.StoragePolicy policy) Returns an InputFactory for which random access is guaranteed.static InputFactory
createSequentialFactory
(uk.ac.starlink.util.DataSource datsrc, long offset, long leng) Constructs an instance of this class to read a given data source viewed as a stream, not a file.static BasicInput
Returns a non-random-access BasicInput based on a supplied input stream.abstract boolean
isRandom()
Indicates whether the BasicInput objects created by this factory will support random access.
-
Constructor Details
-
InputFactory
public InputFactory()
-
-
Method Details
-
isRandom
public abstract boolean isRandom()Indicates whether the BasicInput objects created by this factory will support random access.- Returns:
- true iff BasicInput.isRandom() will return true for created objects
-
createInput
Returns a BasicInput instance to read this object's byte stream.- Parameters:
isSeq
- if true, the returned object is expected to be used for sequential access only; this value is a hint which may or may not be used by the implementation- Returns:
- new reader; if isSeq is false and isRandom returns true, it will be capable of random access
- Throws:
IOException
-
createFactory
public static InputFactory createFactory(uk.ac.starlink.util.DataSource datsrc, long offset, long leng) throws IOException Constructs an instance of this class to read a given data source.- Parameters:
datsrc
- data sourceoffset
- offset into file of stream startleng
- number of bytes in stream- Returns:
- new instance
- Throws:
IOException
-
createSequentialFactory
public static InputFactory createSequentialFactory(uk.ac.starlink.util.DataSource datsrc, long offset, long leng) Constructs an instance of this class to read a given data source viewed as a stream, not a file.- Parameters:
datsrc
- data sourceoffset
- offset into file of stream startleng
- number of bytes in stream- Returns:
- new instance
-
createFileFactory
public static InputFactory createFileFactory(File uncompressedFile, long offset, long leng) throws IOException Constructs an instance of this class to read a given uncompressed file. It must be uncompressed for the random access to be able to locate the right part to read.- Parameters:
uncompressedFile
- unencoded fileoffset
- offset into file of stream startleng
- number of bytes in stream- Returns:
- new instance
- Throws:
IOException
-
createRandomFactory
public static InputFactory createRandomFactory(uk.ac.starlink.util.DataSource datsrc, long offset, long leng, uk.ac.starlink.table.StoragePolicy policy) throws IOException Returns an InputFactory for which random access is guaranteed. If necessary, the bytes from the data source will be cached using the supplied storage policy.- Parameters:
datsrc
- data sourceoffset
- offset into file of stream startleng
- number of bytes in streampolicy
- storage policy for caching if required, or null for default- Returns:
- new instance
- Throws:
IOException
-
createByteStoreFactory
public static InputFactory createByteStoreFactory(uk.ac.starlink.table.ByteStore byteStore) throws IOException Returns an input factory based on a populated bytestore.- Parameters:
byteStore
- cache containing byte content- Returns:
- new input factory
- Throws:
IOException
-
createSequentialInput
Returns a non-random-access BasicInput based on a supplied input stream.- Parameters:
in
- input stream- Returns:
- non-random BasicInput
-