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 byteget()Reads one byte from the current position.protected abstract voidget(byte[] buf, int offset, int length) Reads bytes into a buffer from the current position.abstract longlength()Returns the size of this buffer.protected abstract voidput(byte b) Writes a single byte at the current position.protected abstract voidput(byte[] buf, int offset, int length) Writes bytes from a buffer to the current position.intread()intread(boolean[] buf) intread(boolean[] buf, int start, int length) intread(byte[] buf) intread(byte[] buf, int start, int length) intread(char[] buf) intread(char[] buf, int start, int length) intread(double[] buf) intread(double[] buf, int start, int length) intread(float[] buf) intread(float[] buf, int start, int length) intread(int[] buf) intread(int[] buf, int start, int length) intread(long[] buf) intread(long[] buf, int start, int length) intread(short[] buf) intread(short[] buf, int start, int length) intbooleanbytereadByte()charreadChar()doublefloatvoidreadFully(byte[] buf) voidreadFully(byte[] buf, int start, int len) Reads a specified number of bytes into an array.intreadInt()longreadLArray(Object o) readLine()Deprecated.longreadLong()shortintintreadUTF()protected abstract longReturns the number of bytes remaining between the current position and the end of the file.voidwrite(boolean[] buf) voidwrite(boolean[] buf, int start, int length) voidwrite(byte[] buf) voidwrite(byte[] buf, int start, int length) voidwrite(char[] buf) voidwrite(char[] buf, int start, int length) voidwrite(double[] buf) voidwrite(double[] buf, int start, int length) voidwrite(float[] buf) voidwrite(float[] buf, int start, int length) voidwrite(int val) voidwrite(int[] buf) voidwrite(int[] buf, int start, int length) voidwrite(long[] buf) voidwrite(long[] buf, int start, int length) voidwrite(short[] buf) voidwrite(short[] buf, int start, int length) voidvoidvoidwriteArray(Object o) voidwriteBoolean(boolean val) voidwriteByte(int val) voidwriteBytes(String s) voidwriteChar(int val) voidwriteChars(String s) voidwriteDouble(double val) voidwriteFloat(float val) voidwriteInt(int val) voidwriteLong(long val) voidwriteShort(int val) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nom.tam.util.ArrayDataInput
mark, markSupported, read, read, readArrayFully, readImage, reset, skip, skipAllBytes, skipAllBytesMethods inherited from interface nom.tam.util.ArrayDataOutput
flush, write, writeMethods 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 inbufto 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 inbufto be readlength- number of bytes frombufto 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:
readin interfacenom.tam.util.InputReader- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
readLine
Deprecated.Not implemented - this method is deprecated in any case.- Specified by:
readLinein 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:
readFullyin interfacenom.tam.util.ArrayDataInput- Specified by:
readFullyin 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:
readin interfacenom.tam.util.InputReader- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
read
- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
readArray
- Specified by:
readArrayin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
readLArray
- Specified by:
readLArrayin interfacenom.tam.util.ArrayDataInput- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfacenom.tam.util.OutputWriter- Throws:
IOException
-
writeBoolean
- Specified by:
writeBooleanin interfaceDataOutput- Throws:
IOException
-
writeByte
- Specified by:
writeBytein interfaceDataOutput- Throws:
IOException
-
writeShort
- Specified by:
writeShortin interfaceDataOutput- Throws:
IOException
-
writeChar
- Specified by:
writeCharin interfaceDataOutput- Throws:
IOException
-
writeInt
- Specified by:
writeIntin interfaceDataOutput- Throws:
IOException
-
writeLong
- Specified by:
writeLongin interfaceDataOutput- Throws:
IOException
-
writeFloat
- Specified by:
writeFloatin interfaceDataOutput- Throws:
IOException
-
writeDouble
- Specified by:
writeDoublein interfaceDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Specified by:
writein interfacenom.tam.util.OutputWriter- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
writeBytes
- Specified by:
writeBytesin interfaceDataOutput- Throws:
IOException
-
writeChars
- Specified by:
writeCharsin interfaceDataOutput- Throws:
IOException
-
writeUTF
- Specified by:
writeUTFin interfaceDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfaceDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
write
- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
writeArray
- Specified by:
writeArrayin interfacenom.tam.util.ArrayDataOutput- Throws:
IOException
-
DataInputStream.readLine()