Class DBIdentifier
- Direct Known Subclasses:
DBTableAlias
,DefaultDBColumn
,DefaultDBTable
It already implements functions getting and setting the ADQL and DB names
of the interfaces DBTable
and DBColumn
. Thus, it guarantees
that all DB... identifiers will behave the same way when manipulating their
ADQL and DB names.
- Since:
- 2.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DBIdentifier
(String adqlName) Create an identifier with the given ADQL name.protected
DBIdentifier
(String adqlName, String dbName) Create an identifier with the given ADQL and DB names. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
denormalize
(String ident, boolean caseSensitive) De-normalize the given string.Get the ADQL version of this identifier.Get the database version of this identifier.boolean
Tell whether the ADQL version of this identifier is case sensitive or not.static boolean
isDelimited
(String ident) Tell whether the given identifier is delimited (i.e.static String
Normalize the given identifier.void
setADQLName
(String newName) Set the ADQL version of this identifier.void
setCaseSensitive
(boolean caseSensitive) Set the case sensitivity of the ADQL version of this identifier.void
Set the database version of this identifier.
-
Field Details
-
adqlName
Name (not delimited, not prefixed) to use in ADQL queries.Important: It must never be NULL.
-
adqlCaseSensitive
protected boolean adqlCaseSensitiveA flag indicating if the ADQL name is case sensitive or not (i.e. if it must be delimited or not in an ADQL query). -
dbName
Name (not delimited, not prefixed) of this identifier in the "database". This name must be used, for example, while translating an ADQL query into SQL.Note: It may be NULL. In such case,
getDBName()
must returnadqlName
.
-
-
Constructor Details
-
DBIdentifier
Create an identifier with the given ADQL name.In this constructor, the DB name is not set. Thus,
getDBName()
will return the same asgetADQLName()
.Note: If the given name is delimited, the surrounding double quotes will be removed and
isCaseSensitive()
will returntrue
.- Parameters:
adqlName
- The ADQL and DB name of this identifier. It may be delimited and/or qualified.- Throws:
NullPointerException
- If the given name is NULL or empty.- See Also:
-
DBIdentifier
Create an identifier with the given ADQL and DB names.In this constructor, the DB name is not set. Thus,
getDBName()
will return the same asgetADQLName()
.Note: If the given name is delimited, the surrounding double quotes will be removed and
isCaseSensitive()
will returntrue
.- Parameters:
adqlName
- The ADQL and DB name of this identifier. It may be delimited and/or qualified.- Throws:
NullPointerException
- If the given name is NULL or empty.- See Also:
-
-
Method Details
-
getADQLName
Get the ADQL version of this identifier.This name is neither delimited, nor prefixed. To determine whether it should be delimited in an ADQL query, use
isCaseSensitive()
.Note: The returned string is never empty or NULL.
- Returns:
- The name to use in ADQL queries.
-
setADQLName
Set the ADQL version of this identifier.If the given name is delimited, the surrounding double quotes will be removed and case sensitivity will be set to
true
(i.e.isCaseSensitive()
will returntrue
).Note: The given name must not be prefixed.
WARNING: If the given name is NULL or empty (even after removal of surrounding double quotes, if delimited), this function will immediately throw an exception.
- Parameters:
newName
- New ADQL version of this identifier.- Throws:
NullPointerException
- If the given name is NULL or empty.- See Also:
-
isCaseSensitive
public boolean isCaseSensitive()Tell whether the ADQL version of this identifier is case sensitive or not.If case sensitive, the ADQL name must be written between double quotes (and all inner double quotes should be doubled).
- Returns:
true
if case sensitive,false
otherwise.
-
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive) Set the case sensitivity of the ADQL version of this identifier.Setting the case sensitivity to
true
will force the delimited form of the ADQL name (i.e. it will be written between double quotes).- Parameters:
caseSensitive
-true
to declare the ADQL name as case sensitive,false
otherwise.
-
getDBName
Get the database version of this identifier.This name is neither delimited, nor prefixed.
In an SQL query, this name should be considered as case sensitive.
Note: The returned string is never empty or NULL.
- Returns:
- The real name of this identifier in the "database".
-
setDBName
Set the database version of this identifier.If the given name is delimited, the surrounding double quotes will be removed.
Note 1: The given name should not be prefixed.
Note 2: If the given name is NULL or empty (even after removal of surrounding double quotes if delimited),
getDBName()
will return the same asgetADQLName()
.- Parameters:
newName
- The real name of this identifier in the "database".- See Also:
-
isDelimited
Tell whether the given identifier is delimited (i.e. within the same pair of double quotes -"
).The following identifiers ARE delimited:
"a"
""
(empty string ; but won't be considered as a valid ADQL name)" "
(string with spaces ; but won't be considered as a valid ADQL name)"foo.bar"
"foo"".""bar"
(with escaped double quotes)""""
(idem)
The following identifiers are NOT considered as delimited:
"foo
(missing ending double quote)foo"
(missing leading double quote)"foo"."bar"
(not the same pair of double quotes)
- Parameters:
ident
- Identifier that may be delimited.- Returns:
true
if the given identifier is delimited,false
otherwise.
-
normalize
Normalize the given identifier.This function performs the following operations:
- Remove leading and trailing space characters.
- If the resulting string is empty, return NULL.
- If
delimited
, remove the leading and trailing double quotes. - If the resulting string without leading and trailing spaces is empty, return NULL.
- Return the resulting string.
- Parameters:
ident
- The identifier to normalize.- Returns:
- The normalized string, or NULL if NULL or empty.
- See Also:
-
denormalize
De-normalize the given string.This function does something only if the given string is declared as case sensitive. In such case, it will surround it by double quotes. All inner double quotes will be escaped by doubling them.
Note: If the given string is NULL, it will be returned as such (i.e. NULL).
- Parameters:
ident
- The identifier to de-normalize.caseSensitive
-true
if the given identifier is considered as case sensitive,false
otherwise.- Returns:
- The de-normalized identifier.
- See Also:
-