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
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
Consult the 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
    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(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
     
    char
     
    double
     
    float
     
    void
    readFully(byte[] buf)
     
    void
    readFully(byte[] buf, int start, int len)
    Reads a specified number of bytes into an array.
    int
     
    long
     
    long
     
    short
     
    int
     
    int
     
     
    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
    write(String[] strings)
     
    void
    write(String[] strings, int start, int length)
     
    void
     
    void
    writeBoolean(boolean val)
     
    void
    writeByte(int val)
     
    void
     
    void
    writeChar(int val)
     
    void
     
    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, reset, skip, skipAllBytes, skipAllBytes

    Methods inherited from interface nom.tam.util.ArrayDataOutput

    flush

    Methods inherited from interface java.io.DataInput

    skipBytes

    Methods inherited from interface nom.tam.util.FitsIO

    close
  • Constructor Details

    • AbstractArrayDataIO

      public AbstractArrayDataIO()
  • Method Details

    • get

      protected abstract byte get() throws IOException
      Reads one byte from the current position.
      Returns:
      next byte
      Throws:
      IOException
    • get

      protected abstract void get(byte[] buf, int offset, int length) throws IOException
      Reads bytes into a buffer from the current position.
      Parameters:
      buf - destination buffer
      offset - offset of first byte in buf to be written
      length - maximum number of bytes to be written to buf
      Throws:
      IOException
    • put

      protected abstract void put(byte b) throws IOException
      Writes a single byte at the current position.
      Parameters:
      b - output byte
      Throws:
      IOException
    • put

      protected abstract void put(byte[] buf, int offset, int length) throws IOException
      Writes bytes from a buffer to the current position.
      Parameters:
      buf - source buffer
      offset - offset of first byte in buf to be read
      length - number of bytes from buf 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 return Long.MAX_VALUE;
      Returns:
      number of bytes left in file
    • readBoolean

      public boolean readBoolean() throws IOException
      Specified by:
      readBoolean in interface DataInput
      Throws:
      IOException
    • readByte

      public byte readByte() throws IOException
      Specified by:
      readByte in interface DataInput
      Throws:
      IOException
    • readShort

      public short readShort() throws IOException
      Specified by:
      readShort in interface DataInput
      Throws:
      IOException
    • readChar

      public char readChar() throws IOException
      Specified by:
      readChar in interface DataInput
      Throws:
      IOException
    • readInt

      public int readInt() throws IOException
      Specified by:
      readInt in interface DataInput
      Throws:
      IOException
    • readLong

      public long readLong() throws IOException
      Specified by:
      readLong in interface DataInput
      Throws:
      IOException
    • readFloat

      public float readFloat() throws IOException
      Specified by:
      readFloat in interface DataInput
      Throws:
      IOException
    • readDouble

      public double readDouble() throws IOException
      Specified by:
      readDouble in interface DataInput
      Throws:
      IOException
    • readUnsignedByte

      public int readUnsignedByte() throws IOException
      Specified by:
      readUnsignedByte in interface DataInput
      Throws:
      IOException
    • readUnsignedShort

      public int readUnsignedShort() throws IOException
      Specified by:
      readUnsignedShort in interface DataInput
      Throws:
      IOException
    • readUTF

      public String readUTF() throws IOException
      Specified by:
      readUTF in interface DataInput
      Throws:
      IOException
    • readLine

      @Deprecated public String readLine() throws IOException
      Not implemented - this method is deprecated in any case.
      Specified by:
      readLine in interface DataInput
      Throws:
      UnsupportedOperationException - always
      IOException
    • readFully

      public void readFully(byte[] buf, int start, int len) throws IOException
      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 interface nom.tam.util.ArrayDataInput
      Specified by:
      readFully in interface DataInput
      Parameters:
      buf - the byte buffer into which to read
      start - the index in buf at which to start putting bytes
      len - the number of bytes which must be read
      Throws:
      EOFException - if there are fewer than len bytes left
      IOException
    • read

      public int read(byte[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(boolean[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(short[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(char[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(int[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(long[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(float[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(double[] buf, int start, int length) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • readFully

      public void readFully(byte[] buf) throws IOException
      Specified by:
      readFully in interface DataInput
      Throws:
      IOException
    • read

      public int read(byte[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(boolean[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(short[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(char[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(int[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(long[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(float[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • read

      public int read(double[] buf) throws IOException
      Specified by:
      read in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • readArray

      public int readArray(Object o) throws IOException
      Specified by:
      readArray in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • readLArray

      public long readLArray(Object o) throws IOException
      Specified by:
      readLArray in interface nom.tam.util.ArrayDataInput
      Throws:
      IOException
    • write

      public void write(int val) throws IOException
      Specified by:
      write in interface DataOutput
      Throws:
      IOException
    • writeBoolean

      public void writeBoolean(boolean val) throws IOException
      Specified by:
      writeBoolean in interface DataOutput
      Throws:
      IOException
    • writeByte

      public void writeByte(int val) throws IOException
      Specified by:
      writeByte in interface DataOutput
      Throws:
      IOException
    • writeShort

      public void writeShort(int val) throws IOException
      Specified by:
      writeShort in interface DataOutput
      Throws:
      IOException
    • writeChar

      public void writeChar(int val) throws IOException
      Specified by:
      writeChar in interface DataOutput
      Throws:
      IOException
    • writeInt

      public void writeInt(int val) throws IOException
      Specified by:
      writeInt in interface DataOutput
      Throws:
      IOException
    • writeLong

      public void writeLong(long val) throws IOException
      Specified by:
      writeLong in interface DataOutput
      Throws:
      IOException
    • writeFloat

      public void writeFloat(float val) throws IOException
      Specified by:
      writeFloat in interface DataOutput
      Throws:
      IOException
    • writeDouble

      public void writeDouble(double val) throws IOException
      Specified by:
      writeDouble in interface DataOutput
      Throws:
      IOException
    • write

      public void write(byte[] buf, int start, int length) throws IOException
      Specified by:
      write in interface DataOutput
      Throws:
      IOException
    • write

      public void write(boolean[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(short[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(char[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(int[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(long[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(float[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(double[] buf, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(String[] strings, int start, int length) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • writeBytes

      public void writeBytes(String s) throws IOException
      Specified by:
      writeBytes in interface DataOutput
      Throws:
      IOException
    • writeChars

      public void writeChars(String s) throws IOException
      Specified by:
      writeChars in interface DataOutput
      Throws:
      IOException
    • writeUTF

      public void writeUTF(String str) throws IOException
      Specified by:
      writeUTF in interface DataOutput
      Throws:
      IOException
    • write

      public void write(byte[] buf) throws IOException
      Specified by:
      write in interface DataOutput
      Throws:
      IOException
    • write

      public void write(boolean[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(short[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(char[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(int[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(long[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(float[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(double[] buf) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • write

      public void write(String[] strings) throws IOException
      Specified by:
      write in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException
    • writeArray

      public void writeArray(Object o) throws IOException
      Specified by:
      writeArray in interface nom.tam.util.ArrayDataOutput
      Throws:
      IOException