|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.sqltools.sqlbuilder.util.SQLIdentifier
public class SQLIdentifier
The main methods of this class help handle ordinary and delimited SQL identifiers, and can be understood according to the origin of the identifier and their intended use:
boolean isDBIDOrdinary(id)
boolean isDBIDOrdinary(id, platforms)
String convertDBID(id, delimiter)
String convertDBID(id, delimiter, platforms)
boolean isUserInputOrdinary(id)
boolean isUserInputOrdinary(id, platforms)
boolean isUserInputOrdinary(id, delimiter, platforms)
String convertUserInput(id, delimiter)
String convertUserInput(id, delimiter, platforms)
boolean isUserInputOrdinary(id)
boolean isUserInputOrdinary(id, platforms)
boolean isUserInputOrdinary(id, delimiter, platforms)
String convertDBID(id, delimiter)
String convertDBID(id, delimiter, platforms)
Other methods provide supporting function.
The methods implement the following differences between platforms:
For definitions of an ordinary SQL identifier see the online documentation:
Field Summary | |
---|---|
static java.lang.String |
CLOUDSCAPE
For identifying DatabaseDefinitions vendor names for IBM Cloudscape. |
static java.lang.String |
DB2_ISERIES
For identifying DatabaseDefinitions vendor names for DB2 for iSeries. |
static java.lang.String |
DB2_LUW0
For identifying DatabaseDefinitions vendor names for DB2 for workstation. |
static java.lang.String |
DB2_ZSERIES
For identifying DatabaseDefinitions vendor names for DB2 for zSeries. |
static java.lang.String |
DERBY
For identifying DatabaseDefinitions vendor names for Derby. |
static int |
PLATFORM_390
OS/390, z/OS. |
static java.lang.String |
PLATFORM_390_KEY
Hash key for OS/390, z/OS |
static int |
PLATFORM_400
OS/400, iSeries. |
static java.lang.String |
PLATFORM_400_KEY
Hash key for OS/400, iSeries. |
static int |
PLATFORM_ALL
LUWO, 390, 400, and Cloudscape |
static int |
PLATFORM_ANY
Any platform. |
static int |
PLATFORM_CLOUDSCAPE
Cloudscape. |
static java.lang.String |
PLATFORM_CLOUDSCAPE_KEY
Hash key for Cloudscape. |
static int |
PLATFORM_DB2
LUWO, z/OS, and iSeries |
static int |
PLATFORM_DERBY
Derby. |
static int |
PLATFORM_INFORMIX
Informix. |
static int |
PLATFORM_LUWO
LUWO: Linux, UNIX, Windows, and OS/2. |
static java.lang.String |
PLATFORM_LUWO_KEY
Hash key for LUWO: Linux, UNIX, Windows, and OS/2. |
static int |
PLATFORM_ORACLE
Oracle. |
static int |
PLATFORM_OTHER
Any other platform. |
static java.lang.String |
PLATFORM_OTHER_KEY
Hash key for any other platform. |
static int |
PLATFORM_SQLSERVER
SQL Server. |
static int |
PLATFORM_SYBASE
Sybase. |
static int |
TRIM_ALL
All of the above. |
static int |
TRIM_BOTH
Trim from the left and the right. |
static int |
TRIM_INSIDE
Trim inside the specified delimiter from the right. |
static int |
TRIM_LEFT
Trim from the left. |
static int |
TRIM_RIGHT
Trim from the right. |
Method Summary | |
---|---|
static boolean |
beginsWith(java.lang.String id,
java.lang.String prefix,
char delimiter)
Returns true if the two SQL identifiers match to the length of prefix. |
static boolean |
checkName(java.util.Enumeration e,
java.lang.String identifier,
char delimiter)
Checks the passed uniqueName is in the passed Enumeration of names and returns true if found, false otherwise. |
static java.lang.String |
concatIdentifier(java.lang.String id,
java.lang.Object add,
char delimiter)
Returns a new identifier concatonating the toString of the object (before the closing delimiter if need be). |
static java.lang.String |
convertAuthID(java.lang.String id,
char delim,
int platforms)
Returns the input authorization ID in SQL format. |
static java.lang.String |
convertAuthID(java.lang.String id,
ISQLEditorConnectionInfo coninfo)
Returns the input authorization ID in SQL format. |
static java.lang.String |
convertDBID(java.lang.String id,
char delimiter)
Returns the input SQL identifier ready to be used in an SQL statement for DB2 UDB for LUWO. |
static java.lang.String |
convertDBID(java.lang.String id,
char delimiter,
int platforms)
Returns the input SQL identifier ready to be used in an SQL statement for LUWO, OS/390, or OS/400 or a combination of platforms. |
static java.lang.String |
convertDBID(java.lang.String id,
char delimiter,
int platforms,
boolean checkReserved)
Returns the input SQL identifier ready to be used in an SQL statement for LUWO, OS/390, or OS/400 or a combination of platforms. |
static java.lang.String |
convertUserInput(java.lang.String id,
char delimiter)
Returns the user-input SQL identifier as DB2 for LUWO would store it. |
static java.lang.String |
convertUserInput(java.lang.String id,
char delimiter,
int platforms)
Returns the input SQL identifier either converted to uppercase, if it is an ordinary identifier ignoring the case of each letter, or delimited, if it cannot be an ordinary identifier, for LUWO, OS/390, or OS/400 or a combination of platforms. |
static boolean |
equals(java.lang.String ident1,
java.lang.String ident2,
char delimiter)
Returns true if two SQL identifiers are "equal" for DB2 UDB for LUWO. |
static boolean |
equals(java.lang.String ident1,
java.lang.String ident2,
char delimiter,
int platforms)
Returns true if two SQL identifiers in SQL format are "equal" for LUWO, OS/390, or OS/400 or a combination of platforms. |
static boolean |
equals(java.lang.String id1,
java.lang.String id2,
ISQLEditorConnectionInfo coninfo)
Returns true if two SQL identifiers in SQL format are "equal" for the given connection. |
static long |
getCatalogLength(java.lang.String text,
ISQLEditorConnectionInfo aConInfo)
Determines the length in the database catalog of a given Java String. |
static char |
getDelimiter(java.sql.Connection connection)
|
static java.lang.String |
getIdentifierQuoteString(ISQLEditorConnectionInfo connInfo)
Returns the IdentifierQuoteString for a database via a database connection. |
static int |
getPlatform(ISQLEditorConnectionInfo aConInfo)
Returns the code for the DB2 platform represented by a given Connection object. |
static long |
getUTF8Length(java.lang.String text)
Determines the length in UTF-8 of a given Java String. |
static int[] |
getVersion(ISQLEditorConnectionInfo aConInfo)
Returns the version, release, and modification levels, as specified in the ISQLEditorConnectionInfo or DatabaseDefinition. |
static java.util.List |
initReserved(java.lang.String vendor,
java.lang.String version)
Returns a List of SQL keyswords for the given vendor and version. |
static boolean |
isDB2SpecialChar(char c)
Returns true if the given character is a DB2 special character. |
static boolean |
isDBIDOrdinary(java.lang.String id)
Returns true if the given string is an ordinary identifier for DB2 UDB for LUWO; otherwise returns false. |
static boolean |
isDBIDOrdinary(java.lang.String id,
char delimiter,
int platforms)
Returns true if the given identifier from DB2 is an ordinary identifier for LUWO, OS/390, or OS/400 or a combination of platforms; otherwise returns false. |
static boolean |
isDBIDOrdinary(java.lang.String id,
int platforms)
Returns true if the given identifier from DB2 is an ordinary identifier for LUWO, OS/390, or OS/400 or a combination of platforms; otherwise returns false. |
static boolean |
isOrdinary390Char(char ch)
Determines if the specified character is an ordinary character for OS/390. |
static boolean |
isOrdinary400Char(char ch)
Determines if the specified character is an ordinary character for OS/400. |
static boolean |
isOrdinaryChar(char ch,
int platforms)
Determines if the specified character is an ordinary character for LUWO, OS/390, OS/400, or a combination of platforms, for user input. |
static boolean |
isOrdinaryCloudscapeChar(char ch)
Determines if the specified character is an ordinary character for IBM Cloudscape. |
static boolean |
isOrdinaryDigit(char c)
Returns true if the given char is in the range 0..9. |
static boolean |
isOrdinaryLUWOChar(char ch)
Determines if the specified character is an ordinary character for LUWO. |
static boolean |
isOrdinaryOtherChar(char ch)
Determines if the specified character is an ordinary character for a database whose ordinary characters are specified using setExtraOrdinaryChars(String). |
static boolean |
isOrdinaryUpperChar(char ch,
int platforms)
Determines if the specified character is an ordinary character for LUWO, OS/390, OS/400, or a combination of platforms, for an identifier in DB2. |
static boolean |
isReservedIdentifier(java.lang.String id,
char delimiter)
Returns true if the given SQL identifier is a reserved word for DB2 UDB for LUWO. |
static boolean |
isReservedIdentifier(java.lang.String id,
char delimiter,
int platforms)
Returns true if the given SQL ordinary identifier is a reserved word for DB2 UDB for LUWO, OS/390, OS/400, or a combination of platforms. |
static boolean |
isReservedIdentifier(java.lang.String id,
ISQLEditorConnectionInfo coninfo)
Returns true if the given SQL ordinary identifier is a reserved word. |
static boolean |
isReservedSchema(java.lang.String id,
char delimiter)
Returns true if the given SQL identifier is a reserved schema. |
static boolean |
isUserInputOrdinary(java.lang.String id)
Returns true if the given string is an ordinary identifier for DB2 UDB for LUWO ignoring the case of each letter; otherwise returns false. |
static boolean |
isUserInputOrdinary(java.lang.String id,
char delimiter,
int platforms)
Returns true if the given string as input by the user is an ordinary identifier for LUWO, OS/390, or OS/400 or a combination of platforms, ignoring the case of each letter; otherwise returns false. |
static boolean |
isUserInputOrdinary(java.lang.String id,
int platforms)
Returns true if the given string is an ordinary identifier for LUWO, OS/390, or OS/400 or a combination of platforms, ignoring the case of each letter; otherwise returns false. |
static void |
setExtraOrdinaryChars(java.sql.Connection connection)
Sets the extra characters that you can use in an ordinary identifier (those beyond a-z, A-Z, 0-9 and _), between 35 and 383. |
static java.lang.String |
toCatalogFormat(java.lang.String id,
ISQLEditorConnectionInfo coninfo)
Returns the input SQL identifier as the database at the given connection would store it in its catalog. |
static java.lang.String |
toSQLFormat(java.lang.String id,
ISQLEditorConnectionInfo coninfo)
Returns the input SQL identifier ready to be used in an SQL statement for the given connection. |
static java.lang.String |
trim(java.lang.String id,
int side,
char delimiter)
Trims blanks (' '), but not other whitespace characters such as tabs, from the left, the right, and the right inside a delimiter. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int PLATFORM_ANY
public static final int PLATFORM_LUWO
public static final int PLATFORM_390
public static final int PLATFORM_400
public static final int PLATFORM_DB2
public static final int PLATFORM_CLOUDSCAPE
public static final int PLATFORM_ALL
public static final int PLATFORM_DERBY
public static final int PLATFORM_INFORMIX
public static final int PLATFORM_ORACLE
public static final int PLATFORM_SYBASE
public static final int PLATFORM_SQLSERVER
public static final int PLATFORM_OTHER
public static final java.lang.String PLATFORM_390_KEY
public static final java.lang.String PLATFORM_400_KEY
public static final java.lang.String PLATFORM_LUWO_KEY
public static final java.lang.String PLATFORM_CLOUDSCAPE_KEY
public static final java.lang.String PLATFORM_OTHER_KEY
public static final java.lang.String DB2_ZSERIES
public static final java.lang.String DB2_ISERIES
public static final java.lang.String DB2_LUW0
public static final java.lang.String CLOUDSCAPE
public static final java.lang.String DERBY
public static final int TRIM_ALL
public static final int TRIM_BOTH
public static final int TRIM_INSIDE
public static final int TRIM_LEFT
public static final int TRIM_RIGHT
Method Detail |
---|
public static java.lang.String getIdentifierQuoteString(ISQLEditorConnectionInfo connInfo)
connInfo
- Describes the database connection
public static java.lang.String convertAuthID(java.lang.String id, ISQLEditorConnectionInfo coninfo)
id
- An SQL identifier.coninfo
- Describes the database connnection.
convertAuthID(String, char, int)
public static java.lang.String convertAuthID(java.lang.String id, char delim, int platforms)
id
- An SQL identifier.delim
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
public static java.lang.String toCatalogFormat(java.lang.String id, ISQLEditorConnectionInfo coninfo)
Equivalent to convertUserInput(String id, char delimiter, int platforms).
id
- An SQL identifier.coninfo
- Describes the database connnection.
convertUserInput(String, char, int)
public static java.lang.String toSQLFormat(java.lang.String id, ISQLEditorConnectionInfo coninfo)
Equivalent to convertDBID(String id, char delimiter, int platforms).
id
- An SQL identifier.coninfo
- Describes the database connnection.
convertDBID(String, char, int)
public static boolean beginsWith(java.lang.String id, java.lang.String prefix, char delimiter)
id
- An SQL identifierprefix
- The beginning of an SQL identifierdelimiter
- The delimiter defined as the escape character
public static boolean checkName(java.util.Enumeration e, java.lang.String identifier, char delimiter)
names
- Array of namesuniqueName
- The name to be checked.delimiter
- The delimiter defined as the escape character
public static java.lang.String concatIdentifier(java.lang.String id, java.lang.Object add, char delimiter)
id
- The starting identifieradd
- The object to adddelimiter
- The delimiter defined as the escape character
public static java.lang.String convertDBID(java.lang.String id, char delimiter)
(Formerly named db2String.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
For LUWO, OS/390, or OS/400 or a combination of platforms,
see convertDBID(String, char, int)
.
id
- An SQL identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.
convertDBID(String, char, int)
public static java.lang.String convertDBID(java.lang.String id, char delimiter, int platforms)
public static java.lang.String convertDBID(java.lang.String id, char delimiter, int platforms, boolean checkReserved)
(Formerly named db2String.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
id
- An SQL identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
checkReserved
- whether or not identifier should be checked against
list of reserved words when considering 'ordinaryness'. Default true.
public static java.lang.String convertUserInput(java.lang.String id, char delimiter)
(Formerly named handleDB2Identifier.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length, or failing to double internal delimiters.
For LUWO, OS/390, or OS/400 or a combination of platforms,
see convertUserInput(String, char, int)
.
id
- An SQL identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.
convertUserInput(String, char, int)
public static java.lang.String convertUserInput(java.lang.String id, char delimiter, int platforms)
(Formerly named handleDB2Identifier.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
id
- An SQL identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
public static boolean equals(java.lang.String id1, java.lang.String id2, ISQLEditorConnectionInfo coninfo)
id1
- An SQL identifier in SQL format.id2
- An SQL identifier in SQL format.coninfo
- Describes the database connnection.
#equal(String, String, char, int)
public static boolean equals(java.lang.String ident1, java.lang.String ident2, char delimiter)
ident1
- The first identifierident2
- The second identifierdelimiter
- The delimiter defined as the escape character
public static boolean equals(java.lang.String ident1, java.lang.String ident2, char delimiter, int platforms)
ident1
- The first identifierident2
- The second identifierdelsimiter
- The delimiter defined as the escape characterplatforms
- The sum of platform constants:
public static long getCatalogLength(java.lang.String text, ISQLEditorConnectionInfo aConInfo)
public static long getUTF8Length(java.lang.String text)
Each character in a Java String is has a numeric value. The following table defines the number of octets needed to represent this value by its numeric range. This table is derived from the description of UTF-8 at http://ietf.org/rfc/rfc2279.txt.
Terminology:
text
- An arbitrary string or an identifier in catalog format.public static char getDelimiter(java.sql.Connection connection)
connection
- A live Connection.
public static int getPlatform(ISQLEditorConnectionInfo aConInfo)
The
- connection information object
public static int[] getVersion(ISQLEditorConnectionInfo aConInfo)
The
- connection information object
public static boolean isDB2SpecialChar(char c)
' '
'-'
'"'
'.'
'%'
'/'
'&'
':'
'\''
';'
'('
'<'
')'
'='
'*'
'>'
'+'
'?'
','
'_'
'|'
'^'
'!'
c
- A character.
public static boolean isDBIDOrdinary(java.lang.String id)
(Formerly named isOrdinaryIdentifier.)
This method is used when retrieving an SQL identifier from DB2, where the delimiters have been dropped and lower-case characters folded to upper case.
This method assumes that the delimiter is '"' and the platform is LUWO.
To specify the delimiter and the platform,
see isDBIDOrdinary(String, int)
.
id
- A candidate ordinary identifier.
isDBIDOrdinary(String, int)
,
isDBIDOrdinary(String, int)
public static boolean isDBIDOrdinary(java.lang.String id, int platforms)
(Formerly named isOrdinaryIdentifier.)
This method is used when retrieving an SQL identifier from DB2, where the delimiters have been dropped and lower-case characters folded to upper case.
id
- A candidate ordinary identifier.platforms
- The sum of platform constants:
public static boolean isDBIDOrdinary(java.lang.String id, char delimiter, int platforms)
(Formerly named isOrdinaryIdentifier.)
This method is used when retrieving an SQL identifier from DB2, where the delimiters have been dropped and lower-case characters folded to upper case.
id
- A candidate ordinary identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
public static boolean isOrdinary390Char(char ch)
ch
- A char.
public static boolean isOrdinary400Char(char ch)
ch
- A char.
public static boolean isOrdinaryChar(char ch, int platforms)
ch
- A char.platforms
- The sum of platform constants:
public static boolean isOrdinaryDigit(char c)
c
- The char in question.
public static boolean isOrdinaryLUWOChar(char ch)
ch
- A char.
public static boolean isOrdinaryCloudscapeChar(char ch)
ch
- A char.
public static boolean isOrdinaryOtherChar(char ch)
ch
- A char.
public static boolean isOrdinaryUpperChar(char ch, int platforms)
ch
- A char.platforms
- The sum of platform constants:
public static boolean isReservedIdentifier(java.lang.String id, char delimiter)
id
- An SQL identifier.delimiter
- The delimiter defined as the escape character.
public static boolean isReservedIdentifier(java.lang.String id, char delimiter, int platforms)
id
- An SQL ordinary identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
public static boolean isReservedIdentifier(java.lang.String id, ISQLEditorConnectionInfo coninfo)
id
- An SQL identifier.coninfo
- Describes the database connnection.
public static boolean isReservedSchema(java.lang.String id, char delimiter)
id
- A schemadelimiter
- The delimiter defined as the escape character.
public static boolean isUserInputOrdinary(java.lang.String id)
(Formerly named isInputOrdinary.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
For LUWO, OS/390, or OS/400 or a combination of platforms,
see isUserInputOrdinary(String, int)
.
id
- A candidate ordinary identifier.
isUserInputOrdinary(String, int)
public static boolean isUserInputOrdinary(java.lang.String id, char delimiter, int platforms)
(Formerly named isInputOrdinary.)
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
id
- A candidate ordinary identifier.delimiter
- The delimiter defined as the escape character
on the DB2 platform or platforms.platforms
- The sum of platform constants:
public static boolean isUserInputOrdinary(java.lang.String id, int platforms)
(Formerly named isInputOrdinary.)
This method assumes that the delimiter is '"'.
To specify the delimiter,
see isUserInputOrdinary(String, char, int)
.
This method does not guarantee that the identifier is valid; it might violate other rules for identifiers, such as exceeding the maximum length.
id
- A candidate ordinary identifier.platforms
- The sum of platform constants:
public static void setExtraOrdinaryChars(java.sql.Connection connection)
connection
- A live Connection.
A null removes the otherOrdinaryFlags.DatabaseMetaData.getExtraNameCharacters().
public static java.lang.String trim(java.lang.String id, int side, char delimiter)
id
- An SQL identifierside
- A sum of:
delimiter
- The delimiter defined as the escape character,
used only if (side & TRIM_INSIDE) > 0.public static java.util.List initReserved(java.lang.String vendor, java.lang.String version)
vendor
- A vendor name in a DatabaseDefinition.version
- A version string in a DatabaseDefinition.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |