OutByteBuffer (JiBX Java data binding to XML - Version 1.2.3)
Keywords: org.jibx.runtime.impl.OutByteBuffer class

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jibx.runtime.impl
Class OutByteBuffer

    java.lang.Object
      org.jibx.runtime.impl.OutByteBuffer

All Implemented Interfaces:
  IByteBuffer, IOutByteBuffer

    public class OutByteBuffer

extends java.lang.Object
implements IOutByteBuffer

Byte buffer wrapping an output stream. Clients need to obey the interface access rules.

Author:
  Dennis M. Sosnoski

Field Summary
`static int` | `DEFAULT_BUFFER_SIZE` Default output buffer size.

Constructor Summary
`OutByteBuffer()` Constructor using default buffer size.
`OutByteBuffer(int size)` Constructor with size specified.

Method Summary
`void` | `finish()` Complete usage of the current stream.
`void` | `flush()` Empty the buffer.
`void` | `free(int reserve, int size)` Free at least some number of bytes of space in the byte array.
`byte[]` | `getBuffer()` Get the byte array buffer.
`int` | `getOffset()` Get the index of the next byte to be read.
`void` | `reset()` Reset to initial state for reuse.
`void` | `setOffset(int offset)` Set the current offset.
`void` | `setOutput(java.io.OutputStream os)` Set output stream.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_BUFFER_SIZE

    public static final int DEFAULT_BUFFER_SIZE

  Default output buffer size.

  See Also:
    Constant Field Values

Constructor Detail

### OutByteBuffer

    public OutByteBuffer(int size)

  Constructor with size specified.

  Parameters:
    `size` - initial buffer size in bytes

### OutByteBuffer

    public OutByteBuffer()

  Constructor using default buffer size.

Method Detail

### reset

    public void reset()

  Reset to initial state for reuse.

### setOutput

    public void setOutput(java.io.OutputStream os)

  Set output stream. If an output stream is currently open when this is called the existing stream is flushed and closed, with any errors ignored.

  Parameters:
    `os` - stream

### getBuffer

    public byte[] getBuffer()

  Get the byte array buffer.

  Specified by:
    `getBuffer` in interface `IByteBuffer`
  Returns:
    array

### getOffset

    public int getOffset()

  Get the index of the next byte to be read. After reading data, the `setOffset(int)` method must be used to update the current offset before any other operations are performed on the buffer.

  Specified by:
    `getOffset` in interface `IByteBuffer`
  Returns:
    offset

### setOffset

    public void setOffset(int offset)

  Set the current offset. This must be used to update the stored buffer state after reading any data.

  Specified by:
    `setOffset` in interface `IByteBuffer`
  Parameters:
    `offset` -

### free

    public void free(int reserve,
                     int size)
              throws java.io.IOException

  Free at least some number of bytes of space in the byte array. If no reserve is specified, this call may write all data up to the current offset to the output stream, and if necessary will replace the byte array with a larger array. If a reserve is specified, only data up to the reserve will be written, and any remaining data will be moved down to the start of the (possibly new) byte array on return. Both `getBuffer()` and `IByteBuffer.getOffset()` must always be called again before any further use of the buffer.

  Specified by:
    `free` in interface `IOutByteBuffer`
  Parameters:
    `reserve` - offset of data to be preserved in buffer (nothing preserved if greater than or equal to current offset)
    `size` - desired number of bytes
  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

  Empty the buffer. Writes all data from the buffer to the output stream, resetting the offset to the start of the buffer.

  Specified by:
    `flush` in interface `IOutByteBuffer`
  Throws:
    `java.io.IOException`

### finish

    public void finish()
                throws java.io.IOException

  Complete usage of the current stream. This method should be called whenever the application is done writing to the buffered stream. Once this method is called, a call to `setOutput(OutputStream)` is required before the buffer can again be used.

  Specified by:
    `finish` in interface `IByteBuffer`
  Throws:
    `java.io.IOException`

Overview | Package | Class | Deprecated
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Project Web Site |