com.triactive.jdo.store.sql
Class SchemaName

java.lang.Object
  extended bycom.triactive.jdo.store.sql.SchemaName

public final class SchemaName
extends java.lang.Object

An SQL schema name.

A SchemaName is a name of an SQL schema. Schema names can in turn be qualified with a catalog name. Schema names have the general form:

 [ catalog ] . schema
 

The [catalog] part is represented by a CatalogName object, and the schema part is a plain SqlIdentifier.

Author:
Mike Martin

Constructor Summary
SchemaName(DatabaseAdapter dba, CatalogName catalogName, java.lang.String identifier)
          Constructs a schema name.
SchemaName(DatabaseAdapter dba, java.lang.String identifier)
          Constructs a schema name.
 
Method Summary
 java.lang.String effectiveCatalogName(StoreManager storeMgr)
          Returns the effective catalog name for this object.
 boolean equals(java.lang.Object obj)
          Tests this object for equality with another object.
static SchemaName fromStrings(DatabaseAdapter dba, java.lang.String catalogName, java.lang.String schemaName)
          Constructs a schema name from strings.
 SchemaName fullyQualified(StoreManager storeMgr)
          Returns a new schema name object representing this name fully-qualified (if possible) with catalog.
 CatalogName getCatalogName()
          Returns the catalog name part of this schema name.
 SqlIdentifier getIdentifier()
          Returns the identifier part of this schema name.
 int hashCode()
          Returns a hash code value for this object.
static SchemaName parse(DatabaseAdapter dba, java.lang.String schemaNameStr)
          Parses a schema name from a string.
 java.lang.String toString()
          Returns the SQL string representation of this schema name.
 java.lang.String undelimited()
          Returns the undelimited string representation of this schema name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SchemaName

public SchemaName(DatabaseAdapter dba,
                  java.lang.String identifier)
Constructs a schema name. The identifier will be truncated if necessary to the maximum allowed schema name length. The name will not be catalog-qualified.

Parameters:
dba - a database adapter for the relevant database
identifier - the SQL identifier value as a string

SchemaName

public SchemaName(DatabaseAdapter dba,
                  CatalogName catalogName,
                  java.lang.String identifier)
Constructs a schema name. The identifier will be truncated if necessary to the maximum allowed schema name length.

Parameters:
dba - a database adapter for the relevant database
catalogName - the catalog name part of the schema name, or null if the name is not catalog-qualified
identifier - the SQL identifier value as a string
Method Detail

getCatalogName

public CatalogName getCatalogName()
Returns the catalog name part of this schema name.

Returns:
the catalog name part of this schema name, or null if this name is not catalog-qualified.

getIdentifier

public SqlIdentifier getIdentifier()
Returns the identifier part of this schema name.

Returns:
the identifier part of this schema name

fullyQualified

public SchemaName fullyQualified(StoreManager storeMgr)
Returns a new schema name object representing this name fully-qualified (if possible) with catalog. If this name object has a catalog name part, it is returned. Otherwise, if the given store manager has a default catalog a new SchemaName object is constructed whose catalog name part represents the default catalog. If not, this object is returned as-is.

Parameters:
storeMgr - the store manager to use to determine the default catalog
Returns:
The fully-qualified version of this name.

effectiveCatalogName

public java.lang.String effectiveCatalogName(StoreManager storeMgr)
Returns the effective catalog name for this object. If this object specifically names a catalog, its name is returned as a string. Otherwise the default catalog name from the specified store manager is returned.

Parameters:
storeMgr - the store manager to use to determine the default catalog
Returns:
the effective catalog name, undelimited, or null if the database doesn't support catalogs.

hashCode

public int hashCode()
Returns a hash code value for this object.


equals

public boolean equals(java.lang.Object obj)
Tests this object for equality with another object. Two SchemaName objects are equal if their catalog name and identifier parts are equal.

Parameters:
obj - the object to compare with
Returns:
true if the objects are equal, false otherwise.

toString

public java.lang.String toString()
Returns the SQL string representation of this schema name. The string representation is suitable for use directly in SQL statement text. In particular, any SQL keywords will be quoted.

Returns:
the SQL string representation of this qualified name.

undelimited

public java.lang.String undelimited()
Returns the undelimited string representation of this schema name. This is the same as the toString() representation except that SQL keywords will not be quoted (delimited).

Returns:
the undelimited string representation of this qualified name.

parse

public static SchemaName parse(DatabaseAdapter dba,
                               java.lang.String schemaNameStr)
Parses a schema name from a string. Not yet implemented

Parameters:
dba - a database adapter for the relevant database
schemaNameStr - A schema name in the form "[ catalog ] . schema".
Returns:
a new SchemaName object.

fromStrings

public static SchemaName fromStrings(DatabaseAdapter dba,
                                     java.lang.String catalogName,
                                     java.lang.String schemaName)
Constructs a schema name from strings. This method returns null if schemaName is null, otherwise it returns a new SchemaName object using the SchemaName(DatabaseAdapter, CatalogName, String) constructor.

Parameters:
dba - a database adapter for the relevant database
catalogName - the catalog name, or null
schemaName - the schema name, or null
Returns:
a new SchemaName object, or null if schemaName is null.


Copyright 2001-2007 The TJDO Project All Rights Reserved.