@Override public void setChar(long byteIndex, char[] source, int elemoff, int numElems) { for ( int i=0; i <numElems; i++ ) { buffer.putChar((int) (byteIndex+2*i),source[i+elemoff]); } }
@Override public void putChar(long byteIndex, char c) { buffer.putChar((int) byteIndex, c); }
@Override public void writeString( char value ) { buf.putChar( value ); }
@Override public CharBuffer put (int index, char c) { if (index < 0 || index >= limit) { throw new IndexOutOfBoundsException(); } byteBuffer.putChar(index << 1, c); return this; }
@Override public CharBuffer put (int index, char c) { if (index < 0 || index >= limit) { throw new IndexOutOfBoundsException(); } byteBuffer.putChar(index << 1, c); return this; }
@Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } }
@Override public final Hasher putChar(char c) { buffer.putChar(c); munchIfFull(); return this; }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); ByteBuffer buffer = ByteBuffer.allocate(len * 2).order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < len; i++) { buffer.putChar(input.charAt(i)); } return hashBytes(buffer.array()); }
@Override public CharBuffer put (char c) { if (position == limit) { throw new BufferOverflowException(); } byteBuffer.putChar(position++ << 1, c); return this; }
@Override public void writeString( String value ) { final int len = value.length(); buf.putInt( value.length() ); for ( int i = 0; i < len; i++ ) { final char c = value.charAt( i ); buf.putChar( c ); } }
@Override public CharBuffer put (char c) { if (position == limit) { throw new BufferOverflowException(); } byteBuffer.putChar(position++ << 1, c); return this; }
@Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } }
@Override public HashCode hashUnencodedChars(CharSequence input) { int len = input.length(); ByteBuffer buffer = ByteBuffer.allocate(len * 2).order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < len; i++) { buffer.putChar(input.charAt(i)); } return hashBytes(buffer.array()); }
@Override public final Hasher putChar(char c) { buffer.putChar(c); munchIfFull(); return this; }
/** * Append the given {@code char} to this {@literal Buffer}. * * @param c The {@code char} to append. * @return {@literal this} */ public Buffer append(char c) { ensureCapacity(2); buffer.putChar(c); return this; }
@Override public final Hasher putChar(char c) { buffer.putChar(c); munchIfFull(); return this; }
@Override public Hasher putChar(char c) { scratch.putChar(c); return update(Chars.BYTES); } }
/** * Prepend the given {@code char} to this existing {@literal Buffer}. * * @param c The {@code char} to prepend. * @return {@literal this} */ public Buffer prepend(char c) { shift(2); this.buffer.putChar(c); reset(); return this; }
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_PAIRED_STATS.toByteArray(); byte[] tooLongByteArray = ByteBuffer.allocate(buffer.length + 2) .order(ByteOrder.LITTLE_ENDIAN) .put(buffer) .putChar('.') .array(); try { PairedStats.fromByteArray(tooLongByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() { byte[] buffer = MANY_VALUES_STATS_VARARGS.toByteArray(); byte[] tooLongByteArray = ByteBuffer.allocate(buffer.length + 2) .order(ByteOrder.LITTLE_ENDIAN) .put(buffer) .putChar('.') .array(); try { Stats.fromByteArray(tooLongByteArray); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }