Lines Matching refs:buffer

20  * Byte buffer container including length of valid data.
27 private byte[] buffer;
35 * @param initialCapacity the initial capacity for this buffer
39 this.buffer = new byte[initialCapacity];
45 * @param buffer a byte array that will be wrapped with <code>ByteBuffer</code>.
47 public ByteBuffer(byte[] buffer)
49 this.buffer = buffer;
50 this.length = buffer.length;
55 * @param buffer a byte array that will be wrapped with <code>ByteBuffer</code>.
58 public ByteBuffer(byte[] buffer, int length)
60 if (length > buffer.length)
62 throw new ArrayIndexOutOfBoundsException("Valid length exceeds the buffer length.");
64 this.buffer = buffer;
70 * Loads the stream into a buffer.
77 // load stream into buffer
80 this.buffer = new byte[chunk];
83 while ((read = in.read(this.buffer, this.length, chunk)) > 0)
99 * @param buffer a byte array that will be wrapped with <code>ByteBuffer</code>.
100 * @param offset the offset of the provided buffer.
103 public ByteBuffer(byte[] buffer, int offset, int length)
105 if (length > buffer.length - offset)
107 throw new ArrayIndexOutOfBoundsException("Valid length exceeds the buffer length.");
109 this.buffer = new byte[length];
110 System.arraycopy(buffer, offset, this.buffer, 0, length);
120 return new ByteArrayInputStream(buffer, 0, length);
125 * @return Returns the length, that means the number of valid bytes, of the buffer;
136 // * @return Returns the inner byte buffer.
140 // return buffer;
146 * @return Returns a byte from the buffer
152 return buffer[index];
156 throw new IndexOutOfBoundsException("The index exceeds the valid buffer area");
163 * @return Returns a byte from the buffer
169 return buffer[index] & 0xFF;
173 throw new IndexOutOfBoundsException("The index exceeds the valid buffer area");
179 * Appends a byte to the buffer.
185 buffer[length++] = b;
190 * Appends a byte array or part of to the buffer.
199 System.arraycopy(bytes, offset, buffer, length, len);
205 * Append a byte array to the buffer
215 * Append another buffer to this buffer.
220 append(anotherBuffer.buffer, 0, anotherBuffer.length);
225 * Detects the encoding of the byte buffer, stores and returns it.
241 else if (buffer[0] == 0)
248 if (length < 4 || buffer[1] != 0)
252 else if ((buffer[2] & 0xFF) == 0xFE && (buffer[3] & 0xFF) == 0xFF)
261 else if ((buffer[0] & 0xFF) < 0x80)
267 if (buffer[1] != 0)
271 else if (length < 4 || buffer[2] != 0)
288 if ((buffer[0] & 0xFF) == 0xEF)
292 else if ((buffer[0] & 0xFF) == 0xFE)
296 else if (length < 4 || buffer[2] != 0)
312 * Ensures the requested capacity by increasing the buffer size when the
315 * @param requestedLength requested new buffer length
319 if (requestedLength > buffer.length)
321 byte[] oldBuf = buffer;
322 buffer = new byte[oldBuf.length * 2];
323 System.arraycopy(oldBuf, 0, buffer, 0, oldBuf.length);