Class DBIdentifier
- java.lang.Object
-
- org.apache.openjpa.lib.identifier.IdentifierImpl
-
- org.apache.openjpa.jdbc.identifier.DBIdentifier
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Identifier>,Identifier
- Direct Known Subclasses:
QualifiedDBIdentifier
public class DBIdentifier extends IdentifierImpl implements java.lang.Cloneable, Identifier, java.io.Serializable
Encapsulates a database identifier. With a few exceptions, this class is intended to treated as immutable.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDBIdentifier.DBIdentifierTypeDatabase identifier types.
-
Field Summary
Fields Modifier and Type Field Description boolean_ignoreCasestatic DBIdentifierNULLSpecial NULL indicator for db identifiers.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDBIdentifier()protectedDBIdentifier(java.lang.String name, boolean delimit)protectedDBIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType type)protectedDBIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType type, boolean delimit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DBIdentifierappend(DBIdentifier name, java.lang.String str)Returns a new DBIdentifier with the given string appended.DBIdentifierclone()Clones an identifier using deep copy.static DBIdentifiercombine(DBIdentifier.DBIdentifierType id, java.lang.String... names)Combines an array of names names using standard combining rules and returns an identifier of the specified type.static DBIdentifiercombine(DBIdentifier name, java.lang.String str)Returns a new DBIdentifier with the given string combined using delimiting rules and appropriate separators.intcompareTo(Identifier o)Comparison operator for identifiers.static booleanequal(DBIdentifier name1, DBIdentifier name2)Static equality method for comparing two identifiers.booleanequals(java.lang.Object obj)Equality operation for identifiers.booleanequalsIgnoreCase(DBIdentifier name)Equality operator which ignores case.static booleanequalsIgnoreCase(DBIdentifier name1, DBIdentifier name2)Static equality operator which ignores case.booleangetIgnoreCase()Returns whether case is ignored during equality operations.DBIdentifier.DBIdentifierTypegetType()Get the identifier typeDBIdentifiergetUnqualifiedName()Returns the unqualified name of this identifier.booleanisDelimited()Returns true if the identifier is delimited.static booleanisEmpty(DBIdentifier name)Returns true if the identifier is null or the name is null or empty.booleanisNull()Returns true if this object is NULL or has a null name component.static booleanisNull(DBIdentifier name)Returns true if the identifier is null.static java.lang.Stringjoin(DBIdentifier... names)Joins the list of identifiers using the appropriate delimiters and returns a string based identifier.intlength()The length of the name, including delimiting characters.static DBIdentifiernewCatalog(java.lang.String name)Constructs a new identifier of type Catalog.static DBIdentifiernewCatalog(java.lang.String name, boolean delimit)Constructs a new identifier of type Catalog ,optionally delimiting the name.static DBIdentifiernewColumn(java.lang.String name)Constructs a new identifier of type Column.static DBIdentifiernewColumn(java.lang.String name, boolean delimit)Constructs a new identifier of type Column,optionally delimiting the name.static DBIdentifiernewColumnDefinition(java.lang.String name)Constructs a new identifier of type Column Definition.static DBIdentifiernewConstant(java.lang.String name)Constructs a new identifier of type Constant.static DBIdentifiernewConstraint(java.lang.String name)Constructs a new identifier of type Constraint.static DBIdentifiernewConstraint(java.lang.String name, boolean delimit)Constructs a new identifier of type Constraint, optionally delimiting the name.static DBIdentifiernewDefault(java.lang.String name)Constructs a new identifier of type Default.static DBIdentifiernewForeignKey(java.lang.String name)Constructs a new identifier of type ForeignKey.static DBIdentifiernewForeignKey(java.lang.String name, boolean delimit)Constructs a new identifier of type ForeignKey, optionally delimiting the name.protected static DBIdentifiernewIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType id)Constructs a new identifier with the provided name and typestatic DBIdentifiernewIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType id, boolean toUpper)Constructs a new identifier with the provided name an type.protected static DBIdentifiernewIdentifier(java.lang.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 DBIdentifiernewIdentifier(java.lang.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 DBIdentifiernewIndex(java.lang.String name)Constructs a new identifier of type Index.static DBIdentifiernewIndex(java.lang.String name, boolean delimit)Constructs a new identifier of type Index, optionally delimiting the name.static DBIdentifiernewProcedure(java.lang.String name)static DBIdentifiernewSchema(java.lang.String name)Constructs a new identifier of type Schema.static DBIdentifiernewSchema(java.lang.String name, boolean delimit)Constructs a new identifier of type Schema, optionally delimiting the name.static DBIdentifiernewSequence(java.lang.String name)Constructs a new identifier of type Sequence.static DBIdentifiernewSequence(java.lang.String name, boolean delimit)Constructs a new identifier of type Sequence, optionally delimiting the name.static DBIdentifiernewTable(java.lang.String name)Constructs a new identifier of type Table.static DBIdentifiernewTable(java.lang.String name, boolean delimit)Constructs a new identifier of type Table, optionally delimiting the name.static DBIdentifierpreCombine(DBIdentifier name, java.lang.String prefix)Returns a new identifier with a combined prefix and name using the standard name concatenation character ('_').static DBIdentifierremoveDelimiters(DBIdentifier name)Returns a new identifier with delimiters removed.static DBIdentifierremoveDelimitersAndMakeUpper(DBIdentifier name)CombineremoveDelimiters(org.apache.openjpa.jdbc.identifier.DBIdentifier)withtoUpper(org.apache.openjpa.jdbc.identifier.DBIdentifier, boolean)in order to save allocations and CPU cycles.static DBIdentifierremoveHungarianNotation(DBIdentifier name)Returns a new DBIdentifier with Hungarian notation removed.static DBIdentifierremoveLeading(DBIdentifier name, java.lang.String leadingStr)Returns a new DBIdentifier with the specified leading string removed.voidsetIgnoreCase(boolean ignoreCase)voidsetName(java.lang.String name)Set the name of the identifier.voidsetName(java.lang.String name, boolean delimit)Set the name of the identifier and optionally force delimiting of the identifier.voidsetName(DBIdentifier name)Set the name of this identifier based upon a given identifier.protected voidsetType(DBIdentifier.DBIdentifierType type)Set the type of the identifierstatic DBIdentifier[]split(java.lang.String name, DBIdentifier.DBIdentifierType id, java.lang.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, java.lang.String name)Splits a given DBIdentifier into multiple DBIdentifiers.static DBIdentifier[]toArray(java.lang.String[] columnNames, DBIdentifier.DBIdentifierType id)Converts the provided set of names to an array of identifiers of the provided typestatic DBIdentifier[]toArray(java.lang.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 DBIdentifiertoLower(DBIdentifier name)Returns a new DBIdentifier converted to lower case - if not delimited.static DBIdentifiertoLower(DBIdentifier name, boolean force)Returns a new DBIdentifier converted to lower case.static java.lang.String[]toStringArray(DBIdentifier[] sNames)Returns a string array of names based upon the provided set of identifiers.static DBIdentifiertoUpper(DBIdentifier name)Returns a new DBIdentifier converted to upper case - if not delimited.static DBIdentifiertoUpper(DBIdentifier name, boolean force)Returns a new DBIdentifier converted to upper case.static DBIdentifiertrim(DBIdentifier name)Returns a new delimiter with leading and trailing spaces removed.static DBIdentifiertrimToNull(DBIdentifier name)Returns a copy of an identifier with name trimmed to null.static DBIdentifiertruncate(DBIdentifier name, int length)Returns a new DBIdentifier truncated to length-
Methods 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 Detail
-
NULL
public static final DBIdentifier NULL
Special NULL indicator for db identifiers.
-
_ignoreCase
public boolean _ignoreCase
-
-
Constructor Detail
-
DBIdentifier
protected DBIdentifier()
-
DBIdentifier
protected DBIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType type)
-
DBIdentifier
protected DBIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType type, boolean delimit)
-
DBIdentifier
protected DBIdentifier(java.lang.String name, boolean delimit)
-
-
Method Detail
-
getIgnoreCase
public boolean getIgnoreCase()
Returns whether case is ignored during equality operations.
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
-
setName
public void setName(java.lang.String name)
Set the name of the identifier.- Specified by:
setNamein interfaceIdentifier- Overrides:
setNamein classIdentifierImpl
-
setName
public void setName(DBIdentifier name)
Set the name of this identifier based upon a given identifier.
-
setName
public void setName(java.lang.String name, boolean delimit)Set the name of the identifier and optionally force delimiting of the identifier.
-
setType
protected void setType(DBIdentifier.DBIdentifierType type)
Set the type of the identifier
-
getType
public DBIdentifier.DBIdentifierType getType()
Get the identifier type- Returns:
- the identifier type
-
split
public static DBIdentifier[] split(java.lang.String name, DBIdentifier.DBIdentifierType id, java.lang.String delim)
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
public static java.lang.String join(DBIdentifier... names)
Joins the list of identifiers using the appropriate delimiters and returns a string based identifier.
-
split
public static DBIdentifier[] split(DBIdentifier.DBIdentifierType resultType, java.lang.String name)
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
public static boolean isEmpty(DBIdentifier name)
Returns true if the identifier is null or the name is null or empty.- Parameters:
name-
-
isNull
public static boolean isNull(DBIdentifier name)
Returns true if the identifier is null.- Parameters:
name-
-
clone
public DBIdentifier clone()
Clones an identifier using deep copy.- Overrides:
clonein classjava.lang.Object
-
trimToNull
public static DBIdentifier trimToNull(DBIdentifier name)
Returns a copy of an identifier with name trimmed to null.- Parameters:
name-
-
equals
public boolean equals(java.lang.Object obj)
Equality operation for identifiers. Supports comparison with strings and objects of this type.- Overrides:
equalsin classjava.lang.Object
-
isNull
public boolean isNull()
Returns true if this object is NULL or has a null name component.
-
compareTo
public int compareTo(Identifier o)
Comparison operator for identifiers.- Specified by:
compareToin interfacejava.lang.Comparable<Identifier>- Overrides:
compareToin classIdentifierImpl
-
toArray
public static DBIdentifier[] toArray(java.lang.String[] columnNames, DBIdentifier.DBIdentifierType id)
Converts the provided set of names to an array of identifiers of the provided type- Parameters:
columnNames-id-
-
toArray
public static DBIdentifier[] toArray(java.lang.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
public static java.lang.String[] toStringArray(DBIdentifier[] sNames)
Returns a string array of names based upon the provided set of identifiers.- Parameters:
sNames-
-
newCatalog
public static DBIdentifier newCatalog(java.lang.String name)
Constructs a new identifier of type Catalog.
-
newCatalog
public static DBIdentifier newCatalog(java.lang.String name, boolean delimit)
Constructs a new identifier of type Catalog ,optionally delimiting the name.
-
newTable
public static DBIdentifier newTable(java.lang.String name)
Constructs a new identifier of type Table.
-
newTable
public static DBIdentifier newTable(java.lang.String name, boolean delimit)
Constructs a new identifier of type Table, optionally delimiting the name.
-
newColumn
public static DBIdentifier newColumn(java.lang.String name)
Constructs a new identifier of type Column.
-
newColumn
public static DBIdentifier newColumn(java.lang.String name, boolean delimit)
Constructs a new identifier of type Column,optionally delimiting the name.
-
newSchema
public static DBIdentifier newSchema(java.lang.String name)
Constructs a new identifier of type Schema.
-
newSchema
public static DBIdentifier newSchema(java.lang.String name, boolean delimit)
Constructs a new identifier of type Schema, optionally delimiting the name.
-
newIndex
public static DBIdentifier newIndex(java.lang.String name)
Constructs a new identifier of type Index.
-
newIndex
public static DBIdentifier newIndex(java.lang.String name, boolean delimit)
Constructs a new identifier of type Index, optionally delimiting the name.
-
newSequence
public static DBIdentifier newSequence(java.lang.String name)
Constructs a new identifier of type Sequence.
-
newSequence
public static DBIdentifier newSequence(java.lang.String name, boolean delimit)
Constructs a new identifier of type Sequence, optionally delimiting the name.
-
newForeignKey
public static DBIdentifier newForeignKey(java.lang.String name)
Constructs a new identifier of type ForeignKey.
-
newForeignKey
public static DBIdentifier newForeignKey(java.lang.String name, boolean delimit)
Constructs a new identifier of type ForeignKey, optionally delimiting the name.
-
newConstraint
public static DBIdentifier newConstraint(java.lang.String name)
Constructs a new identifier of type Constraint.
-
newConstraint
public static DBIdentifier newConstraint(java.lang.String name, boolean delimit)
Constructs a new identifier of type Constraint, optionally delimiting the name.
-
newConstant
public static DBIdentifier newConstant(java.lang.String name)
Constructs a new identifier of type Constant.
-
newColumnDefinition
public static DBIdentifier newColumnDefinition(java.lang.String name)
Constructs a new identifier of type Column Definition.
-
newDefault
public static DBIdentifier newDefault(java.lang.String name)
Constructs a new identifier of type Default.
-
newIdentifier
protected static DBIdentifier newIdentifier(java.lang.String name, DBIdentifier.DBIdentifierType id)
Constructs a new identifier with the provided name and type
-
newIdentifier
public static DBIdentifier newIdentifier(java.lang.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(java.lang.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
public static DBIdentifier newProcedure(java.lang.String name)
-
newIdentifier
protected static DBIdentifier newIdentifier(java.lang.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
public static boolean equal(DBIdentifier name1, DBIdentifier name2)
Static equality method for comparing two identifiers.- Parameters:
name1-name2-
-
truncate
public static DBIdentifier truncate(DBIdentifier name, int length)
Returns a new DBIdentifier truncated to length- Parameters:
name-length-
-
append
public static DBIdentifier append(DBIdentifier name, java.lang.String str)
Returns a new DBIdentifier with the given string appended.- Parameters:
name-length-
-
combine
public static DBIdentifier combine(DBIdentifier name, java.lang.String str)
Returns a new DBIdentifier with the given string combined using delimiting rules and appropriate separators.- Parameters:
name-length-
-
toLower
public static DBIdentifier toLower(DBIdentifier name)
Returns a new DBIdentifier converted to lower case - if not delimited.- Parameters:
name-
-
toLower
public static DBIdentifier toLower(DBIdentifier name, boolean force)
Returns a new DBIdentifier converted to lower case. If delimited, force to lower case using force option.- Parameters:
name-
-
toUpper
public static DBIdentifier toUpper(DBIdentifier name)
Returns a new DBIdentifier converted to upper case - if not delimited.- Parameters:
name-
-
toUpper
public static DBIdentifier toUpper(DBIdentifier name, boolean force)
Returns a new DBIdentifier converted to upper case. If delimited, force to upper case using force option.- Parameters:
name-
-
removeLeading
public static DBIdentifier removeLeading(DBIdentifier name, java.lang.String leadingStr)
Returns a new DBIdentifier with the specified leading string removed.- Parameters:
name-
-
removeHungarianNotation
public static DBIdentifier removeHungarianNotation(DBIdentifier name)
Returns a new DBIdentifier with Hungarian notation removed.- Parameters:
name-
-
equalsIgnoreCase
public boolean equalsIgnoreCase(DBIdentifier name)
Equality operator which ignores case.
-
equalsIgnoreCase
public static boolean equalsIgnoreCase(DBIdentifier name1, DBIdentifier name2)
Static equality operator which ignores case.
-
preCombine
public static DBIdentifier preCombine(DBIdentifier name, java.lang.String prefix)
Returns a new identifier with a combined prefix and name using the standard name concatenation character ('_').
-
removeDelimiters
public static DBIdentifier removeDelimiters(DBIdentifier name)
Returns a new identifier with delimiters removed.
-
removeDelimitersAndMakeUpper
public static DBIdentifier removeDelimitersAndMakeUpper(DBIdentifier name)
CombineremoveDelimiters(org.apache.openjpa.jdbc.identifier.DBIdentifier)withtoUpper(org.apache.openjpa.jdbc.identifier.DBIdentifier, boolean)in order to save allocations and CPU cycles.
-
trim
public static DBIdentifier trim(DBIdentifier name)
Returns a new delimiter with leading and trailing spaces removed.
-
length
public int length()
The length of the name, including delimiting characters.- Specified by:
lengthin interfaceIdentifier- Overrides:
lengthin classIdentifierImpl
-
isDelimited
public boolean isDelimited()
Returns true if the identifier is delimited.
-
combine
public static DBIdentifier combine(DBIdentifier.DBIdentifierType id, java.lang.String... names)
Combines an array of names names using standard combining rules and returns an identifier of the specified type.
-
getUnqualifiedName
public DBIdentifier getUnqualifiedName()
Returns the unqualified name of this identifier.
-
-