public final class CqlIdentifier extends Object implements Comparable<CqlIdentifier>, Serializable
CQL identifiers, when unquoted, are converted to lower case. When quoted, they are returned as-is with no lower
casing and encased in double quotes. To render, use any of the methods toCql(),
toCql(StringBuilder), or toString().
toCql(),
toCql(StringBuilder),
toString(),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static Pattern |
QUOTED |
static String |
QUOTED_REGEX |
static Pattern |
UNQUOTED |
static String |
UNQUOTED_REGEX |
| Constructor and Description |
|---|
CqlIdentifier(CharSequence identifier)
Creates a new
CqlIdentifier without force-quoting it. |
CqlIdentifier(CharSequence identifier,
boolean forceQuote)
Creates a new CQL identifier, optionally force-quoting it.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(CqlIdentifier identifier)
Unquoted identifiers sort before quoted ones.
|
static CqlIdentifier |
cqlId(CharSequence identifier)
Factory method for
CqlIdentifier. |
static CqlIdentifier |
cqlId(CharSequence identifier,
boolean forceQuote)
Factory method for
CqlIdentifier. |
boolean |
equals(Object obj)
Compares this
CqlIdentifier to the given object. |
String |
getUnquoted()
Returns the identifier without encasing quotes, regardless of the value of
isQuoted(). |
int |
hashCode() |
boolean |
isQuoted()
Whether or not this identifier is quoted.
|
static boolean |
isQuotedIdentifier(CharSequence chars)
Returns
true if the given CharSequence is a legal unquoted identifier. |
static boolean |
isUnquotedIdentifier(CharSequence chars)
Returns
true if the given CharSequence is a legal unquoted identifier. |
static CqlIdentifier |
quotedCqlId(CharSequence identifier)
Factory method for a force-quoted
CqlIdentifier. |
String |
toCql()
Renders this identifier appropriately.
|
StringBuilder |
toCql(StringBuilder builder)
Appends the rendering of this identifier to the given
StringBuilder, then returns that
StringBuilder. |
String |
toString()
Alias for
toCql(). |
public static final String UNQUOTED_REGEX
public static final Pattern UNQUOTED
public static final String QUOTED_REGEX
public static final Pattern QUOTED
public CqlIdentifier(CharSequence identifier)
CqlIdentifier without force-quoting it. It may end up quoted, depending on its value.cqlId(CharSequence)public CqlIdentifier(CharSequence identifier, boolean forceQuote)
forceQuote is true,
isQuoted() will return true and the identifier will be quoted when rendered.isQuoted() will return false,
plus the name will be converted to lower case and rendered as such.IllegalArgumentException is thrown.public static CqlIdentifier cqlId(CharSequence identifier)
CqlIdentifier. Convenient if imported statically.CqlIdentifier(CharSequence)public static CqlIdentifier cqlId(CharSequence identifier, boolean forceQuote)
CqlIdentifier. Convenient if imported statically.CqlIdentifier(CharSequence, boolean)public static CqlIdentifier quotedCqlId(CharSequence identifier)
CqlIdentifier. Convenient if imported statically.CqlIdentifier(CharSequence, boolean)public static boolean isUnquotedIdentifier(CharSequence chars)
true if the given CharSequence is a legal unquoted identifier.public static boolean isQuotedIdentifier(CharSequence chars)
true if the given CharSequence is a legal unquoted identifier.public String getUnquoted()
isQuoted(). For
example, if isQuoted() is true, then this value will be the same as toCql() and
toString().
This is needed, for example, to get the correct TableMetadata from
KeyspaceMetadata.getTable(String): the given string must not be quoted.public String toCql()
public StringBuilder toCql(StringBuilder builder)
StringBuilder, then returns that
StringBuilder. If null is given, a new StringBuilder is created, appended to, and
returned.public boolean isQuoted()
public int compareTo(CqlIdentifier identifier)
compareTo in interface Comparable<CqlIdentifier>public boolean equals(Object obj)
CqlIdentifier to the given object. Note that if a CharSequence is given, a new
CqlIdentifier is created from it and compared, such that a CharSequence can be effectively equal to
a CqlIdentifier.Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.