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
ConstructorsConstructorDescriptionNlsString(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()intstatic NlsStringConcatenates someNlsStringobjects.Creates a copy of thisNlsStringwith different content but same charset and collation.boolean@Nullable Charset@Nullable String@Nullable SqlCollationgetValue()@Nullable org.apache.calcite.avatica.util.ByteStringReturns the value as aByteString.inthashCode()rtrim()Returns a string the same as this but with spaces trimmed from the right.rtrim(int minResultSize) 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:
compareToin interfaceComparable<NlsString>
-
getCharsetName
-
getCharset
-
getCollation
-
getValue
-
rtrim
Returns a string the same as this but with spaces trimmed from the right. -
rtrim
Returns a string the same as this but with spaces trimmed from the right. The result is never shorter than minResultSize.- Parameters:
minResultSize- Expected size for result string. If negative, it indicates that no trimming should be done.
-
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 someNlsStringobjects. 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 ofNlsStringto be concatenated
-
copy
Creates a copy of thisNlsStringwith different content but same charset and collation. -
getValueBytes
@Pure public @Nullable org.apache.calcite.avatica.util.ByteString getValueBytes()Returns the value as aByteString.
-