org.sourcejammer.server.make
Class ByteArrayChunkCompare

java.lang.Object
  |
  +--org.sourcejammer.server.make.ByteArrayChunkCompare
Direct Known Subclasses:
BufferedChunkCompare

public class ByteArrayChunkCompare
extends java.lang.Object

This class allows simple iteration through a byte array for the purpose of comparing a chunk of bytes of a specified size.


Field Summary
private  byte[] mbySource
           
private  int miIndex
           
private  int miSize
           
 
Constructor Summary
protected ByteArrayChunkCompare()
           
  ByteArrayChunkCompare(byte[] source)
          Create a new ByteArrayChunkCompare object for a byte array, beginning with the first byte in the array.
  ByteArrayChunkCompare(byte[] source, int iBeginIndex)
          Create a new ByteArrayChunkCompare object for a byte array, beginning with a specified index.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests if the current chunk of bytes in this ByteArrayChunkCompare object is equal to the current chunk of bytes in o.
 int getIndex()
           
 int getSizeOfSource()
           
protected  byte[] getSource()
           
 boolean nextByByte()
          Advances the index of the byte array source by 1 byte.
 boolean nextByChunk()
          Advances the index of the byte array source to the next byte chunk.
 void setIndex(int index)
          Explicitly sets the index value.
 int size()
          Returns the comparison size, or the number of bytes that will be compared when the equals() method is called.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mbySource

private byte[] mbySource

miIndex

private int miIndex

miSize

private int miSize
Constructor Detail

ByteArrayChunkCompare

protected ByteArrayChunkCompare()

ByteArrayChunkCompare

public ByteArrayChunkCompare(byte[] source)
                      throws EndOfSourceException
Create a new ByteArrayChunkCompare object for a byte array, beginning with the first byte in the array.

Parameters:
source - -- a byte array to be iterated through and compared.
Throws:
EndOfSourceException - -- if the source is 0 length array.

ByteArrayChunkCompare

public ByteArrayChunkCompare(byte[] source,
                             int iBeginIndex)
                      throws EndOfSourceException
Create a new ByteArrayChunkCompare object for a byte array, beginning with a specified index.

Parameters:
source - -- a byte array to be iterated through and compared.
iBeginIndex - -- the index at which iteration through source should begin. Note: index is 0-based. 0 is first, 1 is second, . . .
Throws:
EndOfSourceException - -- iBeginIndex is not in source.
Method Detail

nextByChunk

public boolean nextByChunk()
Advances the index of the byte array source to the next byte chunk. In other words, advances the index by the value of the ComparisonChunkSize value in AppConfig.

Returns:
true if the index advanced successfully. false if the end of the source byte array has been reached.

nextByByte

public boolean nextByByte()
Advances the index of the byte array source by 1 byte.

Returns:
true if the index advanced successfully. false if the end of the source byte array has been reached.

setIndex

public void setIndex(int index)
              throws EndOfSourceException
Explicitly sets the index value.

Throws:
EndOfSourceException - -- Requested index is not in source byte array.

getIndex

public int getIndex()

size

public int size()
Returns the comparison size, or the number of bytes that will be compared when the equals() method is called.


getSizeOfSource

public int getSizeOfSource()

equals

public boolean equals(java.lang.Object o)
Tests if the current chunk of bytes in this ByteArrayChunkCompare object is equal to the current chunk of bytes in o.

Overrides:
equals in class java.lang.Object

getSource

protected byte[] getSource()


Copyright 2003 Soucejammer project.