Class DBIdentifier
java.lang.Object
org.apache.openjpa.lib.identifier.IdentifierImpl
org.apache.openjpa.jdbc.identifier.DBIdentifier
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Identifier>
,Identifier
- Direct Known Subclasses:
QualifiedDBIdentifier
Encapsulates a database identifier. With a few exceptions, this class is
intended to treated as immutable.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Database identifier types. -
Field Summary
Modifier and TypeFieldDescriptionboolean
static final DBIdentifier
Special NULL indicator for db identifiers. -
Constructor Summary
ModifierConstructorDescriptionprotected
protected
DBIdentifier
(String name, boolean delimit) protected
DBIdentifier
(String name, DBIdentifier.DBIdentifierType type) protected
DBIdentifier
(String name, DBIdentifier.DBIdentifierType type, boolean delimit) -
Method Summary
Modifier and TypeMethodDescriptionstatic DBIdentifier
append
(DBIdentifier name, String str) Returns a new DBIdentifier with the given string appended.clone()
Clones an identifier using deep copy.static DBIdentifier
combine
(DBIdentifier.DBIdentifierType id, String... names) Combines an array of names names using standard combining rules and returns an identifier of the specified type.static DBIdentifier
combine
(DBIdentifier name, String str) Returns a new DBIdentifier with the given string combined using delimiting rules and appropriate separators.int
Comparison operator for identifiers.static boolean
equal
(DBIdentifier name1, DBIdentifier name2) Static equality method for comparing two identifiers.boolean
Equality operation for identifiers.boolean
equalsIgnoreCase
(DBIdentifier name) Equality operator which ignores case.static boolean
equalsIgnoreCase
(DBIdentifier name1, DBIdentifier name2) Static equality operator which ignores case.boolean
Returns whether case is ignored during equality operations.getType()
Get the identifier typeReturns the unqualified name of this identifier.boolean
Returns true if the identifier is delimited.static boolean
isEmpty
(DBIdentifier name) Returns true if the identifier is null or the name is null or empty.boolean
isNull()
Returns true if this object is NULL or has a null name component.static boolean
isNull
(DBIdentifier name) Returns true if the identifier is null.static String
join
(DBIdentifier... names) Joins the list of identifiers using the appropriate delimiters and returns a string based identifier.int
length()
The length of the name, including delimiting characters.static DBIdentifier
newCatalog
(String name) Constructs a new identifier of type Catalog.static DBIdentifier
newCatalog
(String name, boolean delimit) Constructs a new identifier of type Catalog ,optionally delimiting the name.static DBIdentifier
Constructs a new identifier of type Column.static DBIdentifier
Constructs a new identifier of type Column,optionally delimiting the name.static DBIdentifier
newColumnDefinition
(String name) Constructs a new identifier of type Column Definition.static DBIdentifier
newConstant
(String name) Constructs a new identifier of type Constant.static DBIdentifier
newConstraint
(String name) Constructs a new identifier of type Constraint.static DBIdentifier
newConstraint
(String name, boolean delimit) Constructs a new identifier of type Constraint, optionally delimiting the name.static DBIdentifier
newDefault
(String name) Constructs a new identifier of type Default.static DBIdentifier
newForeignKey
(String name) Constructs a new identifier of type ForeignKey.static DBIdentifier
newForeignKey
(String name, boolean delimit) Constructs a new identifier of type ForeignKey, optionally delimiting the name.protected static DBIdentifier
newIdentifier
(String name, DBIdentifier.DBIdentifierType id) Constructs a new identifier with the provided name and typestatic DBIdentifier
newIdentifier
(String name, DBIdentifier.DBIdentifierType id, boolean toUpper) Constructs a new identifier with the provided name an type.protected static DBIdentifier
newIdentifier
(String name, DBIdentifier.DBIdentifierType id, boolean toUpper, boolean delimit) Constructs a new identifier (potentially a compound QualifiedDBIdentifier) with the provided name an type.protected static DBIdentifier
newIdentifier
(String name, DBIdentifier.DBIdentifierType id, boolean toUpper, boolean delimit, boolean ignoreCase) Constructs a new identifier (potentially a compound QualifiedDBIdentifier) with the provided name an type.static DBIdentifier
Constructs a new identifier of type Index.static DBIdentifier
Constructs a new identifier of type Index, optionally delimiting the name.static DBIdentifier
newProcedure
(String name) static DBIdentifier
Constructs a new identifier of type Schema.static DBIdentifier
Constructs a new identifier of type Schema, optionally delimiting the name.static DBIdentifier
newSequence
(String name) Constructs a new identifier of type Sequence.static DBIdentifier
newSequence
(String name, boolean delimit) Constructs a new identifier of type Sequence, optionally delimiting the name.static DBIdentifier
Constructs a new identifier of type Table.static DBIdentifier
Constructs a new identifier of type Table, optionally delimiting the name.static DBIdentifier
preCombine
(DBIdentifier name, String prefix) Returns a new identifier with a combined prefix and name using the standard name concatenation character ('_').static DBIdentifier
removeDelimiters
(DBIdentifier name) Returns a new identifier with delimiters removed.static DBIdentifier
CombineremoveDelimiters(org.apache.openjpa.jdbc.identifier.DBIdentifier)
withtoUpper(org.apache.openjpa.jdbc.identifier.DBIdentifier, boolean)
in order to save allocations and CPU cycles.static DBIdentifier
Returns a new DBIdentifier with Hungarian notation removed.static DBIdentifier
removeLeading
(DBIdentifier name, String leadingStr) Returns a new DBIdentifier with the specified leading string removed.void
setIgnoreCase
(boolean ignoreCase) void
Set the name of the identifier.void
Set the name of the identifier and optionally force delimiting of the identifier.void
setName
(DBIdentifier name) Set the name of this identifier based upon a given identifier.protected void
Set the type of the identifierstatic DBIdentifier[]
split
(String name, DBIdentifier.DBIdentifierType id, String delim) Splits a string delimited by the specified delimiter of a given name type into an array of DBIdentifier objects.static DBIdentifier[]
split
(DBIdentifier.DBIdentifierType resultType, String name) Splits a given DBIdentifier into multiple DBIdentifiers.static DBIdentifier[]
toArray
(String[] columnNames, DBIdentifier.DBIdentifierType id) Converts the provided set of names to an array of identifiers of the provided typestatic DBIdentifier[]
toArray
(String[] names, DBIdentifier.DBIdentifierType id, boolean delimit) Converts the provided set of names to an array of identifiers of the provided type, optionally delimiting the names.static DBIdentifier
toLower
(DBIdentifier name) Returns a new DBIdentifier converted to lower case - if not delimited.static DBIdentifier
toLower
(DBIdentifier name, boolean force) Returns a new DBIdentifier converted to lower case.static String[]
toStringArray
(DBIdentifier[] sNames) Returns a string array of names based upon the provided set of identifiers.static DBIdentifier
toUpper
(DBIdentifier name) Returns a new DBIdentifier converted to upper case - if not delimited.static DBIdentifier
toUpper
(DBIdentifier name, boolean force) Returns a new DBIdentifier converted to upper case.static DBIdentifier
trim
(DBIdentifier name) Returns a new delimiter with leading and trailing spaces removed.static DBIdentifier
trimToNull
(DBIdentifier name) Returns a copy of an identifier with name trimmed to null.static DBIdentifier
truncate
(DBIdentifier name, int length) Returns a new DBIdentifier truncated to lengthMethods inherited from class org.apache.openjpa.lib.identifier.IdentifierImpl
getName, hashCode, isNameDelimited, setNameDelimited, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.openjpa.lib.identifier.Identifier
getName
-
Field Details
-
NULL
Special NULL indicator for db identifiers. -
_ignoreCase
public boolean _ignoreCase
-
-
Constructor Details
-
DBIdentifier
protected DBIdentifier() -
DBIdentifier
-
DBIdentifier
-
DBIdentifier
-
-
Method Details
-
getIgnoreCase
public boolean getIgnoreCase()Returns whether case is ignored during equality operations. -
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase) -
setName
Set the name of the identifier.- Specified by:
setName
in interfaceIdentifier
- Overrides:
setName
in classIdentifierImpl
-
setName
Set the name of this identifier based upon a given identifier. -
setName
Set the name of the identifier and optionally force delimiting of the identifier. -
setType
Set the type of the identifier -
getType
Get the identifier type- Returns:
- the identifier type
-
split
Splits a string delimited by the specified delimiter of a given name type into an array of DBIdentifier objects. Example: COL1|"COL 2"|COL3 delim=| --> DBIdentifier[]{ COL1, "COL 2", COL3 } -
join
Joins the list of identifiers using the appropriate delimiters and returns a string based identifier. -
split
Splits a given DBIdentifier into multiple DBIdentifiers. Uses the base name type and heuristics to determine the types and placement of the resulting components.- Parameters:
name
-
-
isEmpty
Returns true if the identifier is null or the name is null or empty.- Parameters:
name
-
-
isNull
Returns true if the identifier is null.- Parameters:
name
-
-
clone
Clones an identifier using deep copy. -
trimToNull
Returns a copy of an identifier with name trimmed to null.- Parameters:
name
-
-
equals
Equality operation for identifiers. Supports comparison with strings and objects of this type. -
isNull
public boolean isNull()Returns true if this object is NULL or has a null name component. -
compareTo
Comparison operator for identifiers.- Specified by:
compareTo
in interfaceComparable<Identifier>
- Overrides:
compareTo
in classIdentifierImpl
-
toArray
Converts the provided set of names to an array of identifiers of the provided type- Parameters:
columnNames
-id
-
-
toArray
public static DBIdentifier[] toArray(String[] names, DBIdentifier.DBIdentifierType id, boolean delimit) Converts the provided set of names to an array of identifiers of the provided type, optionally delimiting the names.- Parameters:
names
- columnNames or other DB identifier namesid
-
-
toStringArray
Returns a string array of names based upon the provided set of identifiers.- Parameters:
sNames
-
-
newCatalog
Constructs a new identifier of type Catalog. -
newCatalog
Constructs a new identifier of type Catalog ,optionally delimiting the name. -
newTable
Constructs a new identifier of type Table. -
newTable
Constructs a new identifier of type Table, optionally delimiting the name. -
newColumn
Constructs a new identifier of type Column. -
newColumn
Constructs a new identifier of type Column,optionally delimiting the name. -
newSchema
Constructs a new identifier of type Schema. -
newSchema
Constructs a new identifier of type Schema, optionally delimiting the name. -
newIndex
Constructs a new identifier of type Index. -
newIndex
Constructs a new identifier of type Index, optionally delimiting the name. -
newSequence
Constructs a new identifier of type Sequence. -
newSequence
Constructs a new identifier of type Sequence, optionally delimiting the name. -
newForeignKey
Constructs a new identifier of type ForeignKey. -
newForeignKey
Constructs a new identifier of type ForeignKey, optionally delimiting the name. -
newConstraint
Constructs a new identifier of type Constraint. -
newConstraint
Constructs a new identifier of type Constraint, optionally delimiting the name. -
newConstant
Constructs a new identifier of type Constant. -
newColumnDefinition
Constructs a new identifier of type Column Definition. -
newDefault
Constructs a new identifier of type Default. -
newIdentifier
Constructs a new identifier with the provided name and type -
newIdentifier
public static DBIdentifier newIdentifier(String name, DBIdentifier.DBIdentifierType id, boolean toUpper) Constructs a new identifier with the provided name an type. Optionally, converting the name to upper case. -
newIdentifier
protected static DBIdentifier newIdentifier(String name, DBIdentifier.DBIdentifierType id, boolean toUpper, boolean delimit) Constructs a new identifier (potentially a compound QualifiedDBIdentifier) with the provided name an type. Optionally, converting the name to upper case and delimiting it. -
newProcedure
-
newIdentifier
protected static DBIdentifier newIdentifier(String name, DBIdentifier.DBIdentifierType id, boolean toUpper, boolean delimit, boolean ignoreCase) Constructs a new identifier (potentially a compound QualifiedDBIdentifier) with the provided name an type. Optionally, converting the name to upper case and delimiting it. -
equal
Static equality method for comparing two identifiers.- Parameters:
name1
-name2
-
-
truncate
Returns a new DBIdentifier truncated to length- Parameters:
name
-length
-
-
append
Returns a new DBIdentifier with the given string appended.- Parameters:
name
-length
-
-
combine
Returns a new DBIdentifier with the given string combined using delimiting rules and appropriate separators.- Parameters:
name
-length
-
-
toLower
Returns a new DBIdentifier converted to lower case - if not delimited.- Parameters:
name
-
-
toLower
Returns a new DBIdentifier converted to lower case. If delimited, force to lower case using force option.- Parameters:
name
-
-
toUpper
Returns a new DBIdentifier converted to upper case - if not delimited.- Parameters:
name
-
-
toUpper
Returns a new DBIdentifier converted to upper case. If delimited, force to upper case using force option.- Parameters:
name
-
-
removeLeading
Returns a new DBIdentifier with the specified leading string removed.- Parameters:
name
-
-
removeHungarianNotation
Returns a new DBIdentifier with Hungarian notation removed.- Parameters:
name
-
-
equalsIgnoreCase
Equality operator which ignores case. -
equalsIgnoreCase
Static equality operator which ignores case. -
preCombine
Returns a new identifier with a combined prefix and name using the standard name concatenation character ('_'). -
removeDelimiters
Returns a new identifier with delimiters removed. -
removeDelimitersAndMakeUpper
CombineremoveDelimiters(org.apache.openjpa.jdbc.identifier.DBIdentifier)
withtoUpper(org.apache.openjpa.jdbc.identifier.DBIdentifier, boolean)
in order to save allocations and CPU cycles. -
trim
Returns a new delimiter with leading and trailing spaces removed. -
length
public int length()The length of the name, including delimiting characters.- Specified by:
length
in interfaceIdentifier
- Overrides:
length
in classIdentifierImpl
-
isDelimited
public boolean isDelimited()Returns true if the identifier is delimited. -
combine
Combines an array of names names using standard combining rules and returns an identifier of the specified type. -
getUnqualifiedName
Returns the unqualified name of this identifier.
-