Package nom.tam.util

Class BufferEncoder


@Deprecated public abstract class BufferEncoder extends FitsEncoder
Deprecated.
Use FitsEncoder instead which provides a similar function but in a more consistent way and with a less misleading name. This is a rusty rail implementation for of an older abandoned class only, unsafe for general use. For writing non-FITS encoding you may also use OutputEncoder as a base for implementing efficient custom encoding of binary outputs in general.
See Also:
  • Constructor Details

    • BufferEncoder

      public BufferEncoder(BufferPointer p)
      Deprecated.
      Parameters:
      p - Unused, but the position and length fields are set/reset as to pretend that the buffer is perpetually half filled with data, and with position at 0. However, at no point will there be any data actually in the buffer of this object. You should by all means avoid directly writing data from this buffer to the output stream, other than the hopefully untriggered write of an existing needBuffer(int) implementation (and it's safest if you don't override or ever call needBuffer(int) from your code!).
  • Method Details

    • needBuffer

      @Deprecated protected void needBuffer(int need) throws IOException
      Deprecated.
      No longer used internally, kept only for back-compatibility since it used to be a needed abstract method. It's safest if you never override or call this method from your code!
      Parameters:
      need - the number of consecutive bytes we need available in the conversion buffer
      Throws:
      IOException - if the buffer could not be flushed to the output to free up space in the buffer.
    • write

      protected void write(byte[] b, int from, int len) throws IOException
      Deprecated.
      Description copied from class: OutputEncoder
      Writes up to the specified number of bytes from a buffer directly to the output. See the general contract of DataOutputStream.write(byte[], int, int). The number of unencoded bytes written by this method are not reflected in the value returned by OutputEncoder.getCount().
      Overrides:
      write in class OutputEncoder
      Parameters:
      b - the buffer
      from - the starting buffer index
      len - the number of bytes to write.
      Throws:
      IOException - if there was an underlying IO error
      See Also:
    • writeUncheckedByte

      protected void writeUncheckedByte(byte b) throws IllegalStateException
      Deprecated.
      Writes a single byte to the output, but not before flushing the contents of the conversion buffer. The supplied BufferPointer is not used at all, and is immediately invalidated (which is consistent with having flushed all pending output). It's not all that efficient, but then again one should be using the new FitsEncoder instead. This is really just a rusty rail solution. Also, since this methods does not throw an exception, and needBuffer(int) (which did throw an exception) is no longer in use, the duct-tape solution is to convert any IOException encountered here into a runtime exception...
      Parameters:
      b - the byte to write
      Throws:
      IllegalStateException - if there was an IO error flushing the conversion buffer or writing the new byte after it.