net.sf.dexterim.oscar
Class BufferArray

java.lang.Object
  extended bynet.sf.dexterim.oscar.OscarByteBuffer
      extended bynet.sf.dexterim.oscar.BufferArray

public class BufferArray
extends OscarByteBuffer

Author:
christoph

Method Summary
 byte[] array()
          Returns the underlying data structure as byte array.
static OscarByteBuffer createBufferArray(java.util.List buffers)
           
static OscarByteBuffer createBufferArray(OscarByteBuffer first, OscarByteBuffer second)
           
 int fill()
          Returns last position with data available
 int getByte()
          Returns byte at current position.
 DWord getDWord()
          Returns the data chunk at current position as DWord.
 Word getWord()
          Returns the data chunk at current position as Word.
 int position()
          Returns the current position.
 int position(int position)
          Sets the position to newPosition and returns the old position.
 int size()
          Returns the current size of the buffer.
 byte[] slice()
          Returns the underlying data structure as byte array.
 int strip()
          Strips the OscarByteBuffer by setting the fill to the current position.
 OscarByteBuffer write(byte source)
          Writes a byte value at current position.
 OscarByteBuffer write(ByteBased source)
          Writes a ByteBased value at current position.
 OscarByteBuffer write(OscarByteBuffer source)
          Writes a OscarByteBuffer value at current position.
 
Methods inherited from class net.sf.dexterim.oscar.OscarByteBuffer
allocate, dynamic, wrap, wrapDynamic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

position

public int position(int position)
Description copied from class: OscarByteBuffer
Sets the position to newPosition and returns the old position. May throw an ArrayIndexOutOfBounds exception if position was set beyond the end of the underlying data structure.

Specified by:
position in class OscarByteBuffer
Parameters:
position - new Position
Returns:
old Position

position

public int position()
Description copied from class: OscarByteBuffer
Returns the current position.

Specified by:
position in class OscarByteBuffer
Returns:
current Position in Buffer

size

public int size()
Description copied from class: OscarByteBuffer
Returns the current size of the buffer. For dynamic Buffers this size may change after calling writer or position.

Specified by:
size in class OscarByteBuffer
Returns:
current size

fill

public int fill()
Description copied from class: OscarByteBuffer
Returns last position with data available

Specified by:
fill in class OscarByteBuffer
Returns:
fill

strip

public int strip()
Description copied from class: OscarByteBuffer
Strips the OscarByteBuffer by setting the fill to the current position.

Specified by:
strip in class OscarByteBuffer
Returns:
current Position

getWord

public Word getWord()
Description copied from class: OscarByteBuffer
Returns the data chunk at current position as Word. Throws an ArrayIndexOutOfBounds Exception if not enough bytes are present in Buffer to construct a Word value.

Specified by:
getWord in class OscarByteBuffer
Returns:
Word value at current position

getDWord

public DWord getDWord()
Description copied from class: OscarByteBuffer
Returns the data chunk at current position as DWord. Throws an ArrayIndexOutOfBounds Exception if not enough bytes are present in Buffer to construct a DWord value.

Specified by:
getDWord in class OscarByteBuffer
Returns:
DWord value at current position

getByte

public int getByte()
Description copied from class: OscarByteBuffer
Returns byte at current position. Throws an ArrayIndexOutOfBounds Exception if position() >= size()

Specified by:
getByte in class OscarByteBuffer
Returns:
byte value at current position

write

public OscarByteBuffer write(ByteBased source)
Description copied from class: OscarByteBuffer
Writes a ByteBased value at current position. This may throw an ArrayIndexOutOfBounds Exception for allocated buffers if size() <= position() + new DWord().getLength(). Method returns this to be used in command chaining.

Specified by:
write in class OscarByteBuffer
Parameters:
source - value to write to buffer
Returns:
this

write

public OscarByteBuffer write(byte source)
Description copied from class: OscarByteBuffer
Writes a byte value at current position. This may throw an ArrayIndexOutOfBounds Exception for allocated buffers if size() <= position() + 1. Method returns this to be used in command chaining.

Specified by:
write in class OscarByteBuffer
Parameters:
source - value to write to buffer
Returns:
this

write

public OscarByteBuffer write(OscarByteBuffer source)
Description copied from class: OscarByteBuffer
Writes a OscarByteBuffer value at current position. This may throw an ArrayIndexOutOfBounds Exception for allocated buffers if size() <= position() + source.slice().length(). Method returns this to be used in command chaining.

Specified by:
write in class OscarByteBuffer
Parameters:
source - value to write to buffer
Returns:
this

array

public byte[] array()
Description copied from class: OscarByteBuffer
Returns the underlying data structure as byte array. This method does not clone the byte array nor tailor the length of the underlying byte array. Changes commited to this array will affect data in OscarByteBuffer. This method is considered to be more performant than slice().

Specified by:
array in class OscarByteBuffer
Returns:
byte array

slice

public byte[] slice()
Description copied from class: OscarByteBuffer
Returns the underlying data structure as byte array. This method returns a new instance of byte[] by calling Systen.arrayCopy or some other mechanism and tailor it's length to position()

Specified by:
slice in class OscarByteBuffer
Returns:
byte array

createBufferArray

public static OscarByteBuffer createBufferArray(OscarByteBuffer first,
                                                OscarByteBuffer second)

createBufferArray

public static OscarByteBuffer createBufferArray(java.util.List buffers)


Copyright © 2003-2004 Dexter IM Team. All Rights Reserved.