Package com.google.common.hash
Interface PrimitiveSink
-
- All Known Subinterfaces:
Hasher
@Beta public interface PrimitiveSink
An object which can receive a stream of primitive values.- Since:
- 12.0 (in 11.0 as
Sink) - Author:
- Kevin Bourrillion
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description PrimitiveSinkputBoolean(boolean b)Puts a boolean into this sink.PrimitiveSinkputByte(byte b)Puts a byte into this sink.PrimitiveSinkputBytes(byte[] bytes)Puts an array of bytes into this sink.PrimitiveSinkputBytes(byte[] bytes, int off, int len)Puts a chunk of an array of bytes into this sink.PrimitiveSinkputBytes(java.nio.ByteBuffer bytes)Puts the remaining bytes of a byte buffer into this sink.PrimitiveSinkputChar(char c)Puts a character into this sink.PrimitiveSinkputDouble(double d)Puts a double into this sink.PrimitiveSinkputFloat(float f)Puts a float into this sink.PrimitiveSinkputInt(int i)Puts an int into this sink.PrimitiveSinkputLong(long l)Puts a long into this sink.PrimitiveSinkputShort(short s)Puts a short into this sink.PrimitiveSinkputString(java.lang.CharSequence charSequence, java.nio.charset.Charset charset)Puts a string into this sink using the given charset.PrimitiveSinkputUnencodedChars(java.lang.CharSequence charSequence)Puts each 16-bit code unit from theCharSequenceinto this sink.
-
-
-
Method Detail
-
putByte
@CanIgnoreReturnValue PrimitiveSink putByte(byte b)
Puts a byte into this sink.- Parameters:
b- a byte- Returns:
- this instance
-
putBytes
@CanIgnoreReturnValue PrimitiveSink putBytes(byte[] bytes)
Puts an array of bytes into this sink.- Parameters:
bytes- a byte array- Returns:
- this instance
-
putBytes
@CanIgnoreReturnValue PrimitiveSink putBytes(byte[] bytes, int off, int len)
Puts a chunk of an array of bytes into this sink.bytes[off]is the first byte written,bytes[off + len - 1]is the last.- Parameters:
bytes- a byte arrayoff- the start offset in the arraylen- the number of bytes to write- Returns:
- this instance
- Throws:
java.lang.IndexOutOfBoundsException- ifoff < 0oroff + len > bytes.lengthorlen < 0
-
putBytes
@CanIgnoreReturnValue PrimitiveSink putBytes(java.nio.ByteBuffer bytes)
Puts the remaining bytes of a byte buffer into this sink.bytes.position()is the first byte written,bytes.limit() - 1is the last. The position of the buffer will be equal to the limit when this method returns.- Parameters:
bytes- a byte buffer- Returns:
- this instance
- Since:
- 23.0
-
putShort
@CanIgnoreReturnValue PrimitiveSink putShort(short s)
Puts a short into this sink.
-
putInt
@CanIgnoreReturnValue PrimitiveSink putInt(int i)
Puts an int into this sink.
-
putLong
@CanIgnoreReturnValue PrimitiveSink putLong(long l)
Puts a long into this sink.
-
putFloat
@CanIgnoreReturnValue PrimitiveSink putFloat(float f)
Puts a float into this sink.
-
putDouble
@CanIgnoreReturnValue PrimitiveSink putDouble(double d)
Puts a double into this sink.
-
putBoolean
@CanIgnoreReturnValue PrimitiveSink putBoolean(boolean b)
Puts a boolean into this sink.
-
putChar
@CanIgnoreReturnValue PrimitiveSink putChar(char c)
Puts a character into this sink.
-
putUnencodedChars
@CanIgnoreReturnValue PrimitiveSink putUnencodedChars(java.lang.CharSequence charSequence)
Puts each 16-bit code unit from theCharSequenceinto this sink.Warning: This method will produce different output than most other languages do when running on the equivalent input. For cross-language compatibility, use
putString(java.lang.CharSequence, java.nio.charset.Charset), usually with a charset of UTF-8. For other use cases, useputUnencodedChars.- Since:
- 15.0 (since 11.0 as putString(CharSequence))
-
putString
@CanIgnoreReturnValue PrimitiveSink putString(java.lang.CharSequence charSequence, java.nio.charset.Charset charset)
Puts a string into this sink using the given charset.Warning: This method, which reencodes the input before processing it, is useful only for cross-language compatibility. For other use cases, prefer
putUnencodedChars(java.lang.CharSequence), which is faster, produces the same output across Java releases, and processes everycharin the input, even if some are invalid.
-
-