org.jpox.store
Class AbstractDatastoreAdapter

java.lang.Object
  extended byorg.jpox.store.AbstractDatastoreAdapter
All Implemented Interfaces:
DatastoreAdapter, ExpressionConversionAdapter, ExpressionLogicSetAdapter, ExpressionMethodAdapter, ExpressionOperatorAdapter, ExpressionPatternAdapter, ExpressionSupportedFeaturesAdapter
Direct Known Subclasses:
DatabaseAdapter

public abstract class AbstractDatastoreAdapter
extends java.lang.Object
implements DatastoreAdapter

Generalised datastore representation. Each datastore is assumed to have a "name", and a "version" (of the form major.minor.revision) and will store "identifiers". In addition, each field will have a Mapping to the datastore

This will typically be extended to provide e.g RDBMS connection using JDBC, or XML file connection using a DOM parser.

Version:
$Revision: 1.23 $

Field Summary
protected  int datastoreMajorVersion
          The major version number of the underlying datastore.
protected  int datastoreMinorVersion
          The minor version number of the underlying datastore.
protected  java.lang.String datastoreProductName
          The product name of the underlying datastore.
protected  java.lang.String datastoreProductVersion
          The version number of the underlying datastore as a string.
protected  int datastoreRevisionVersion
          The revision version number of the underlying datastore.
protected  Dictionary dictionary
          The dictionary to use for identifiers etc.
protected  int identifierCase
          Case that the identifiers will be stored in.
protected  java.lang.String identifierQuoteString
          The String used to quote identifiers.
protected static Localiser LOCALISER_BASE
           
protected  MappingManager mappingManager
          Manager for the mapping between Java and datastore types.
protected  java.util.HashSet reservedKeywords
          The set of reserved keywords for this datastore.
 
Fields inherited from interface org.jpox.store.DatastoreAdapter
IDENTIFIER_LOWER_CASE, IDENTIFIER_LOWER_CASE_QUOTED, IDENTIFIER_MIXED_CASE, IDENTIFIER_MIXED_CASE_QUOTED, IDENTIFIER_UPPER_CASE, IDENTIFIER_UPPER_CASE_QUOTED
 
Constructor Summary
AbstractDatastoreAdapter(Dictionary dictionary)
          Constructor.
 
Method Summary
 long getAdapterTime(java.sql.Timestamp time)
          Utility to return the adapter time in case there are rounding issues with millisecs etc.
 int getDatastoreMajorVersion()
          Accessor for the datastore major version number.
 int getDatastoreMinorVersion()
          Accessor for the datastore minor version number.
 Dictionary getDictionary()
          Accessor for the Dictionary.
 int getIdentifierCase()
          Accessor for the case that the identifiers will be specified in
 java.lang.String getIdentifierInAdapterCase(java.lang.String identifier)
          Convenience method to convert the passed identifier into an identifier in the correct case, and with any required quoting.
 java.lang.String getIdentifierQuoteString()
          Accessor for an identifier quote string.
 JavaTypeMapping getMapping(java.lang.Class c, boolean serialised, boolean embedded, StoreManager storeMgr, ClassLoaderResolver clr)
          Convenience accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(java.lang.Class c, boolean serialised, boolean embedded, java.lang.String fieldName, StoreManager storeMgr)
          Convenience accessor for the mapping for the specified class.
protected  JavaTypeMapping getMapping(java.lang.Class c, ScalarExpression expr)
          Convenience accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(java.lang.Class c, StoreManager storeMgr)
          Convenience accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(java.lang.Class c, StoreManager storeMgr, ClassLoaderResolver clr)
          Convenience accessor for the mapping for the specified class.
 MappingManager getMappingManager()
          Acessor for the MappingManager
protected  int getMiliseconds(long nanos)
           
protected abstract  MappingManager getNewMappingManager()
          Accessor for a new mapping manager.
protected  long getTime(long time, long nanos)
           
 java.lang.String getVendorID()
          Accessor for the Vendor ID for this datastore.
 boolean isReservedKeyword(java.lang.String word)
          Method to check if a word is reserved for this datastore.
 void loadDatastoreMapping(PluginManager mgr, ClassLoaderResolver clr)
          Load the datastore mapping declared as Plug-in
 NumericExpression modOperator(ScalarExpression operand1, ScalarExpression operand2)
          Method to generate a modulus expression.
abstract  QueryExpression newQueryStatement(DatastoreContainerObject container, ClassLoaderResolver clr)
          Accessor for a new query statement.
abstract  QueryExpression newQueryStatement(DatastoreContainerObject container, DatastoreIdentifier rangeVar, ClassLoaderResolver clr)
          Accessor for a new query statement.
 boolean supportsAutoIncrementFields()
          Accessor for whether autoincrementing fields are supported.
 boolean supportsQueryFetchSizeLowerThanOne()
          Whether the datastore supports setting a fetch size lower than one.
 boolean supportsSequences()
          Accessor for whether sequences are supported.
 java.lang.String toString()
          Method to return this object as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jpox.store.DatastoreAdapter
closeConnection, getConnection, initialiseDatastore, isAutoIncrementingDataType
 
Methods inherited from interface org.jpox.store.expression.ExpressionConversionAdapter
toNumericExpression, toStringExpression, toStringExpression
 
Methods inherited from interface org.jpox.store.expression.ExpressionOperatorAdapter
concatOperator, getOperatorConcat
 
Methods inherited from interface org.jpox.store.expression.ExpressionMethodAdapter
absMethod, acosMethod, asinMethod, atanMethod, ceilMethod, cosMethod, endsWithMethod, expMethod, floorMethod, getDayMethod, getHourMethod, getMinuteMethod, getMonthMethod, getSecondMethod, getYearMethod, indexOfMethod, lengthMethod, logMethod, sinMethod, sqrtMethod, startsWithMethod, substringMethod, substringMethod, tanMethod, trimMethod
 
Methods inherited from interface org.jpox.store.expression.ExpressionSupportedFeaturesAdapter
supportsBooleanComparison, supportsEscapeExpressionInLikePredicate
 
Methods inherited from interface org.jpox.store.expression.ExpressionPatternAdapter
getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters
 
Methods inherited from interface org.jpox.store.expression.ExpressionLogicSetAdapter
cartersianProduct
 

Field Detail

LOCALISER_BASE

protected static final Localiser LOCALISER_BASE

reservedKeywords

protected final java.util.HashSet reservedKeywords
The set of reserved keywords for this datastore.


datastoreProductName

protected java.lang.String datastoreProductName
The product name of the underlying datastore.


datastoreProductVersion

protected java.lang.String datastoreProductVersion
The version number of the underlying datastore as a string.


datastoreMajorVersion

protected int datastoreMajorVersion
The major version number of the underlying datastore.


datastoreMinorVersion

protected int datastoreMinorVersion
The minor version number of the underlying datastore.


datastoreRevisionVersion

protected int datastoreRevisionVersion
The revision version number of the underlying datastore.


identifierCase

protected int identifierCase
Case that the identifiers will be stored in.


identifierQuoteString

protected java.lang.String identifierQuoteString
The String used to quote identifiers.


dictionary

protected Dictionary dictionary
The dictionary to use for identifiers etc.


mappingManager

protected MappingManager mappingManager
Manager for the mapping between Java and datastore types.

Constructor Detail

AbstractDatastoreAdapter

public AbstractDatastoreAdapter(Dictionary dictionary)
Constructor.

Parameters:
dictionary - The dictionary to use for identifiers
Method Detail

getNewMappingManager

protected abstract MappingManager getNewMappingManager()
Accessor for a new mapping manager. Must be implemented by subclasses.

Returns:
The new mapping manager

loadDatastoreMapping

public void loadDatastoreMapping(PluginManager mgr,
                                 ClassLoaderResolver clr)
Load the datastore mapping declared as Plug-in

Specified by:
loadDatastoreMapping in interface DatastoreAdapter
Parameters:
mgr - the PluginManager
clr - the ClassLoaderResolver

getMappingManager

public MappingManager getMappingManager()
Acessor for the MappingManager

Specified by:
getMappingManager in interface DatastoreAdapter
Returns:
the MappingManager

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  StoreManager storeMgr)
Convenience accessor for the mapping for the specified class. Provides a wrapper to the method on the MappingManager.

Specified by:
getMapping in interface DatastoreAdapter
Parameters:
c - Java type
storeMgr - the StoreManager
Returns:
The mapping for the class.

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  boolean serialised,
                                  boolean embedded,
                                  java.lang.String fieldName,
                                  StoreManager storeMgr)
Convenience accessor for the mapping for the specified class. Provides a wrapper to the method on the MappingManager.

Specified by:
getMapping in interface DatastoreAdapter
Parameters:
c - Java type
serialised - Whether the type is serialised
embedded - Whether the type is embedded
fieldName - Name of field (for logging only).
storeMgr - the StoreManager
Returns:
The mapping for the class.

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  StoreManager storeMgr,
                                  ClassLoaderResolver clr)
Convenience accessor for the mapping for the specified class. Provides a wrapper to the method on the MappingManager.

Specified by:
getMapping in interface DatastoreAdapter
Parameters:
c - Java type
storeMgr - The Store manager
clr - ClassLoader resolver
Returns:
The mapping for the class.

getMapping

protected final JavaTypeMapping getMapping(java.lang.Class c,
                                           ScalarExpression expr)
Convenience accessor for the mapping for the specified class. Provides a wrapper to the method on the MappingManager.

Parameters:
c - Java type
expr - the ScalarExpression
Returns:
The mapping for the class.

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  boolean serialised,
                                  boolean embedded,
                                  StoreManager storeMgr,
                                  ClassLoaderResolver clr)
Convenience accessor for the mapping for the specified class. Provides a wrapper to the method on the MappingManager.

Specified by:
getMapping in interface DatastoreAdapter
Parameters:
c - Java type
serialised - Whether the type is serialised
embedded - Whether the type is embedded
storeMgr - The Store manager
clr - ClassLoader resolver
Returns:
The mapping for the class.

getVendorID

public java.lang.String getVendorID()
Description copied from interface: DatastoreAdapter
Accessor for the Vendor ID for this datastore.

Specified by:
getVendorID in interface DatastoreAdapter
Returns:
Vendor id for this datastore

isReservedKeyword

public boolean isReservedKeyword(java.lang.String word)
Description copied from interface: DatastoreAdapter
Method to check if a word is reserved for this datastore.

Specified by:
isReservedKeyword in interface DatastoreAdapter
Parameters:
word - The word
Returns:
Whether it is reserved

getIdentifierCase

public int getIdentifierCase()
Accessor for the case that the identifiers will be specified in

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

getIdentifierQuoteString

public java.lang.String getIdentifierQuoteString()
Accessor for an identifier quote string.

Specified by:
getIdentifierQuoteString in interface DatastoreAdapter
Returns:
Identifier quote string.

getIdentifierInAdapterCase

public java.lang.String getIdentifierInAdapterCase(java.lang.String identifier)
Convenience method to convert the passed identifier into an identifier in the correct case, and with any required quoting. If the identifier is already quoted and needs quotes then none are added.

Specified by:
getIdentifierInAdapterCase in interface DatastoreAdapter
Parameters:
identifier - The identifier
Returns:
The updated identifier in the correct case

newQueryStatement

public abstract QueryExpression newQueryStatement(DatastoreContainerObject container,
                                                  ClassLoaderResolver clr)
Description copied from interface: DatastoreAdapter
Accessor for a new query statement.

Specified by:
newQueryStatement in interface DatastoreAdapter
Parameters:
container - The table to query
clr - the ClassLoaderResolver
Returns:
The Query Statement

newQueryStatement

public abstract QueryExpression newQueryStatement(DatastoreContainerObject container,
                                                  DatastoreIdentifier rangeVar,
                                                  ClassLoaderResolver clr)
Description copied from interface: DatastoreAdapter
Accessor for a new query statement.

Specified by:
newQueryStatement in interface DatastoreAdapter
Parameters:
container - The table to query
rangeVar - A range variable for the query
clr - the ClassLoaderResolver
Returns:
The Query Statement

getDictionary

public Dictionary getDictionary()
Description copied from interface: DatastoreAdapter
Accessor for the Dictionary.

Specified by:
getDictionary in interface DatastoreAdapter
Returns:
Returns the dictionary.

getAdapterTime

public long getAdapterTime(java.sql.Timestamp time)
Description copied from interface: DatastoreAdapter
Utility to return the adapter time in case there are rounding issues with millisecs etc.

Specified by:
getAdapterTime in interface DatastoreAdapter
Parameters:
time - The timestamp
Returns:
The time in millisecs

getTime

protected long getTime(long time,
                       long nanos)

getMiliseconds

protected int getMiliseconds(long nanos)

getDatastoreMajorVersion

public int getDatastoreMajorVersion()
Description copied from interface: DatastoreAdapter
Accessor for the datastore major version number.

Specified by:
getDatastoreMajorVersion in interface DatastoreAdapter
Returns:
Major version number

getDatastoreMinorVersion

public int getDatastoreMinorVersion()
Description copied from interface: DatastoreAdapter
Accessor for the datastore minor version number.

Specified by:
getDatastoreMinorVersion in interface DatastoreAdapter
Returns:
Minor version number

modOperator

public NumericExpression modOperator(ScalarExpression operand1,
                                     ScalarExpression operand2)
Description copied from interface: DatastoreAdapter
Method to generate a modulus expression. The binary % operator is said to yield the remainder of its operands from an implied division; the left-hand operand is the dividend and the right-hand operand is the divisor.

Specified by:
modOperator in interface DatastoreAdapter
Parameters:
operand1 - the left expression
operand2 - the right expression
Returns:
The Expression for modulus

supportsAutoIncrementFields

public boolean supportsAutoIncrementFields()
Accessor for whether autoincrementing fields are supported.

Specified by:
supportsAutoIncrementFields in interface DatastoreAdapter
Returns:
Whether we support autoincrementing fields

supportsSequences

public boolean supportsSequences()
Accessor for whether sequences are supported.

Specified by:
supportsSequences in interface DatastoreAdapter
Returns:
whether we support sequences.

supportsQueryFetchSizeLowerThanOne

public boolean supportsQueryFetchSizeLowerThanOne()
Whether the datastore supports setting a fetch size lower than one. Usually, the datastore should ignore settting fetch size lower than one.

Specified by:
supportsQueryFetchSizeLowerThanOne in interface DatastoreAdapter
Returns:
whether we support fetch size lower than one

toString

public java.lang.String toString()
Description copied from interface: DatastoreAdapter
Method to return this object as a string.

Specified by:
toString in interface DatastoreAdapter


Copyright © -2007 . All Rights Reserved.