public class NlsString extends java.lang.Object implements java.lang.Comparable<NlsString>, java.lang.Cloneable
character set
and
SqlCollation
. It is immutable.Modifier and Type | Field and Description |
---|---|
private org.apache.calcite.avatica.util.ByteString |
bytesValue |
private java.nio.charset.Charset |
charset |
private java.lang.String |
charsetName |
private SqlCollation |
collation |
private static com.google.common.cache.LoadingCache<Pair<org.apache.calcite.avatica.util.ByteString,java.nio.charset.Charset>,java.lang.String> |
DECODE_MAP |
private java.lang.String |
stringValue |
Modifier | Constructor and Description |
---|---|
|
NlsString(org.apache.calcite.avatica.util.ByteString bytesValue,
java.lang.String charsetName,
SqlCollation collation)
Creates a string in a specified character set.
|
private |
NlsString(java.lang.String stringValue,
org.apache.calcite.avatica.util.ByteString bytesValue,
java.lang.String charsetName,
SqlCollation collation)
Internal constructor; other constructors must call it.
|
|
NlsString(java.lang.String stringValue,
java.lang.String charsetName,
SqlCollation collation)
Easy constructor for Java string.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
asSql(boolean prefix,
boolean suffix)
Returns the string quoted for SQL, for example
_ISO-8859-1'is it a
plane? no it''s superman!' . |
java.lang.Object |
clone() |
int |
compareTo(NlsString other) |
static NlsString |
concat(java.util.List<NlsString> args)
Concatenates some
NlsString objects. |
NlsString |
copy(java.lang.String value)
Creates a copy of this
NlsString with different content but same
charset and collation. |
boolean |
equals(java.lang.Object obj) |
java.nio.charset.Charset |
getCharset() |
java.lang.String |
getCharsetName() |
SqlCollation |
getCollation() |
java.lang.String |
getValue() |
org.apache.calcite.avatica.util.ByteString |
getValueBytes()
Returns the value as a
ByteString . |
int |
hashCode() |
NlsString |
rtrim()
Returns a string the same as this but with spaces trimmed from the
right.
|
java.lang.String |
toString()
Returns the string quoted for SQL, for example
_ISO-8859-1'is it a
plane? no it''s superman!' . |
private static final com.google.common.cache.LoadingCache<Pair<org.apache.calcite.avatica.util.ByteString,java.nio.charset.Charset>,java.lang.String> DECODE_MAP
private final java.lang.String stringValue
private final org.apache.calcite.avatica.util.ByteString bytesValue
private final java.lang.String charsetName
private final java.nio.charset.Charset charset
private final SqlCollation collation
public NlsString(org.apache.calcite.avatica.util.ByteString bytesValue, java.lang.String charsetName, SqlCollation collation)
bytesValue
- Byte array constant, must not be nullcharsetName
- Name of the character set, must not be nullcollation
- Collation, may be nulljava.nio.charset.IllegalCharsetNameException
- If the given charset name is illegaljava.nio.charset.UnsupportedCharsetException
- If no support for the named charset
is available in this instance of the Java virtual machinejava.lang.RuntimeException
- If the given value cannot be represented in the
given charsetpublic NlsString(java.lang.String stringValue, java.lang.String charsetName, SqlCollation collation)
stringValue
- String constant, must not be nullcharsetName
- Name of the character set, may be nullcollation
- Collation, may be nulljava.nio.charset.IllegalCharsetNameException
- If the given charset name is illegaljava.nio.charset.UnsupportedCharsetException
- If no support for the named charset
is available in this instance of the Java virtual machinejava.lang.RuntimeException
- If the given value cannot be represented in the
given charsetprivate NlsString(java.lang.String stringValue, org.apache.calcite.avatica.util.ByteString bytesValue, java.lang.String charsetName, SqlCollation collation)
public java.lang.Object clone()
clone
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int compareTo(NlsString other)
compareTo
in interface java.lang.Comparable<NlsString>
public java.lang.String getCharsetName()
public java.nio.charset.Charset getCharset()
public SqlCollation getCollation()
public java.lang.String getValue()
public NlsString rtrim()
public java.lang.String asSql(boolean prefix, boolean suffix)
_ISO-8859-1'is it a
plane? no it''s superman!'
.prefix
- if true, prefix the character set namesuffix
- if true, suffix the collation clausepublic java.lang.String toString()
_ISO-8859-1'is it a
plane? no it''s superman!'
.toString
in class java.lang.Object
public static NlsString concat(java.util.List<NlsString> args)
NlsString
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.args
- array of NlsString
to be concatenatedpublic NlsString copy(java.lang.String value)
NlsString
with different content but same
charset and collation.public org.apache.calcite.avatica.util.ByteString getValueBytes()
ByteString
.Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.