67 |
} |
} |
68 |
|
|
69 |
/** |
/** |
|
* Create a stream, reading from the given buffer region. |
|
|
* |
|
|
* @param a_buffer a buffer to read from. |
|
|
* @param offset the offset of the region. |
|
|
* @param length thr length of the region. |
|
|
*/ |
|
|
public aligningInputStream(byte[] a_buffer, int offset, int length) |
|
|
{ |
|
|
super(a_buffer, offset, length); |
|
|
} |
|
|
|
|
|
/** |
|
70 |
* Set the alignment offset, if the index of the first byte in the |
* Set the alignment offset, if the index of the first byte in the |
71 |
* stream is different from 0. |
* stream is different from 0. |
72 |
*/ |
*/ |
107 |
{ |
{ |
108 |
return buf; |
return buf; |
109 |
} |
} |
110 |
|
|
111 |
|
/** |
112 |
|
* Get the current position in the buffer. |
113 |
|
* |
114 |
|
* @return The position in the buffer, taking offset into consideration. |
115 |
|
*/ |
116 |
|
public int getPosition() |
117 |
|
{ |
118 |
|
return pos + offset; |
119 |
|
} |
120 |
|
|
121 |
|
/** |
122 |
|
* Jump to the given position, taking offset into consideration. |
123 |
|
*/ |
124 |
|
public void seek(int position) |
125 |
|
{ |
126 |
|
if (position < offset || position > (count+offset)) |
127 |
|
throw new ArrayIndexOutOfBoundsException(position |
128 |
|
+ " is out of valid ["+offset+".." + (count+offset) + "[ range"); |
129 |
|
pos = position - offset; |
130 |
|
} |
131 |
} |
} |