Lines Matching refs:length
61 // The length of the sub-sequence.
74 * @param length
75 * The length of the sub-sequence.
77 private SubSequence(int offset, int length)
80 this.subLength = length;
114 public int compareTo(byte[] b, int offset, int length)
117 ByteString.checkArrayBounds(b, offset, length);
121 b, offset, length);
163 Math.min(subLength, b.length - offset));
205 public boolean equals(byte[] b, int offset, int length)
208 ByteString.checkArrayBounds(b, offset, length);
212 b, offset, length);
257 public int length()
331 private int length;
365 this.length = 0;
380 buffer[length++] = b;
398 * src.append(b, 0, b.length);
408 return append(b, 0, b.length);
421 * non-negative and no larger than {@code b.length} .
422 * @param length
423 * The length of the byte array to be used; must be
424 * non-negative and no larger than {@code b.length -
428 * If {@code offset} is negative or if {@code length} is
429 * negative or if {@code offset + length} is greater than
430 * {@code b.length}.
432 public ByteStringBuilder append(byte[] b, int offset, int length)
435 ByteString.checkArrayBounds(b, offset, length);
437 if (length != 0)
439 ensureAdditionalCapacity(length);
440 System.arraycopy(b, offset, buffer, this.length, length);
441 this.length += length;
456 * @param length
460 * If {@code length} is less than zero or greater than
463 public ByteStringBuilder append(ByteBuffer buffer, int length)
466 if ((length < 0) || (length > buffer.remaining()))
471 if (length != 0)
473 ensureAdditionalCapacity(length);
474 buffer.get(this.buffer, this.length, length);
475 this.length += length;
506 * @param length
510 * If {@code length} is less than zero or greater than
514 ByteSequenceReader reader, int length)
517 if ((length < 0) || (length > reader.remaining()))
522 if (length != 0)
524 ensureAdditionalCapacity(length);
525 reader.get(buffer, this.length, length);
526 this.length += length;
541 * @param length
548 * If {@code length} is less than zero.
552 public int append(InputStream stream, int length)
555 if (length < 0)
560 ensureAdditionalCapacity(length);
561 int bytesRead = stream.read(buffer, this.length, length);
564 this.length += bytesRead;
579 * @param length
586 * If {@code length} is less than zero.
589 public int append(ReadableByteChannel channel, int length)
592 if (length < 0)
596 ensureAdditionalCapacity(length);
597 int bytesRead = channel.read(ByteBuffer.wrap(buffer, this.length, length));
600 this.length += bytesRead;
619 for (int j = length + 1; j >= length; j--)
624 length += 2;
642 for (int j = length + 3; j >= length; j--)
647 length += 4;
665 for (int i = length + 7; i >= length; i--)
670 length += 8;
693 int len = s.length();
703 buffer[this.length + i] = b;
724 this.length += len;
731 * Appends the ASN.1 BER length encoding representation of the
734 * @param length
735 * The value to encode using the BER length encoding rules.
738 public ByteStringBuilder appendBERLength(int length)
740 if ((length & 0x0000007F) == length)
744 buffer[this.length++] = ((byte) (length & 0xFF));
746 else if ((length & 0x000000FF) == length)
750 buffer[this.length++] = ((byte) 0x81);
751 buffer[this.length++] = ((byte) (length & 0xFF));
753 else if ((length & 0x0000FFFF) == length)
757 buffer[this.length++] = ((byte) 0x82);
758 buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
759 buffer[this.length++] = ((byte) (length & 0xFF));
761 else if ((length & 0x00FFFFFF) == length)
765 buffer[this.length++] = ((byte) 0x83);
766 buffer[this.length++] = ((byte) ((length >> 16) & 0xFF));
767 buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
768 buffer[this.length++] = ((byte) (length & 0xFF));
774 buffer[this.length++] = ((byte) 0x84);
775 buffer[this.length++] = ((byte) ((length >> 24) & 0xFF));
776 buffer[this.length++] = ((byte) ((length >> 16) & 0xFF));
777 buffer[this.length++] = ((byte) ((length >> 8) & 0xFF));
778 buffer[this.length++] = ((byte) (length & 0xFF));
811 if (index >= length || index < 0)
828 return buffer.length;
836 public int compareTo(byte[] b, int offset, int length)
839 ByteString.checkArrayBounds(b, offset, length);
840 return ByteString.compareTo(this.buffer, 0, this.length,
841 b, offset, length);
852 return -(o.compareTo(buffer, 0, length));
858 * Sets the length of this byte string builder to zero.
870 length = 0;
877 * Sets the length of this byte string builder to zero, and resets the
897 if (capacity != buffer.length)
901 length = 0;
924 output.ensureAdditionalCapacity(length);
926 int compressedSize = cryptoManager.compress(buffer, 0, length,
927 output.buffer, output.length, output.buffer.length - output.length);
934 length);
937 output.length += compressedSize;
967 System.arraycopy(buffer, 0, b, offset, Math.min(length,
968 b.length - offset));
979 builder.append(buffer, 0, length);
990 stream.write(buffer, 0, length);
1001 return channel.write(ByteBuffer.wrap(buffer, 0, length));
1016 int newCount = length + size;
1017 if (newCount > buffer.length)
1019 byte[] newbuffer = new byte[Math.max(buffer.length << 1, newCount)];
1020 System.arraycopy(buffer, 0, newbuffer, 0, length);
1031 public boolean equals(byte[] b, int offset, int length)
1034 ByteString.checkArrayBounds(b, offset, length);
1035 return ByteString.equals(this.buffer, 0, this.length,
1036 b, offset, length);
1063 return other.equals(buffer, 0, length);
1078 * Note that the length of the returned array is only guaranteed to
1079 * be the same as the length of this byte string builder immediately
1107 return ByteString.hashCode(buffer, 0, length);
1115 public int length()
1117 return length;
1125 * An index ranges from zero to {@code length() - 1}. The first byte value of
1135 * If the index argument is negative or not less than length().
1140 if (index >= length || index < 0)
1156 * end - 1}. The length (in bytes) of the returned sequence is
1173 * {@code end} is greater than {@code length()}, or if
1179 if ((start < 0) || (start > end) || (end > length))
1194 return copyTo(new byte[length]);
1209 byte[] b = new byte[length];
1210 System.arraycopy(buffer, 0, b, 0, length);
1222 return ByteString.toString(buffer, 0, length);
1236 if (buffer.length > length)
1238 byte[] newBuffer = new byte[length];
1239 System.arraycopy(buffer, 0, newBuffer, 0, length);
1273 int decompressResult = cryptoManager.uncompress(buffer, 0, length,
1274 output.buffer, output.length, output.buffer.length - output.length);
1280 decompressResult = cryptoManager.uncompress(buffer, 0, length,
1281 output.buffer, output.length, output.buffer.length - output.length);
1287 output.length += decompressResult;
1303 return ByteBuffer.wrap(buffer, 0, length);