Lines Matching refs:length

20  * Byte buffer container including length of valid data.
29 private int length;
40 this.length = 0;
50 this.length = buffer.length;
56 * @param length the length of valid bytes in the array
58 public ByteBuffer(byte[] buffer, int length)
60 if (length > buffer.length)
62 throw new ArrayIndexOutOfBoundsException("Valid length exceeds the buffer length.");
65 this.length = length;
79 this.length = 0;
83 while ((read = in.read(this.buffer, this.length, chunk)) > 0)
85 this.length += read;
88 ensureCapacity(length + chunk);
101 * @param length the length of valid bytes in the array
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);
111 this.length = length;
120 return new ByteArrayInputStream(buffer, 0, length);
125 * @return Returns the length, that means the number of valid bytes, of the buffer;
128 public int length()
130 return length;
135 // * <em>Note:</em> Only the byte up to length are valid!
150 if (index < length)
167 if (index < length)
184 ensureCapacity(length + 1);
185 buffer[length++] = b;
198 ensureCapacity(length + len);
199 System.arraycopy(bytes, offset, buffer, length, len);
200 length += len;
210 append(bytes, 0, bytes.length);
220 append(anotherBuffer.buffer, 0, anotherBuffer.length);
236 if (length < 2)
238 // only one byte length must be UTF-8
248 if (length < 4 || buffer[1] != 0)
271 else if (length < 4 || buffer[2] != 0)
296 else if (length < 4 || buffer[2] != 0)
313 * current length is exceeded.
315 * @param requestedLength requested new buffer length
319 if (requestedLength > buffer.length)
322 buffer = new byte[oldBuf.length * 2];
323 System.arraycopy(oldBuf, 0, buffer, 0, oldBuf.length);