Top Description Inners Fields Constructors Methods
org.hsqldb

public final Class HsqlNameManager

extends Object
Class Inheritance
Imports
java.util.concurrent.atomic.AtomicLong, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.StringConverter, org.hsqldb.rights.Grantee

Provides Name Management for SQL objects.

This class now includes the HsqlName class introduced in 1.7.1 and improves auto-naming with multiple databases in the engine.

Methods check user defined names and issue system generated names for SQL objects.

This class does not deal with the type of the SQL object for which it is used.

Some names beginning with SYS_ are reserved for system generated names. These are defined in isReserveName(String name) and created by the makeAutoName(String type) factory method

sysNumber is used to generate system-generated names. It is set to the largest integer encountered in names that use the SYS_xxxxxxx_INTEGER format. As the DDL is processed before any ALTER command, any new system generated name will have a larger integer suffix than all the existing names.

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.7.2
Version
2.7.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Field Summary

Modifier and TypeField and Description
private static final HsqlNameManager.HsqlName[]
private static final String[]
private HsqlNameManager.HsqlName
private AtomicLong
private boolean
private static final HsqlNameManager
pack-priv HsqlNameManager.HsqlName
private AtomicLong

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public static HsqlNameManager.HsqlName
getAutoColumnName(int i)

Column index i is 0 based, returns 1 based numbered column.

public static String
public static String
public HsqlNameManager.HsqlName
public static HsqlNameManager.SimpleName
getSimpleName(String name, boolean isNameQuoted)

public HsqlNameManager.HsqlName
getSubqueryTableName()

Same name string but different objects and serial number

public HsqlNameManager.HsqlName
newAutoName(String prefix, HsqlNameManager.HsqlName schema, HsqlNameManager.HsqlName parent, int type)

Auto names are used for autogenerated indexes or anonymous constraints.

public HsqlNameManager.HsqlName
newAutoName(String prefix, String namepart, HsqlNameManager.HsqlName schema, HsqlNameManager.HsqlName parent, int type)

Auto names are used for autogenerated indexes or anonymous constraints.

public HsqlNameManager.HsqlName
newColumnHsqlName(HsqlNameManager.HsqlName table, String name, boolean isquoted)

public HsqlNameManager.HsqlName
public HsqlNameManager.HsqlName
newConstraintIndexName(HsqlNameManager.HsqlName tableName, HsqlNameManager.HsqlName constName, boolean useConstraint)

public HsqlNameManager.HsqlName
newHsqlName(HsqlNameManager.HsqlName schema, String name, int type)

public HsqlNameManager.HsqlName
newHsqlName(String name, boolean isquoted, int type)

public HsqlNameManager.HsqlName
newHsqlName(HsqlNameManager.HsqlName schema, String name, boolean isquoted, int type)

public HsqlNameManager.HsqlName
newHsqlName(HsqlNameManager.HsqlName schema, String name, boolean isquoted, int type, HsqlNameManager.HsqlName parent)

public static HsqlNameManager.HsqlName
public static HsqlNameManager.HsqlName
newInfoSchemaObjectName(String name, boolean isQuoted, int type)

public static HsqlNameManager.HsqlName
public HsqlNameManager.HsqlName
public static HsqlNameManager.HsqlName
newSystemObjectName(String name, int type)

public void
setSqlRegularNames(boolean value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoColumnNamesback to summary
private static final HsqlNameManager.HsqlName[] autoColumnNames
autoNoNameColumnNamesback to summary
private static final String[] autoNoNameColumnNames
catalogNameback to summary
private HsqlNameManager.HsqlName catalogName
serialNumberback to summary
private AtomicLong serialNumber
sqlRegularNamesback to summary
private boolean sqlRegularNames
staticManagerback to summary
private static final HsqlNameManager staticManager
subqueryTableNameback to summary
pack-priv HsqlNameManager.HsqlName subqueryTableName
sysNumberback to summary
private AtomicLong sysNumber

Constructor Detail

HsqlNameManagerback to summary
public HsqlNameManager()
HsqlNameManagerback to summary
public HsqlNameManager(Database database)

Method Detail

getAutoColumnNameback to summary
public static HsqlNameManager.HsqlName getAutoColumnName(int i)

Column index i is 0 based, returns 1 based numbered column.

getAutoNoNameColumnStringback to summary
public static String getAutoNoNameColumnString(int i)
getAutoSavepointNameStringback to summary
public static String getAutoSavepointNameString(long i, int j)
getCatalogNameback to summary
public HsqlNameManager.HsqlName getCatalogName()
getSimpleNameback to summary
public static HsqlNameManager.SimpleName getSimpleName(String name, boolean isNameQuoted)
getSubqueryTableNameback to summary
public HsqlNameManager.HsqlName getSubqueryTableName()

Same name string but different objects and serial number

newAutoNameback to summary
public HsqlNameManager.HsqlName newAutoName(String prefix, HsqlNameManager.HsqlName schema, HsqlNameManager.HsqlName parent, int type)

Auto names are used for autogenerated indexes or anonymous constraints.

newAutoNameback to summary
public HsqlNameManager.HsqlName newAutoName(String prefix, String namepart, HsqlNameManager.HsqlName schema, HsqlNameManager.HsqlName parent, int type)

Auto names are used for autogenerated indexes or anonymous constraints.

newColumnHsqlNameback to summary
public HsqlNameManager.HsqlName newColumnHsqlName(HsqlNameManager.HsqlName table, String name, boolean isquoted)
newColumnSchemaHsqlNameback to summary
public HsqlNameManager.HsqlName newColumnSchemaHsqlName(HsqlNameManager.HsqlName table, HsqlNameManager.SimpleName name)
newConstraintIndexNameback to summary
public HsqlNameManager.HsqlName newConstraintIndexName(HsqlNameManager.HsqlName tableName, HsqlNameManager.HsqlName constName, boolean useConstraint)
newHsqlNameback to summary
public HsqlNameManager.HsqlName newHsqlName(HsqlNameManager.HsqlName schema, String name, int type)
newHsqlNameback to summary
public HsqlNameManager.HsqlName newHsqlName(String name, boolean isquoted, int type)
newHsqlNameback to summary
public HsqlNameManager.HsqlName newHsqlName(HsqlNameManager.HsqlName schema, String name, boolean isquoted, int type)
newHsqlNameback to summary
public HsqlNameManager.HsqlName newHsqlName(HsqlNameManager.HsqlName schema, String name, boolean isquoted, int type, HsqlNameManager.HsqlName parent)
newInfoSchemaColumnNameback to summary
public static HsqlNameManager.HsqlName newInfoSchemaColumnName(String name, HsqlNameManager.HsqlName table)
newInfoSchemaObjectNameback to summary
public static HsqlNameManager.HsqlName newInfoSchemaObjectName(String name, boolean isQuoted, int type)
newInfoSchemaTableNameback to summary
public static HsqlNameManager.HsqlName newInfoSchemaTableName(String name)
newSpecificRoutineNameback to summary
public HsqlNameManager.HsqlName newSpecificRoutineName(HsqlNameManager.HsqlName name)
newSystemObjectNameback to summary
public static HsqlNameManager.HsqlName newSystemObjectName(String name, int type)
setSqlRegularNamesback to summary
public void setSqlRegularNames(boolean value)
org.hsqldb back to summary

public final Class HsqlNameManager.HsqlName

extends SimpleName
Class Inheritance

Field Summary

Modifier and TypeField and Description
public String
pack-priv static HsqlNameManager.HsqlName[]
pack-priv HsqlNameManager
public Grantee
public HsqlNameManager.HsqlName
public HsqlNameManager.HsqlName
private final long
public String
pack-priv static final String[]
sysPrefixes

"SYS_IDX_" is used for auto-indexes on referring FK columns or unique constraints.

public final int
Inherited from org.hsqldb.HsqlNameManager.SimpleName:
isNameQuotedname

Constructor Summary

AccessConstructor and Description
private
HsqlName(HsqlNameManager man, int type)

private
HsqlName(HsqlNameManager man, String name, boolean isquoted, int type)

private
HsqlName(HsqlNameManager man, String name, int type, boolean isQuoted)

for auto names and system-defined names

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object other)

Overrides org.hsqldb.HsqlNameManager.SimpleName.equals.

Indicates whether some other object is "equal to" this one.

pack-priv String
public String
public long
public String
public int
hashCode()

Overrides org.hsqldb.HsqlNameManager.SimpleName.hashCode.

hash code for this object is based on its unique serial number.

pack-priv static boolean
isRegularIdentifier(String name)

Returns true if the identifier consists of all uppercase letters digits and underscore, beginning with a letter and is not in the keyword list.

pack-priv static boolean
pack-priv boolean
public void
public void
rename(String name, boolean isquoted)

public void
pack-priv static int
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.hsqldb.HsqlNameManager.SimpleName:
getNameString

Field Detail

commentback to summary
public String comment
emptyArrayback to summary
pack-priv static HsqlNameManager.HsqlName[] emptyArray
managerback to summary
pack-priv HsqlNameManager manager
ownerback to summary
public Grantee owner
parentback to summary
public HsqlNameManager.HsqlName parent
schemaback to summary
public HsqlNameManager.HsqlName schema
serialNumberback to summary
private final long serialNumber
statementNameback to summary
public String statementName
sysPrefixesback to summary
pack-priv static final String[] sysPrefixes

"SYS_IDX_" is used for auto-indexes on referring FK columns or unique constraints. "SYS_PK_" is for the primary key constraints "SYS_CT_" is for unique and check constraints "SYS_REF_" is for FK constraints in referenced tables "SYS_FK_" is for FK constraints in referencing tables

typeback to summary
public final int type

Constructor Detail

HsqlNameback to summary
private HsqlName(HsqlNameManager man, int type)
HsqlNameback to summary
private HsqlName(HsqlNameManager man, String name, boolean isquoted, int type)
HsqlNameback to summary
private HsqlName(HsqlNameManager man, String name, int type, boolean isQuoted)

for auto names and system-defined names

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides org.hsqldb.HsqlNameManager.SimpleName.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

getCommentSQLback to summary
pack-priv String getCommentSQL(String typeName)
getSchemaQualifiedStatementNameback to summary
public String getSchemaQualifiedStatementName()
getSerialNumberback to summary
public long getSerialNumber()
getStatementNameback to summary
public String getStatementName()

Overrides org.hsqldb.HsqlNameManager.SimpleName.getStatementName.

hashCodeback to summary
public int hashCode()

Overrides org.hsqldb.HsqlNameManager.SimpleName.hashCode.

hash code for this object is based on its unique serial number.

isRegularIdentifierback to summary
pack-priv static boolean isRegularIdentifier(String name)

Returns true if the identifier consists of all uppercase letters digits and underscore, beginning with a letter and is not in the keyword list.

isReservedNameback to summary
pack-priv static boolean isReservedName(String name)
isReservedNameback to summary
pack-priv boolean isReservedName()
renameback to summary
public void rename(HsqlNameManager.HsqlName name)
renameback to summary
public void rename(String name, boolean isquoted)
setSchemaIfNullback to summary
public void setSchemaIfNull(HsqlNameManager.HsqlName schema)
sysPrefixLengthback to summary
pack-priv static int sysPrefixLength(String name)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

org.hsqldb back to summary

public Class HsqlNameManager.SimpleName

extends Object
Class Inheritance
Known Direct Subclasses
org.hsqldb.HsqlNameManager.HsqlName

Field Summary

Modifier and TypeField and Description
public boolean
public String

Constructor Summary

AccessConstructor and Description
private
private
SimpleName(String name, boolean isNameQuoted)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object other)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public String
public String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

isNameQuotedback to summary
public boolean isNameQuoted
nameback to summary
public String name

Constructor Detail

SimpleNameback to summary
private SimpleName()
SimpleNameback to summary
private SimpleName(String name, boolean isNameQuoted)

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

getNameStringback to summary
public String getNameString()
getStatementNameback to summary
public String getStatementName()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.