net.sf.asyncobjects.io
Class BinaryData.ByteIterator

java.lang.Object
  extended by net.sf.asyncobjects.io.BinaryData.ByteIterator
Enclosing class:
BinaryData

public abstract static class BinaryData.ByteIterator
extends Object

A base class for byte iterators.


Field Summary
protected  int current
          current position
protected  int limit
          current position
 
Method Summary
protected  void advanceNext()
          Subclasses call this method to ensure that iterator could move further
protected  void checkNext()
          Subclass call this method to ensure that it is possible to advance further.
 boolean hasNext()
           
 int next()
           
abstract  byte[] nextArray(byte[] target, int targetStart, int size)
          Copy data to array
abstract  byte nextByte()
           
 int nextInt()
          Get next big endian int.
 long nextLong()
          Get next big endian long.
 short nextShort()
          Get big endian short at the specified posion.
abstract  BinaryData nextSubrange(int length)
          Next subrange
abstract  byte peekByte()
           
 int position()
           
 void skip(int n)
          Skip n bytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected int current
current position


limit

protected int limit
current position

Method Detail

position

public final int position()
Returns:
current position which binary data

hasNext

public final boolean hasNext()
Returns:
true if there is a next byte

next

public final int next()
Returns:
next unisgned byte value (nextByte() & 0xFF)
See Also:
nextByte()

advanceNext

protected final void advanceNext()
Subclasses call this method to ensure that iterator could move further


checkNext

protected void checkNext()
Subclass call this method to ensure that it is possible to advance further.


skip

public final void skip(int n)
Skip n bytes

Parameters:
n - amount of bytes to skip

nextByte

public abstract byte nextByte()
Returns:
next byte

nextInt

public final int nextInt()
Get next big endian int.

Returns:
next four bytes as integer

nextLong

public final long nextLong()
Get next big endian long.

Returns:
next eight bytes as long

nextShort

public final short nextShort()
Get big endian short at the specified posion.

Returns:
next two bytes as short

nextSubrange

public abstract BinaryData nextSubrange(int length)
Next subrange

Parameters:
length - a subrange length
Returns:
a new subrange

nextArray

public abstract byte[] nextArray(byte[] target,
                                 int targetStart,
                                 int size)
Copy data to array

Parameters:
target - a target array
targetStart - start in array to copy
size - a size to copy
Returns:
target array

peekByte

public abstract byte peekByte()
Returns:
peek next byte


Copyright 2002-2007 Constantine Plotnikov. All Rights Reserved.