|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--ByteIterator
| Constructor Summary | |
ByteIterator(byte[] d)
Creates a new copy of the buffer. |
|
ByteIterator(byte[] d,
boolean newBuf)
May create a copy of the given buffer or create a new one. |
|
ByteIterator(byte[] d,
int start,
int length)
Create a new buffer from a portion of a data buffer. |
|
| Method Summary | |
void |
compile(java.lang.String pattern)
Compiles the text pattern for searching. |
static int |
concoctInt(byte[] b)
Converts 4 bytes of a byte array into an int. |
static int |
concoctInt(byte[] b,
int start)
Converts 4 bytes of a byte array into an int from the starting position. |
static long |
concoctLong(byte[] b)
Converts the first 8 bytes of a byte array into a long. |
static long |
concoctLong(byte[] b,
int start)
Converts 8 bytes of a byte array into a long from the starting position. |
static short |
concoctShort(byte[] b)
Converts 2 bytes of a byte array into a short |
static short |
concoctShort(byte[] b,
int start)
Converts 2 bytes of a byte array into a short from the starting position. |
int |
current()
Returns the current position in the buffer. |
static byte[] |
decoct(int i)
Converts an int into 4 bytes. |
static byte[] |
decoct(long i)
Converts a long into 8 bytes. |
static byte[] |
decoct(short i)
Converts a short into 2 bytes. |
java.lang.String |
dump(int start,
int length)
Dump part of the byte stream. |
byte[] |
extend(int diff)
Extends data buffer (may be set longer or shorter). |
byte |
first()
Returns the first byte of buffer in the data. |
byte[] |
getBuffer()
Return the current data buffer. |
byte |
last()
Returns the last byte of buffer in the data. |
long |
length()
Returns the current length of the data buffer. |
void |
move(int count)
Move current position by an arbitrary number of bytes. |
void |
moveByte()
Advance in the array by one byte |
void |
moveInt()
Advance in the array by four bytes (size of int). |
void |
moveLong()
Advance in the array by 8 bytes (size of long). |
void |
moveShort()
Advance in the array by two bytes (size of short). |
byte |
nextByte()
Return the next byte. |
int |
nextInt()
Returns the next int (4 bytes). |
long |
nextLong()
Returns the next long (8 bytes). |
short |
nextShort()
Returns the next short (2 bytes). |
int |
nextUnsignedByte()
Returns the next unsigned byte (1 byte) as an int. |
int |
nextUnsignedShort()
Returns the next unsigned short (2 bytes) as an int. |
int |
partialMatch()
Returns the position at the end of the text buffer where a partial match was found. |
int |
read(byte[] b)
Read a buffer full of bytes. |
int |
read(byte[] b,
int offset,
int count)
Read bytes into a buffer. |
byte |
readByte()
Returns the next byte. |
int |
readInt()
Returns the next int (4 bytes). |
java.lang.String |
readLine()
Read a line from the byte stream. |
long |
readLong()
Returns the next long (8 bytes). |
short |
readShort()
Returns the next short (2 bytes). |
int |
readUnsignedByte()
Returns the next unsigned byte (1 byte). |
int |
readUnsignedShort()
Returns the next unsigned short (2 bytes). |
int |
search(int start,
int length)
Search for the compiled pattern in the given text. |
void |
seek(long posn)
Absolute position to move to in the data buffer. |
void |
setIndex(int posn)
Sets the current position. |
void |
setInt(int i)
Sets an int |
void |
setLong(long i)
Sets a long |
void |
setShort(short i)
Sets a short |
void |
skipBytes(int count)
Skips over bytes. |
int |
write(byte[] b)
Write a byte array to the buffer at the current position. |
void |
writeInt(int i)
Write an int to the buffer at the current position. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public ByteIterator(byte[] d)
data - Data byte array to use.getBuffer()
public ByteIterator(byte[] d,
boolean newBuf)
d - Data byte array to use.newBuf - true if a new buffer is required, false if we use the original.getBuffer()
public ByteIterator(byte[] d,
int start,
int length)
data - Data byte array to use.start - Index of the first bytelength - length to usegetBuffer()| Method Detail |
public byte[] getBuffer()
public byte first()
bytepublic byte last()
bytepublic void setIndex(int posn)
posn - Set the current index into the array.public void move(int count)
count - Number of byte to advancepublic int current()
public long nextLong()
long (8 bytes).
Does not advance the buffer position.long value.public void moveLong()
long).public int nextInt()
int (4 bytes).
Does not advance the buffer position.int value.public void moveInt()
int).public short nextShort()
short (2 bytes).
Does not advance the buffer position.short value.public int nextUnsignedShort()
int.
Does not advance the buffer position.short value as an int.public int nextUnsignedByte()
int.
Does not advance the buffer position.byte value an int.public void moveShort()
short).public byte nextByte()
byte.
Does not advance the buffer position.byte valuepublic void moveByte()
public void setShort(short i)
short at the current location
Does not advance the buffer position.
- Parameters:
i -
public void setInt(int i)
int at the current location
Does not advance the buffer position.
- Parameters:
i -
public void setLong(long i)
long at the current location.
Does not advance the buffer position.
- Parameters:
i -
public static long concoctLong(byte[] b)
long.b - buffer.
public static long concoctLong(byte[] b,
int start)
long from the starting position.b - buffer.start - postion to extract datapublic static int concoctInt(byte[] b)
int.b - buffer.
public static int concoctInt(byte[] b,
int start)
int from the starting position.b - buffer.start - postion to extract datapublic static short concoctShort(byte[] b)
shortb - buffer.
public static short concoctShort(byte[] b,
int start)
short from the starting position.b - buffer.start - postion to extract datapublic static byte[] decoct(short i)
short into 2 bytes.i. - public static byte[] decoct(int i)
int into 4 bytes.i. - public static byte[] decoct(long i)
long into 8 bytes.i. - public int readInt()
int (4 bytes).
Advance the buffer position.int value.public short readShort()
short (2 bytes).
Advances the buffer position.short value.public long readLong()
long (8 bytes).
Advances the buffer position.long value.public int readUnsignedShort()
short (2 bytes).
Advances the buffer position.int value.public int readUnsignedByte()
byte (1 byte).
Advances the buffer position.int value.public byte readByte()
byte.
Advances the buffer position.byte value.public void skipBytes(int count)
count - bytes to skip.public int read(byte[] b)
b - buffer to fill.
public int read(byte[] b,
int offset,
int count)
b - buffer to fill.offset - position in the buffer to start filling.count - number of bytes to read.public void seek(long posn)
posn - positionpublic void writeInt(int i)
int to the buffer at the current position.i - value to write.public int write(byte[] b)
byte array to the buffer at the current position.b - buffer to write.public long length()
extend(int)public byte[] extend(int diff)
diff - difference in size (negative or positive)getBuffer()public java.lang.String readLine()
null if at the end of file.
public java.lang.String dump(int start,
int length)
6D 69 73 63 3B 0D 0A 0D - 0A 69 6D 70 6F 72 74 20 misc;....importDoes not advance the buffer position.
start - start positionlength - length to dumpString containing the String representation of the dump.public void compile(java.lang.String pattern)
pattern - What we're looking for.
public int search(int start,
int length)
text - Buffer containing the textstart - Start position for searchlength - Length of text in the buffer to be searched.partialMatch()public int partialMatch()
In many case where a full text search of a large amount of data precludes access to the entire file or stream the search algorithm will note where the final partial match occurs. After an entire buffer has been searched for full matches calling this method will reveal if a potential match appeared at the end. This information can be used to patch together the partial match with the next buffer of data to determine if a real match occurred.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||