Lines Matching refs:bytes

42  * Immutable array of bytes.
48 private final byte[] bytes;
50 private ByteString(final byte[] bytes) {
51 this.bytes = bytes;
60 return bytes[index];
64 * Gets the number of bytes.
67 return bytes.length;
74 return bytes.length == 0;
86 * Copies the given bytes into a {@code ByteString}.
88 public static ByteString copyFrom(final byte[] bytes, final int offset,
91 System.arraycopy(bytes, offset, copy, 0, size);
96 * Copies the given bytes into a {@code ByteString}.
98 public static ByteString copyFrom(final byte[] bytes) {
99 return copyFrom(bytes, 0, bytes.length);
103 * Copies {@code size} bytes from a {@code java.nio.ByteBuffer} into
106 public static ByteString copyFrom(final ByteBuffer bytes, final int size) {
108 bytes.get(copy);
113 * Copies the remaining bytes from a {@code java.nio.ByteBuffer} into
116 public static ByteString copyFrom(final ByteBuffer bytes) {
117 return copyFrom(bytes, bytes.remaining());
121 * Encodes {@code text} into a sequence of bytes using the named charset
130 * Encodes {@code text} into a sequence of UTF-8 bytes and returns the
160 byte[] bytes = new byte[size];
163 System.arraycopy(str.bytes, 0, bytes, pos, str.size());
166 return new ByteString(bytes);
173 * Copies bytes into a buffer at the given offset.
179 System.arraycopy(bytes, 0, target, offset, bytes.length);
183 * Copies bytes into a buffer.
186 * @param sourceOffset offset within these bytes
188 * @param size number of bytes to copy
193 System.arraycopy(bytes, sourceOffset, target, targetOffset, size);
197 * Copies bytes to a {@code byte[]}.
200 final int size = bytes.length;
202 System.arraycopy(bytes, 0, copy, 0, size);
211 final ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
216 * Constructs a new {@code String} by decoding the bytes using the
221 return new String(bytes, charsetName);
225 * Constructs a new {@code String} by decoding the bytes as UTF-8.
229 return new String(bytes, "UTF-8");
249 final int size = bytes.length;
250 if (size != other.bytes.length) {
254 final byte[] thisBytes = bytes;
255 final byte[] otherBytes = other.bytes;
272 final byte[] thisBytes = bytes;
273 final int size = bytes.length;
293 * Creates an {@code InputStream} which can be used to read the bytes.
296 return new ByteArrayInputStream(bytes);
300 * Creates a {@link CodedInputStream} which can be used to read the bytes.
305 // We trust CodedInputStream not to modify the bytes, or to give anyone
307 return CodedInputStream.newInstance(bytes);
362 * write exactly this many bytes before building the result.
382 // underlying bytes anymore because it already wrote all of them. So,