Top Description Methods
com.google.common.hash

public Interface PrimitiveSink

Known Direct Subinterfaces
com.google.common.hash.Hasher
Annotations
@Beta
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.Beta, com.google.errorprone.annotations.CanIgnoreReturnValue, java.nio.ByteBuffer, java.nio.charset.Charset

An object which can receive a stream of primitive values.
Author
Kevin Bourrillion
Since
12.0 (in 11.0 as Sink)

Method Summary

Modifier and TypeMethod and Description
public PrimitiveSink
putBoolean(boolean b)

Puts a boolean into this sink.

public PrimitiveSink

Returns:

this instance
putByte
(byte
a byte
b
)

Puts a byte into this sink.

public PrimitiveSink

Returns:

this instance
putBytes
(byte[]
a byte array
bytes
)

Puts an array of bytes into this sink.

public PrimitiveSink

Returns:

this instance
putBytes
(byte[]
a byte array
bytes
,
int
the start offset in the array
off
,
int
the number of bytes to write
len
)

Puts a chunk of an array of bytes into this sink.

public PrimitiveSink

Returns:

this instance
putBytes
(ByteBuffer
a byte buffer
bytes
)

Puts the remaining bytes of a byte buffer into this sink.

public PrimitiveSink
putChar(char c)

Puts a character into this sink.

public PrimitiveSink
putDouble(double d)

Puts a double into this sink.

public PrimitiveSink
putFloat(float f)

Puts a float into this sink.

public PrimitiveSink
putInt(int i)

Puts an int into this sink.

public PrimitiveSink
putLong(long l)

Puts a long into this sink.

public PrimitiveSink
putShort(short s)

Puts a short into this sink.

public PrimitiveSink
putString(CharSequence charSequence, Charset charset)

Puts a string into this sink using the given charset.

public PrimitiveSink
putUnencodedChars(CharSequence charSequence)

Puts each 16-bit code unit from the CharSequence into this sink.

Method Detail

putBooleanback to summary
public PrimitiveSink putBoolean(boolean b)

Puts a boolean into this sink.

Annotations
@CanIgnoreReturnValue
putByteback to summary
public PrimitiveSink putByte(byte b)

Puts a byte into this sink.

Parameters
b:byte

a byte

Returns:PrimitiveSink

this instance

Annotations
@CanIgnoreReturnValue
putBytesback to summary
public PrimitiveSink putBytes(byte[] bytes)

Puts an array of bytes into this sink.

Parameters
bytes:byte[]

a byte array

Returns:PrimitiveSink

this instance

Annotations
@CanIgnoreReturnValue
putBytesback to summary
public 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:byte[]

a byte array

off:int

the start offset in the array

len:int

the number of bytes to write

Returns:PrimitiveSink

this instance

Annotations
@CanIgnoreReturnValue
Exceptions
IndexOutOfBoundsException:
if off < 0 or off + len > bytes.length or len < 0
putBytesback to summary
public PrimitiveSink putBytes(ByteBuffer bytes)

Puts the remaining bytes of a byte buffer into this sink. bytes.position() is the first byte written, bytes.limit() - 1 is the last. The position of the buffer will be equal to the limit when this method returns.

Parameters
bytes:ByteBuffer

a byte buffer

Returns:PrimitiveSink

this instance

Annotations
@CanIgnoreReturnValue
Since
23.0
putCharback to summary
public PrimitiveSink putChar(char c)

Puts a character into this sink.

Annotations
@CanIgnoreReturnValue
putDoubleback to summary
public PrimitiveSink putDouble(double d)

Puts a double into this sink.

Annotations
@CanIgnoreReturnValue
putFloatback to summary
public PrimitiveSink putFloat(float f)

Puts a float into this sink.

Annotations
@CanIgnoreReturnValue
putIntback to summary
public PrimitiveSink putInt(int i)

Puts an int into this sink.

Annotations
@CanIgnoreReturnValue
putLongback to summary
public PrimitiveSink putLong(long l)

Puts a long into this sink.

Annotations
@CanIgnoreReturnValue
putShortback to summary
public PrimitiveSink putShort(short s)

Puts a short into this sink.

Annotations
@CanIgnoreReturnValue
putStringback to summary
public PrimitiveSink putString(CharSequence charSequence, 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, which is faster, produces the same output across Java releases, and processes every char in the input, even if some are invalid.

Annotations
@CanIgnoreReturnValue
putUnencodedCharsback to summary
public PrimitiveSink putUnencodedChars(CharSequence charSequence)

Puts each 16-bit code unit from the CharSequence into 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, usually with a charset of UTF-8. For other use cases, use putUnencodedChars.

Annotations
@CanIgnoreReturnValue
Since
15.0 (since 11.0 as putString(CharSequence))