de.esprit.appsuite.nio.binary

## Class ByteBufferWrapper

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.log.SimpleLogSupportAdapter
    - - de.esprit.appsuite.nio.binary.ByteBufferWrapper

- All Implemented Interfaces:
    BinaryDataStructure, SimpleLogSupport, Dumpable, Resettable
  Direct Known Subclasses:
    CharBufferWrapper, NumberBufferWrapper

      public class ByteBufferWrapper
      extends SimpleLogSupportAdapter
      implements BinaryDataStructure

  This is a named buffer for reading a primitive binary structure.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ByteBufferWrapper(java.lang.String name, BinaryChannel binaryChannel, JavaDataType javaDataType)`
    `ByteBufferWrapper(java.lang.String name, BinaryChannel binaryChannel, JavaDataType javaDataType, int numberOfValues)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected BinaryChannel` | `getBinaryChannel()`
    `java.nio.ByteBuffer` | `getByteBuffer()`
    `protected java.nio.ByteOrder` | `getByteOrder()`
    `protected int` | `getCapacity()`
    `byte[]` | `getData()` Reads the data from the underlying file.
    `long` | `getEndPosition()` Tells the end-position of this buffer in the underlying random access file.
    `protected JavaDataType` | `getJavaDataType()`
    `java.lang.String` | `getName()`
    `protected int` | `getNumberOfValues()`
    `BinaryDataStructure` | `getPredecessor()`
    `long` | `getReadOffset()`
    `int` | `getSize()` Returns the capacity of the underlying buffer in bytes.
    `long` | `getStartPosition()` Tells the start-position of this buffer in the underlying random access file.
    `protected int` | `read()`
    `void` | `reset()` Clears the internal cache and forces the data to be re-read again on the next access.
    `void` | `setPredecessor(BinaryDataStructure predecessor)` Sets a reference to the previous structure.
    `void` | `setReadOffset(long readOffset)`

    - ### Methods inherited from class de.esprit.common.log.SimpleLogSupportAdapter

      `getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ByteBufferWrapper

          public ByteBufferWrapper(java.lang.String name,
                           BinaryChannel binaryChannel,
                           JavaDataType javaDataType)

    - #### ByteBufferWrapper

          public ByteBufferWrapper(java.lang.String name,
                           BinaryChannel binaryChannel,
                           JavaDataType javaDataType,
                           int numberOfValues)

  - ### Method Detail

    - #### getJavaDataType

          protected final JavaDataType getJavaDataType()

    - #### getNumberOfValues

          protected final int getNumberOfValues()

    - #### getCapacity

          protected final int getCapacity()

    - #### getBinaryChannel

          protected final BinaryChannel getBinaryChannel()

    - #### getName

          public final java.lang.String getName()

    - #### getByteBuffer

          public final java.nio.ByteBuffer getByteBuffer()
                                                  throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### setPredecessor

          public final void setPredecessor(BinaryDataStructure predecessor)

      Description copied from interface: `BinaryDataStructure`
      Sets a reference to the previous structure. Note that determining the end-position may cause a chained read of the previous stucture's data.
      Specified by:
        `setPredecessor` in interface `BinaryDataStructure`
      See Also:
        `BinaryDataStructure.getEndPosition()`

    - #### getPredecessor

          public final BinaryDataStructure getPredecessor()

    - #### getByteOrder

          protected java.nio.ByteOrder getByteOrder()
                                             throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### read

          protected final int read()
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getData

          public byte[] getData()
                         throws java.io.IOException

      Reads the data from the underlying file. Note that the data is cached an not read again unless `reset()` is called.
      Throws:
        `java.io.IOException`

    - #### getSize

          public int getSize()
                      throws java.io.IOException

      Returns the capacity of the underlying buffer in bytes.
      Throws:
        `java.io.IOException`

    - #### getStartPosition

          public final long getStartPosition()
                                      throws java.io.IOException

      Tells the start-position of this buffer in the underlying random access file. If this structure has a predecessor, then this one will be asked for it's end-position in order to find out the start-position of this buffer.
      Throws:
        `java.io.IOException`

    - #### setReadOffset

          public void setReadOffset(long readOffset)

    - #### getEndPosition

          public final long getEndPosition()
                                    throws java.io.IOException

      Tells the end-position of this buffer in the underlying random access file.
      Specified by:
        `getEndPosition` in interface `BinaryDataStructure`
      Throws:
        `java.io.IOException`
      See Also:
        `getStartPosition()`

    - #### getReadOffset

          public long getReadOffset()

    - #### reset

          public void reset()

      Clears the internal cache and forces the data to be re-read again on the next access.
      Specified by:
        `reset` in interface `Resettable`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.