Java SDK Documentation
11.0.1
|
Static Public Member Functions | |
static ByteBuffer | duplicateBB (ByteBuffer buffer) |
static Charset | getCharset () |
static ByteBuffer | getStringBytes (String value, int length, boolean removeTrailingSpaces) |
static ByteBuffer | getStringBytes (String value, int length, boolean removeTrailingSpaces, boolean truncate) |
static String | newString (ByteBuffer buffer) |
static String | newString (ByteBuffer buffer, Charset charset) |
static void | removeTruncatedUtf8CharBytes (ByteBuffer string) |
static ByteBuffer | sliceBB (ByteBuffer buffer) |
A collection of string-related functions which assist in reading, generating, and handling Vertica string-like types. String-like types include:
|
static |
A safer version of ByteBuffer#duplicate() that works around weird Java behavior. ByteBuffer#duplicate() does not apply the byte ordering of the source buffer to the duplicate buffer. This helper handles this. Otherwise it is identical.
buffer | A non-null ByteBuffer. |
Referenced by com.vertica.sdk.vmap.v1.Encoder.encode().
|
static |
Get the Charset used by Vertica. Required for any strings stored within or retrieved from Vertica.
Referenced by com.vertica.sdk.VString.copy(), and com.vertica.sdk.StringUtils.newString().
|
static |
Correctly extract the bytes from a Java String in Vertica's character set. Does not perform truncation. Shorthand for:
getStringBytes(value, length, removeTrailingSpaces, false);
value | A non-null String (may be empty) |
length | The maximum byte length of the destination, or -1 for no maximum. |
removeTrailingSpaces | If true, trailing ASCII spaces will be excluded from the resulting byte sequence. This is proper behavior for Vertica's 'char' type. |
|
static |
Correctly extract the bytes from a Java String in Vertica's character set. This ensures that the value fits within the designated byte length OR is properly truncated.
If truncation falls within a multi-byte character, additional bytes will be removed in order to ensure the contents are a valid string encoding. This can cause truncation to result in byte buffer that is shorter than length.
When applicable, trailing spaces are removed from the input string immediately as well as after truncation. Therefore, values that exceed the maximum length due to trailing spaces will not require truncation. Also, values that are truncated (if applicable) will have any remaining trailing spaces removed.
value | A non-null String (may be empty) |
length | The maximum byte length of the destination, or -1 for no maximum. |
removeTrailingSpaces | If true, trailing ASCII spaces will be excluded from the resulting byte sequence. This is proper behavior for Vertica's 'char' type. |
truncate | If true, truncate values that are too long. If false, return null for values that are too long. |
|
static |
Decode a String from the ByteBuffer using Vertica's charset. This is written to avoid unnecessary copies of the byte data. The buffer is not modified.
buffer | The buffer with String bytes between its position and limit. The position and limit of the buffer is left unmodified. May not be null. |
|
static |
Decode a String from the ByteBuffer using the specified charset. The implementation avoids unnecessary copies of the byte data.
buffer | The buffer with String bytes between its position and limit. The position and limit of the buffer is left unmodified. May not be null. |
charset | The Charset to use when creating the new string from the source bytes. |
|
static |
Removes bytes at the end of a string encoded in Vertica's character set that are incomplete multi-byte characters. This scenario usually occurs due to truncation according to byte length which falls in the middle of a multi-byte character. This further truncation ensures the final string is valid in Vertica's encoding.
string | A ByteBuffer representing a string in Vertica's encoding. The limit will be moved towards the position in order to drop partial multi-byte characters. |
Referenced by com.vertica.sdk.StringUtils.getStringBytes().
|
static |
A safer version of ByteBuffer#slice() that works around weird Java behavior. ByteBuffer#slice() does not apply the byte ordering of the source buffer to the slice buffer. This helper handles this. Otherwise it is identical.
buffer | A non-null ByteBuffer. |