org.jpox.store
Class AbstractIdentifierFactory

java.lang.Object
  extended by org.jpox.store.AbstractIdentifierFactory
All Implemented Interfaces:
IdentifierFactory
Direct Known Subclasses:
AbstractRDBMSIdentifierFactory

public abstract class AbstractIdentifierFactory
extends java.lang.Object
implements IdentifierFactory

Abstract representation of an identifier factory. To be extended to generate the identifiers.

Version:
$Revision: 1.7 $

Field Summary
static int CASE_LOWER
           
static int CASE_PRESERVE
           
static int CASE_UPPER
           
protected  DatastoreAdapter dba
          Adapter for the datastore.
protected  int identifierCase
          Case to use for identifiers.
protected static Localiser LOCALISER
          Localiser for messages.
 
Fields inherited from interface org.jpox.store.IdentifierFactory
CANDIDATE_KEY, COLUMN, FOREIGN_KEY, IDENTIFIER_LOWER_CASE, IDENTIFIER_LOWER_CASE_QUOTED, IDENTIFIER_MIXED_CASE, IDENTIFIER_MIXED_CASE_QUOTED, IDENTIFIER_UPPER_CASE, IDENTIFIER_UPPER_CASE_QUOTED, INDEX, PRIMARY_KEY, SEQUENCE, TABLE
 
Constructor Summary
AbstractIdentifierFactory(DatastoreAdapter dba, java.lang.String requiredCase)
          Constructor.
 
Method Summary
 DatastoreAdapter getDatastoreAdapter()
          Accessor for the datastore adapter that we are creating identifiers for.
 int getIdentifierCase()
          Accessor for the identifier case being used.
protected abstract  int getMaxLengthForIdentifierType(int identifierType)
          Method to return the maximum permitted length of an identifier of the specified type.
 java.lang.String getNameOfIdentifierCase()
          Convenience method to return the name for the identifier case.
protected static java.lang.String truncate(java.lang.String identifier, int length)
          Method to truncate an identifier to fit within the specified identifier length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.IdentifierFactory
getIdentifierInAdapterCase, newDatastoreContainerIdentifier, newDatastoreContainerIdentifier, newDatastoreContainerIdentifier, newDatastoreFieldIdentifier, newDatastoreFieldIdentifier, newDiscriminatorFieldIdentifier, newIdentifier, newIdentifier, newReferenceFieldIdentifier, newVersionFieldIdentifier
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localiser for messages.


CASE_PRESERVE

public static final int CASE_PRESERVE
See Also:
Constant Field Values

CASE_UPPER

public static final int CASE_UPPER
See Also:
Constant Field Values

CASE_LOWER

public static final int CASE_LOWER
See Also:
Constant Field Values

dba

protected DatastoreAdapter dba
Adapter for the datastore.


identifierCase

protected int identifierCase
Case to use for identifiers.

Constructor Detail

AbstractIdentifierFactory

public AbstractIdentifierFactory(DatastoreAdapter dba,
                                 java.lang.String requiredCase)
Constructor.

Parameters:
dba - Datastore adapter
requiredCase - The case the user requires
Method Detail

getDatastoreAdapter

public DatastoreAdapter getDatastoreAdapter()
Accessor for the datastore adapter that we are creating identifiers for.

Specified by:
getDatastoreAdapter in interface IdentifierFactory
Returns:
The datastore adapter

getIdentifierCase

public int getIdentifierCase()
Accessor for the identifier case being used.

Specified by:
getIdentifierCase in interface IdentifierFactory
Returns:
The identifier case

getNameOfIdentifierCase

public java.lang.String getNameOfIdentifierCase()
Convenience method to return the name for the identifier case.

Specified by:
getNameOfIdentifierCase in interface IdentifierFactory
Returns:
Identifier case name

truncate

protected static java.lang.String truncate(java.lang.String identifier,
                                           int length)
Method to truncate an identifier to fit within the specified identifier length. If truncation is necessary will use a 2 char hashcode (at the end) to attempt to create uniqueness.

Parameters:
identifier - The identifier
length - The (max) length to use
Returns:
The truncated identifier.

getMaxLengthForIdentifierType

protected abstract int getMaxLengthForIdentifierType(int identifierType)
Method to return the maximum permitted length of an identifier of the specified type. Returns -1 if the identifier type is not supported.

Parameters:
identifierType - Type of identifier
Returns:
The maximum length


Copyright © -2008 . All Rights Reserved.