Package org.apache.calcite.util
Class NlsString
java.lang.Object
org.apache.calcite.util.NlsString
- All Implemented Interfaces:
Cloneable
,Comparable<NlsString>
A string, optionally with
character set
and
SqlCollation
. It is immutable.-
Constructor Summary
ConstructorDescriptionNlsString
(String stringValue, @Nullable String charsetName, @Nullable SqlCollation collation) Easy constructor for Java string.NlsString
(org.apache.calcite.avatica.util.ByteString bytesValue, String charsetName, @Nullable SqlCollation collation) Creates a string in a specified character set. -
Method Summary
Modifier and TypeMethodDescriptionasSql
(boolean prefix, boolean suffix) AsasSql(boolean, boolean, SqlDialect)
but with SQL standard dialect.asSql
(boolean prefix, boolean suffix, SqlDialect dialect) Returns the string quoted for SQL, for example_ISO-8859-1'is it a plane? no it''s superman!'
.clone()
int
static NlsString
Concatenates someNlsString
objects.Creates a copy of thisNlsString
with different content but same charset and collation.boolean
@Nullable Charset
@Nullable String
@Nullable SqlCollation
getValue()
@Nullable org.apache.calcite.avatica.util.ByteString
Returns the value as aByteString
.int
hashCode()
rtrim()
Returns a string the same as this but with spaces trimmed from the right.toString()
Returns the string quoted for SQL, for example_ISO-8859-1'is it a plane? no it''s superman!'
.
-
Constructor Details
-
NlsString
public NlsString(org.apache.calcite.avatica.util.ByteString bytesValue, String charsetName, @Nullable SqlCollation collation) Creates a string in a specified character set.- Parameters:
bytesValue
- Byte array constant, must not be nullcharsetName
- Name of the character set, must not be nullcollation
- Collation, may be null- Throws:
IllegalCharsetNameException
- If the given charset name is illegalUnsupportedCharsetException
- If no support for the named charset is available in this instance of the Java virtual machineRuntimeException
- If the given value cannot be represented in the given charset
-
NlsString
public NlsString(String stringValue, @Nullable String charsetName, @Nullable SqlCollation collation) Easy constructor for Java string.- Parameters:
stringValue
- String constant, must not be nullcharsetName
- Name of the character set, may be nullcollation
- Collation, may be null- Throws:
IllegalCharsetNameException
- If the given charset name is illegalUnsupportedCharsetException
- If no support for the named charset is available in this instance of the Java virtual machineRuntimeException
- If the given value cannot be represented in the given charset
-
-
Method Details
-
clone
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<NlsString>
-
getCharsetName
-
getCharset
-
getCollation
-
getValue
-
rtrim
Returns a string the same as this but with spaces trimmed from the right. -
asSql
AsasSql(boolean, boolean, SqlDialect)
but with SQL standard dialect. -
asSql
Returns the string quoted for SQL, for example_ISO-8859-1'is it a plane? no it''s superman!'
.- Parameters:
prefix
- if true, prefix the character set namesuffix
- if true, suffix the collation clausedialect
- Dialect- Returns:
- the quoted string
-
toString
Returns the string quoted for SQL, for example_ISO-8859-1'is it a plane? no it''s superman!'
. -
concat
Concatenates someNlsString
objects. The result has the charset and collation of the first element. The other elements must have matching (or null) charset and collation. Concatenates all at once, not pairwise, to avoid string copies.- Parameters:
args
- array ofNlsString
to be concatenated
-
copy
Creates a copy of thisNlsString
with different content but same charset and collation. -
getValueBytes
@Pure public @Nullable org.apache.calcite.avatica.util.ByteString getValueBytes()Returns the value as aByteString
.
-