Package uk.ac.starlink.fits
Class InputFactory
- java.lang.Object
-
- uk.ac.starlink.fits.InputFactory
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public abstract class InputFactory extends java.lang.Object implements java.io.CloseableRepresents a sequence of bytes, and can create BasicInput objects to read it.- Since:
- 2 Dec 2014
- Author:
- Mark Taylor
-
-
Constructor Summary
Constructors Constructor Description InputFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static InputFactorycreateFactory(uk.ac.starlink.util.DataSource datsrc, long offset, long leng)Constructs an instance of this class to read a given data source.static InputFactorycreateFileFactory(java.io.File uncompressedFile, long offset, long leng)Constructs an instance of this class to read a given uncompressed file.abstract BasicInputcreateInput(boolean isSeq)Returns a BasicInput instance to read this object's byte stream.static InputFactorycreateSequentialFactory(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 BasicInputcreateSequentialInput(java.io.DataInput in)Returns a non-random-access BasicInput based on a supplied input stream.abstract booleanisRandom()Indicates whether the BasicInput objects created by this factory will support random access.
-
-
-
Method Detail
-
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
public abstract BasicInput createInput(boolean isSeq) throws java.io.IOException
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:
java.io.IOException
-
createFactory
public static InputFactory createFactory(uk.ac.starlink.util.DataSource datsrc, long offset, long leng) throws java.io.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:
java.io.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(java.io.File uncompressedFile, long offset, long leng) throws java.io.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:
java.io.IOException
-
createSequentialInput
public static BasicInput createSequentialInput(java.io.DataInput in)
Returns a non-random-access BasicInput based on a supplied input stream. The result is just an adapter wrapping the supplied DataInput.- Parameters:
in- input stream- Returns:
- non-random BasicInput
-
-