Package uk.ac.starlink.fits
Class AbstractArrayDataIO
- java.lang.Object
-
- uk.ac.starlink.fits.AbstractArrayDataIO
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.io.DataOutput,java.lang.AutoCloseable,nom.tam.util.ArrayDataInput,nom.tam.util.ArrayDataOutput,nom.tam.util.FitsIO
- Direct Known Subclasses:
MappedFile,MultiMappedFile
public abstract class AbstractArrayDataIO extends java.lang.Object implements nom.tam.util.ArrayDataInput, nom.tam.util.ArrayDataOutputAbstract implementation of an implementation of anom.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 theBufferedFileimplementation (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
BufferedFileimplementation 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 Constructor Description AbstractArrayDataIO()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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(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)intreadArray(java.lang.Object o)booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] buf)voidreadFully(byte[] buf, int start, int len)Reads a specified number of bytes into an array.intreadInt()longreadLArray(java.lang.Object o)java.lang.StringreadLine()Deprecated.seeDataInputStream.readLine()longreadLong()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()java.lang.StringreadUTF()protected abstract longremaining()Returns 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)voidwrite(java.lang.String[] strings)voidwrite(java.lang.String[] strings, int start, int length)voidwriteArray(java.lang.Object o)voidwriteBoolean(boolean val)voidwriteByte(int val)voidwriteBytes(java.lang.String s)voidwriteChar(int val)voidwriteChars(java.lang.String s)voidwriteDouble(double val)voidwriteFloat(float val)voidwriteInt(int val)voidwriteLong(long val)voidwriteShort(int val)voidwriteUTF(java.lang.String str)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
get
protected abstract byte get() throws java.io.IOExceptionReads one byte from the current position.- Returns:
- next byte
- Throws:
java.io.IOException
-
get
protected abstract void get(byte[] buf, int offset, int length) throws java.io.IOExceptionReads 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:
java.io.IOException
-
put
protected abstract void put(byte b) throws java.io.IOExceptionWrites a single byte at the current position.- Parameters:
b- output byte- Throws:
java.io.IOException
-
put
protected abstract void put(byte[] buf, int offset, int length) throws java.io.IOExceptionWrites 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:
java.io.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
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException- Specified by:
readBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Specified by:
readShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException- Specified by:
readIntin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Throws:
java.io.IOException
-
readLine
@Deprecated public java.lang.String readLine() throws java.io.IOExceptionDeprecated.seeDataInputStream.readLine()Not implemented - this method is deprecated in any case.- Specified by:
readLinein interfacejava.io.DataInput- Throws:
java.lang.UnsupportedOperationException- alwaysjava.io.IOException
-
readFully
public void readFully(byte[] buf, int start, int len) throws java.io.IOExceptionReads 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 interfacejava.io.DataInput- 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:
java.io.EOFException- if there are fewer than len bytes leftjava.io.IOException
-
read
public int read(byte[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(boolean[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(short[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(char[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(int[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(long[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(float[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(double[] buf, int start, int length) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] buf) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Throws:
java.io.IOException
-
read
public int read(byte[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(boolean[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(short[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(char[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(int[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(long[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(float[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
read
public int read(double[] buf) throws java.io.IOException- Specified by:
readin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
readArray
public int readArray(java.lang.Object o) throws java.io.IOException- Specified by:
readArrayin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
readLArray
public long readLArray(java.lang.Object o) throws java.io.IOException- Specified by:
readLArrayin interfacenom.tam.util.ArrayDataInput- Throws:
java.io.IOException
-
write
public void write(int val) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeBoolean
public void writeBoolean(boolean val) throws java.io.IOException- Specified by:
writeBooleanin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeByte
public void writeByte(int val) throws java.io.IOException- Specified by:
writeBytein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeShort
public void writeShort(int val) throws java.io.IOException- Specified by:
writeShortin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChar
public void writeChar(int val) throws java.io.IOException- Specified by:
writeCharin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeInt
public void writeInt(int val) throws java.io.IOException- Specified by:
writeIntin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeLong
public void writeLong(long val) throws java.io.IOException- Specified by:
writeLongin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeFloat
public void writeFloat(float val) throws java.io.IOException- Specified by:
writeFloatin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeDouble
public void writeDouble(double val) throws java.io.IOException- Specified by:
writeDoublein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
write
public void write(boolean[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(short[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(char[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(int[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(long[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(float[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(double[] buf, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(java.lang.String[] strings, int start, int length) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
writeBytes
public void writeBytes(java.lang.String s) throws java.io.IOException- Specified by:
writeBytesin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeChars
public void writeChars(java.lang.String s) throws java.io.IOException- Specified by:
writeCharsin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
writeUTF
public void writeUTF(java.lang.String str) throws java.io.IOException- Specified by:
writeUTFin interfacejava.io.DataOutput- Throws:
java.io.IOException
-
write
public void write(byte[] buf) throws java.io.IOException- Specified by:
writein interfacejava.io.DataOutput- Throws:
java.io.IOException
-
write
public void write(boolean[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(short[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(char[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(int[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(long[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(float[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(double[] buf) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
write
public void write(java.lang.String[] strings) throws java.io.IOException- Specified by:
writein interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
writeArray
public void writeArray(java.lang.Object o) throws java.io.IOException- Specified by:
writeArrayin interfacenom.tam.util.ArrayDataOutput- Throws:
java.io.IOException
-
-