org.jpox.store.mapped
Class AbstractDatastoreAdapter

java.lang.Object
  extended by org.jpox.store.mapped.AbstractDatastoreAdapter
All Implemented Interfaces:
DatastoreAdapter, ExpressionConversionAdapter, ExpressionLogicSetAdapter, ExpressionMethodAdapter, ExpressionOperatorAdapter, ExpressionPatternAdapter, ExpressionSupportedFeaturesAdapter

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.31 $

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  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.
 
Constructor Summary
AbstractDatastoreAdapter()
          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.
 java.lang.String getIdentifierQuoteString()
          Accessor for an identifier quote string.
 JavaTypeMapping getMapping(java.lang.Class c, MappedStoreManager storeMgr)
          Convenience accessor for the mapping for the specified class when not serialised and not embedded.
 JavaTypeMapping getMapping(java.lang.Class c, MappedStoreManager storeMgr, boolean serialised, boolean embedded, java.lang.String fieldName)
          Convenience accessor for the mapping for the specified class.
 JavaTypeMapping getMapping(java.lang.Class c, MappedStoreManager storeMgr, ClassLoaderResolver clr)
          Accessor for the mapping for the specified class when not serialised and not embedded.
 JavaTypeMapping getMapping(java.lang.Class c, MappedStoreManager storeMgr, ClassLoaderResolver clr, boolean serialised, boolean embedded)
          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.
 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 isBitReallyBoolean()
          Accessor for whether a bit is really mapped in the datastore to boolean.
 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 supportsIdentityFields()
          Accessor for whether autoincrementing fields are supported.
 boolean supportsQueryFetchSize(int size)
          Whether the datastore will support setting the query fetch size to the supplied value.
 boolean supportsSequences()
          Accessor for whether sequences are supported.
 
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.mapped.DatastoreAdapter
initialiseDatastore, isIdentityFieldDataType, isStoresLowerCaseIdentifiers, isStoresLowerCaseQuotedIdentifiers, isStoresMixedCaseIdentifiers, isStoresMixedCaseQuotedIdentifiers, isStoresUpperCaseIdentifiers, isStoresUpperCaseQuotedIdentifiers, supportsProjectionInTableReferenceJoins, toString
 
Methods inherited from interface org.jpox.store.mapped.expression.ExpressionConversionAdapter
toNumericExpression, toStringExpression, toStringExpression
 
Methods inherited from interface org.jpox.store.mapped.expression.ExpressionOperatorAdapter
concatOperator, getOperatorConcat
 
Methods inherited from interface org.jpox.store.mapped.expression.ExpressionMethodAdapter
absMethod, acosMethod, asinMethod, atanMethod, ceilMethod, cosMethod, endsWithMethod, expMethod, floorMethod, getCurrentDateMethod, getCurrentTimeMethod, getCurrentTimestampMethod, getDayMethod, getHourMethod, getMinuteMethod, getMonthMethod, getSecondMethod, getYearMethod, indexOfMethod, lengthMethod, logMethod, matchesMethod, sinMethod, sqrtMethod, startsWithMethod, substringMethod, substringMethod, tanMethod, translateMethod, trimMethod
 
Methods inherited from interface org.jpox.store.mapped.expression.ExpressionSupportedFeaturesAdapter
supportsBooleanComparison, supportsEscapeExpressionInLikePredicate
 
Methods inherited from interface org.jpox.store.mapped.expression.ExpressionPatternAdapter
getEscapeCharacter, getEscapedPatternExpression, getEscapePatternExpression, getPatternExpressionAnyCharacter, getPatternExpressionZeroMoreCharacters
 
Methods inherited from interface org.jpox.store.mapped.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.


identifierQuoteString

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


mappingManager

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

Constructor Detail

AbstractDatastoreAdapter

public AbstractDatastoreAdapter()
Constructor.

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,
                                  MappedStoreManager storeMgr)
Convenience accessor for the mapping for the specified class when not serialised and not embedded.

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,
                                  MappedStoreManager storeMgr,
                                  boolean serialised,
                                  boolean embedded,
                                  java.lang.String fieldName)
Convenience accessor for the mapping for the specified class.

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

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  MappedStoreManager storeMgr,
                                  ClassLoaderResolver clr)
Accessor for the mapping for the specified class when not serialised and not embedded.

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

getMapping

public JavaTypeMapping getMapping(java.lang.Class c,
                                  MappedStoreManager storeMgr,
                                  ClassLoaderResolver clr,
                                  boolean serialised,
                                  boolean embedded)
Convenience accessor for the mapping for the specified class.

Specified by:
getMapping in interface DatastoreAdapter
Parameters:
c - Java type
storeMgr - The Store manager
clr - ClassLoader resolver
serialised - Whether the type is serialised
embedded - Whether the type is embedded
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.

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

getIdentifierQuoteString

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

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

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

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
Specified by:
modOperator in interface ExpressionOperatorAdapter
Parameters:
operand1 - the left expression
operand2 - the right expression
Returns:
The Expression for modulus

supportsIdentityFields

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

Specified by:
supportsIdentityFields 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.

supportsQueryFetchSize

public boolean supportsQueryFetchSize(int size)
Whether the datastore will support setting the query fetch size to the supplied value.

Specified by:
supportsQueryFetchSize in interface DatastoreAdapter
Parameters:
size - The value to set to
Returns:
Whether it is supported.

isBitReallyBoolean

public boolean isBitReallyBoolean()
Accessor for whether a bit is really mapped in the datastore to boolean.

Specified by:
isBitReallyBoolean in interface DatastoreAdapter
Returns:
Whether bit is really stored as a boolean


Copyright © -2008 . All Rights Reserved.