public abstract class IdUtil
extends java.lang.Object
The syntax for an id follows.
id := delim-id | unDelim-id delim-id := "[""|[any char but quote]]+" undelim-id := (a-z|A-Z|anyunicodeletter)[a-z|A-Z|_|0-9|anyunicodeletter|anyunicodedigit]* In the syntax braces show grouping. '*' means repeat 0 or more times. '|' means or. '+' means repeat 1 or more times.
In addition this class provides support for qualified names. A qualified name is a dot (.) separated list of ids.
Limitations:
Modifier and Type | Field | Description |
---|---|---|
static int |
DBCP_SCHEMA_NAME |
Index of the schema name in a jar name on a db classpath
|
static int |
DBCP_SQL_JAR_NAME |
Index of the sql jar name in a jar name on a db classpath
|
Constructor | Description |
---|---|
IdUtil() |
Modifier and Type | Method | Description |
---|---|---|
static java.lang.String |
appendNormalToList(java.lang.String id,
java.lang.String list) |
Append an identifier to a comma separated list
of identifiers.
|
static void |
checkIdentifierLengthLimit(java.lang.String identifier,
int identifier_length_limit) |
Check that identifier is not too long
|
static java.lang.String |
deleteId(java.lang.String id,
java.lang.String list) |
Delete an normal value from a list of SQL identifiers.
|
static java.lang.String |
dups(java.lang.String[] l) |
Return an IdList with all the ids that are repeated
in l.
|
static java.lang.String |
getUserAuthorizationId(java.lang.String userName) |
Map userName to authorizationId in its normal form.
|
static java.lang.String |
getUserNameFromURLProps(java.util.Properties params) |
Get user name from URL properties (key user) without any transformation.
|
private static boolean |
idChar(boolean first,
int c) |
|
static boolean |
idOnList(java.lang.String id,
java.lang.String list) |
Return true if the normalized value of an indentifier is on the list
of SQL identifiers provided.
|
static java.lang.String |
intersect(java.lang.String[] l1,
java.lang.String[] l2) |
Return an IdList with all the ids that in l1 and l2
or null if not ids are on both lists.
|
static java.lang.String |
mkIdList(java.lang.String[] ids) |
Produce a string form of an idList from an array of
normalized ids.
|
private static java.lang.String |
mkIdListAsEntered(java.lang.String[] externalIds) |
Produce an id list from an array of ids in external form
|
static java.lang.String |
mkQualifiedName(java.lang.String[] ids) |
Make a string form of a qualified name from the array of ids provided.
|
static java.lang.String |
mkQualifiedName(java.lang.String id1,
java.lang.String id2) |
Produce a delimited two part qualified name from two
un-delimited identifiers.
|
static java.lang.String |
normalToDelimited(java.lang.String id) |
Produce a delimited form of a normal value.
|
static java.lang.String[][] |
parseDbClassPath(java.lang.String input) |
Scan a database classpath from the string provided.
|
private static java.lang.String |
parseId(java.io.StringReader r,
boolean normalize) |
Read an id from the StringReader provided.
|
private static java.lang.String[] |
parseIdList(java.io.StringReader r,
boolean normalize) |
Parse a list of comma separated SQL identifiers returning
them a as elements in an array.
|
static java.lang.String[] |
parseIdList(java.lang.String p) |
Scan a list of comma separated SQL identifiers from the string provided.
|
private static java.lang.String[] |
parseMultiPartSQLIdentifier(java.io.StringReader r) |
|
static java.lang.String[] |
parseMultiPartSQLIdentifier(java.lang.String s) |
Parse a multi-part (dot separated) SQL identifier form the
String provided.
|
private static java.lang.String |
parseQId(java.io.StringReader r,
boolean normalize) |
Parse a delimited (quoted) identifier returning either
the value of the identifier or a delimited identifier.
|
static java.lang.String |
parseRoleId(java.lang.String roleName) |
Parse role identifier to internal, case normal form.
|
static java.lang.String |
parseSQLIdentifier(java.lang.String s) |
Parse a SQL identifier from the String provided.
|
private static java.lang.String |
parseUnQId(java.io.StringReader r,
boolean normalize) |
Parse a regular identifier (unquoted) returning returning either
the value of the identifier or a delimited identifier.
|
static java.lang.String |
pruneDups(java.lang.String l) |
Return an IdList with all the duplicate ids removed
|
static java.lang.String |
SQLIdentifier2CanonicalPropertyUsername(java.lang.String authid) |
Given a case normal form SQL authorization identifier, convert it to a
form that may be compared with the username of Derby builtin
authentication, which uses Java properties of the form
derby.user. <username>. |
private static java.lang.String |
vectorToIdList(java.util.Vector<java.lang.String> v,
boolean normal) |
Return an idList in external form with one id for every
element of v.
|
private static void |
verifyEmpty(java.io.Reader r) |
Verify the read is empty (no more characters in its stream).
|
public static final int DBCP_SCHEMA_NAME
public static final int DBCP_SQL_JAR_NAME
public static java.lang.String normalToDelimited(java.lang.String id)
public static java.lang.String mkQualifiedName(java.lang.String id1, java.lang.String id2)
public static java.lang.String mkQualifiedName(java.lang.String[] ids)
public static java.lang.String[] parseMultiPartSQLIdentifier(java.lang.String s) throws StandardException
s
- The string to be parsedStandardException
- Oopsprivate static java.lang.String[] parseMultiPartSQLIdentifier(java.io.StringReader r) throws StandardException
r
- The multi-part identifier to be parsedStandardException
- Oopspublic static java.lang.String parseSQLIdentifier(java.lang.String s) throws StandardException
StandardException
- Oopsprivate static java.lang.String parseId(java.io.StringReader r, boolean normalize) throws StandardException
normalize
- true means return ids in nomral form, false means
return them as they were entered.
Raise an exception if the first thing in the StringReader is not a valid id.
StandardException
- Ooops.public static java.lang.String SQLIdentifier2CanonicalPropertyUsername(java.lang.String authid)
derby.user.
<username>.
The returned form is suitable for comparing against the property string,
cf. systemPropertiesExistsBuiltinUser
.
E.g.:
Argument -> Return ------------------ EVE -> eve [will match Java property: derby.user.eve] eVe -> "eVe" [will match Java property: derby.user."eVe"] "eve" -> """eve""" [will match Java property: derby.user."""eVe"""] \eve\ -> "\eve\" [will match Java property: derby.user."\eve\"] The latter could look this if specified on a Unix shell command line: -Dderby.user.'"\eve\"'=<password> Note: The processing of properties specified on the command line do not interpret backslash as escape in the way done by the java.util.Properties#load method, so no extra backslash is needed above.Since parseSQLIdentifier maps many-to-one, the backward mapping is non-unique, so the chosen lower case canonical form is arbitrary, e.g. we will not be able to correctly match the non-canonical:
[Java property: derby.user.eVe]since this is internally EVE (but see DERBY-3150), and maps back as eve after the rules above.
private static java.lang.String parseUnQId(java.io.StringReader r, boolean normalize) throws java.io.IOException, StandardException
r
- Regular identifier to parse.normalize
- If true return the identifer converted to a single case, otherwise return the identifier as entered.java.io.IOException
- Error accessing valueStandardException
- Error parsing identifier.private static boolean idChar(boolean first, int c)
private static java.lang.String parseQId(java.io.StringReader r, boolean normalize) throws java.io.IOException, StandardException
r
- Quoted identifier to parse.normalize
- If true return a delimited identifer, otherwise return the identifier's value.java.io.IOException
- Error accessing valueStandardException
- Error parsing identifier.private static void verifyEmpty(java.io.Reader r) throws StandardException
r
- StandardException
public static java.lang.String[][] parseDbClassPath(java.lang.String input) throws StandardException
classpath := item[:item]* item := id.id In the syntax braces ([]) show grouping. '*' means repeat 0 or more times. The syntax for id is defined in IdUtil.
StandardException
- Oopspublic static java.lang.String[] parseIdList(java.lang.String p) throws StandardException
StandardException
- Oopsprivate static java.lang.String[] parseIdList(java.io.StringReader r, boolean normalize) throws StandardException
normalize
- true means return ids in nomral form, false means
return them as they were entered.StandardException
- Oopspublic static java.lang.String intersect(java.lang.String[] l1, java.lang.String[] l2)
l1
- An array of ids in normal forml2
- An array of ids in nomral formprivate static java.lang.String vectorToIdList(java.util.Vector<java.lang.String> v, boolean normal)
normal
- True means the ids in v are in normal form
and false means they are in external form.public static java.lang.String getUserAuthorizationId(java.lang.String userName) throws StandardException
StandardException
- on error or userName is nullpublic static java.lang.String getUserNameFromURLProps(java.util.Properties params)
Property.DEFAULT_USER_NAME
public static java.lang.String dups(java.lang.String[] l)
l
- a list of ids in normal form.public static java.lang.String pruneDups(java.lang.String l) throws StandardException
l
- a list of ids in external form.StandardException
- Oops.public static java.lang.String mkIdList(java.lang.String[] ids)
private static java.lang.String mkIdListAsEntered(java.lang.String[] externalIds)
public static boolean idOnList(java.lang.String id, java.lang.String list) throws StandardException
id
- an id in normal formlist
- a list of ids in external form.StandardException
- oops.public static java.lang.String deleteId(java.lang.String id, java.lang.String list) throws StandardException
id
- an id in normal form (quotes removed, upshifted if regular)list
- a comma separated list of ids in external
form (possibly delmited or not upshifted).StandardException
- oops.public static java.lang.String appendNormalToList(java.lang.String id, java.lang.String list) throws StandardException
StandardException
- oopspublic static java.lang.String parseRoleId(java.lang.String roleName) throws StandardException
roleName
- role identifier to check (SQL form, has possible quoting)StandardException
- normal error policypublic static void checkIdentifierLengthLimit(java.lang.String identifier, int identifier_length_limit) throws StandardException
identifier
- identifier (in case normal form) to checkidentifier_length_limit
- maximum legal lengthStandardException
- normal error policyApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.