Package uk.ac.starlink.oldfits
Class AbstractArrayDataIO
java.lang.Object
uk.ac.starlink.oldfits.AbstractArrayDataIO
- All Implemented Interfaces:
Closeable
,DataInput
,DataOutput
,AutoCloseable
,nom.tam.util.ArrayDataInput
,nom.tam.util.ArrayDataOutput
,nom.tam.util.FitsIO
,nom.tam.util.InputReader
,nom.tam.util.OutputWriter
- Direct Known Subclasses:
MappedFile
public abstract class AbstractArrayDataIO
extends Object
implements nom.tam.util.ArrayDataInput, nom.tam.util.ArrayDataOutput
Abstract implementation of an implementation of a
nom.tam.util
-compatible FITS I/O handler.
The ArrayDataInput interface contains a lot of methods declared like
int read(type[]) throws IOException;whose behaviour is not documented - when do they throw an exception and what do they return? The behaviour implemented here follows that of the
BufferedFile
implementation (which is similarly
undocumented). It is as follows:
- The methods read as many items as there are left, up to the requested maximum or the end of file.
- The return value is the number of bytes read
- An EOFException is thrown only if no items could be read
BufferedFile
implementation for more details.- Since:
- 5 Jan 2007
- Author:
- Mark Taylor, Tom McGlynn
-
Field Summary
Fields inherited from interface nom.tam.util.FitsIO
BITS_OF_1_BYTE, BITS_OF_2_BYTES, BITS_OF_3_BYTES, BITS_OF_4_BYTES, BITS_OF_5_BYTES, BITS_OF_6_BYTES, BITS_OF_7_BYTES, BYTE_1_OF_LONG_MASK, BYTE_2_OF_LONG_MASK, BYTE_3_OF_LONG_MASK, BYTE_4_OF_LONG_MASK, BYTE_MASK, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_FLOAT, BYTES_IN_INTEGER, BYTES_IN_LONG, BYTES_IN_SHORT, DEFAULT_BUFFER_SIZE, HIGH_INTEGER_MASK, INTEGER_MASK, SHORT_MASK, SHORT_OF_LONG_MASK
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte
get()
Reads one byte from the current position.protected abstract void
get
(byte[] buf, int offset, int length) Reads bytes into a buffer from the current position.abstract long
length()
Returns the size of this buffer.protected abstract void
put
(byte b) Writes a single byte at the current position.protected abstract void
put
(byte[] buf, int offset, int length) Writes bytes from a buffer to the current position.int
read()
int
read
(boolean[] buf) int
read
(boolean[] buf, int start, int length) int
read
(byte[] buf) int
read
(byte[] buf, int start, int length) int
read
(char[] buf) int
read
(char[] buf, int start, int length) int
read
(double[] buf) int
read
(double[] buf, int start, int length) int
read
(float[] buf) int
read
(float[] buf, int start, int length) int
read
(int[] buf) int
read
(int[] buf, int start, int length) int
read
(long[] buf) int
read
(long[] buf, int start, int length) int
read
(short[] buf) int
read
(short[] buf, int start, int length) int
boolean
byte
readByte()
char
readChar()
double
float
void
readFully
(byte[] buf) void
readFully
(byte[] buf, int start, int len) Reads a specified number of bytes into an array.int
readInt()
long
readLArray
(Object o) readLine()
Deprecated.long
readLong()
short
int
int
readUTF()
protected abstract long
Returns the number of bytes remaining between the current position and the end of the file.void
write
(boolean[] buf) void
write
(boolean[] buf, int start, int length) void
write
(byte[] buf) void
write
(byte[] buf, int start, int length) void
write
(char[] buf) void
write
(char[] buf, int start, int length) void
write
(double[] buf) void
write
(double[] buf, int start, int length) void
write
(float[] buf) void
write
(float[] buf, int start, int length) void
write
(int val) void
write
(int[] buf) void
write
(int[] buf, int start, int length) void
write
(long[] buf) void
write
(long[] buf, int start, int length) void
write
(short[] buf) void
write
(short[] buf, int start, int length) void
void
void
writeArray
(Object o) void
writeBoolean
(boolean val) void
writeByte
(int val) void
writeBytes
(String s) void
writeChar
(int val) void
writeChars
(String s) void
writeDouble
(double val) void
writeFloat
(float val) void
writeInt
(int val) void
writeLong
(long val) void
writeShort
(int val) void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nom.tam.util.ArrayDataInput
mark, markSupported, read, read, readArrayFully, readImage, reset, skip, skipAllBytes, skipAllBytes
Methods inherited from interface nom.tam.util.ArrayDataOutput
flush, write, write
Methods inherited from interface nom.tam.util.FitsIO
close
-
Constructor Details
-
AbstractArrayDataIO
public AbstractArrayDataIO()
-
-
Method Details
-
get
Reads one byte from the current position.- Returns:
- next byte
- Throws:
IOException
-
get
Reads bytes into a buffer from the current position.- Parameters:
buf
- destination bufferoffset
- offset of first byte inbuf
to be writtenlength
- maximum number of bytes to be written tobuf
- Throws:
IOException
-
put
Writes a single byte at the current position.- Parameters:
b
- output byte- Throws:
IOException
-
put
Writes bytes from a buffer to the current position.- Parameters:
buf
- source bufferoffset
- offset of first byte inbuf
to be readlength
- number of bytes frombuf
to be read- Throws:
IOException
-
length
public abstract long length()Returns the size of this buffer. May be -1 if not known/unlimited.- Returns:
- length or -1
-
remaining
protected abstract long remaining()Returns the number of bytes remaining between the current position and the end of the file. If there is no end to the file, it is permissible to returnLong.MAX_VALUE
;- Returns:
- number of bytes left in file
-
read
- Specified by:
read
in interfacenom.tam.util.InputReader
- Throws:
IOException
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readUTF
- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
-
readLine
Deprecated.Not implemented - this method is deprecated in any case.- Specified by:
readLine
in interfaceDataInput
- Throws:
UnsupportedOperationException
- alwaysIOException
-
readFully
Reads a specified number of bytes into an array. Unlike the read methods, this throws an EOFException if insufficient bytes are available. In this case all the bytes that can be read, will be read before the exception is thrown.- Specified by:
readFully
in interfacenom.tam.util.ArrayDataInput
- Specified by:
readFully
in interfaceDataInput
- Parameters:
buf
- the byte buffer into which to readstart
- the index in buf at which to start putting byteslen
- the number of bytes which must be read- Throws:
EOFException
- if there are fewer than len bytes leftIOException
-
read
- Specified by:
read
in interfacenom.tam.util.InputReader
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
read
- Specified by:
read
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
readArray
- Specified by:
readArray
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
readLArray
- Specified by:
readLArray
in interfacenom.tam.util.ArrayDataInput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfacenom.tam.util.OutputWriter
- Throws:
IOException
-
writeBoolean
- Specified by:
writeBoolean
in interfaceDataOutput
- Throws:
IOException
-
writeByte
- Specified by:
writeByte
in interfaceDataOutput
- Throws:
IOException
-
writeShort
- Specified by:
writeShort
in interfaceDataOutput
- Throws:
IOException
-
writeChar
- Specified by:
writeChar
in interfaceDataOutput
- Throws:
IOException
-
writeInt
- Specified by:
writeInt
in interfaceDataOutput
- Throws:
IOException
-
writeLong
- Specified by:
writeLong
in interfaceDataOutput
- Throws:
IOException
-
writeFloat
- Specified by:
writeFloat
in interfaceDataOutput
- Throws:
IOException
-
writeDouble
- Specified by:
writeDouble
in interfaceDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Specified by:
write
in interfacenom.tam.util.OutputWriter
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
writeBytes
- Specified by:
writeBytes
in interfaceDataOutput
- Throws:
IOException
-
writeChars
- Specified by:
writeChars
in interfaceDataOutput
- Throws:
IOException
-
writeUTF
- Specified by:
writeUTF
in interfaceDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
write
- Specified by:
write
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
writeArray
- Specified by:
writeArray
in interfacenom.tam.util.ArrayDataOutput
- Throws:
IOException
-
DataInputStream.readLine()