001: /**********************************************************************
002: Copyright (c) 2005 Erik Bengtson and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015:
016: Contributors:
017: ...
018: **********************************************************************/package org.jpox.store;
019:
020: import java.sql.Timestamp;
021:
022: import org.jpox.ClassLoaderResolver;
023: import org.jpox.plugin.PluginManager;
024: import org.jpox.store.expression.ExpressionConversionAdapter;
025: import org.jpox.store.expression.ExpressionLogicSetAdapter;
026: import org.jpox.store.expression.ExpressionMethodAdapter;
027: import org.jpox.store.expression.ExpressionOperatorAdapter;
028: import org.jpox.store.expression.ExpressionPatternAdapter;
029: import org.jpox.store.expression.ExpressionSupportedFeaturesAdapter;
030: import org.jpox.store.expression.NumericExpression;
031: import org.jpox.store.expression.QueryExpression;
032: import org.jpox.store.expression.ScalarExpression;
033: import org.jpox.store.mapping.JavaTypeMapping;
034: import org.jpox.store.mapping.MappingManager;
035:
036: /**
037: * Definition of a datastore adapter.
038: *
039: * @version $Revision: 1.35 $
040: */
041: public interface DatastoreAdapter extends ExpressionConversionAdapter,
042: ExpressionOperatorAdapter, ExpressionMethodAdapter,
043: ExpressionSupportedFeaturesAdapter, ExpressionPatternAdapter,
044: ExpressionLogicSetAdapter {
045: /**
046: * Accessor for the Mapping Manager for field mapping management.
047: * @return The Mapping Manager.
048: */
049: public abstract MappingManager getMappingManager();
050:
051: /**
052: * Accessor for the Vendor ID for this datastore.
053: * @return Vendor id for this datastore
054: */
055: public abstract String getVendorID();
056:
057: /**
058: * Load the datastore mappings declared as Plug-in
059: * @param mgr the PluginManager
060: * @param clr the ClassLoaderResolver
061: */
062: public void loadDatastoreMapping(PluginManager mgr,
063: ClassLoaderResolver clr);
064:
065: /**
066: * Method to check if a word is reserved for this datastore.
067: * @param word The word
068: * @return Whether it is reserved
069: */
070: public abstract boolean isReservedKeyword(String word);
071:
072: /**
073: * Creates the auxiliary functions/procedures in the datastore
074: * @param conn the connection to the datastore
075: */
076: public abstract void initialiseDatastore(Object conn);
077:
078: /**
079: * Accessor for the quote string to use when quoting identifiers.
080: * @return The quote string for the identifier
081: */
082: public abstract String getIdentifierQuoteString();
083:
084: /**
085: * Accessor for a new query statement.
086: * @param container The table to query
087: * @param clr the ClassLoaderResolver
088: * @return The Query Statement
089: **/
090: public abstract QueryExpression newQueryStatement(
091: DatastoreContainerObject container, ClassLoaderResolver clr);
092:
093: /**
094: * Accessor for a new query statement.
095: * @param container The table to query
096: * @param rangeVar A range variable for the query
097: * @param clr the ClassLoaderResolver
098: * @return The Query Statement
099: **/
100: public abstract QueryExpression newQueryStatement(
101: DatastoreContainerObject container,
102: DatastoreIdentifier rangeVar, ClassLoaderResolver clr);
103:
104: /**
105: * Accessor for the mapping for the specified class assuming that the type is not serialised and not embedded.
106: * @param c Java type
107: * @param storeMgr the StoreManager
108: * @return The mapping for the class.
109: */
110: public abstract JavaTypeMapping getMapping(Class c,
111: StoreManager storeMgr);
112:
113: /**
114: * Accessor for the mapping for the specified class.
115: * TODO Why use this and not the one with ClassLoaderResolver ?
116: * @param c Java type
117: * @param storeMgr the StoreManager
118: * @param serialised Whether the type is serialised
119: * @param embedded Whether the type is embedded
120: * @param fieldName Name of field (for logging only)
121: * @return The mapping for the class.
122: */
123: public abstract JavaTypeMapping getMapping(Class c,
124: StoreManager storeMgr, boolean serialised,
125: boolean embedded, String fieldName);
126:
127: /**
128: * Accessor for the mapping for the specified class assuming that the type is not serialised and not embedded.
129: * @param c Class to query
130: * @param storeMgr The Store Manager
131: * @param clr The ClassLoaderResolver
132: * @return The mapping for the class.
133: */
134: public abstract JavaTypeMapping getMapping(Class c,
135: StoreManager storeMgr, ClassLoaderResolver clr);
136:
137: /**
138: * Accessor for the mapping for the specified class.
139: * TODO Why use this and not the one without ClassLoaderResolver ?
140: * @param c Class to query
141: * @param storeMgr The Store Manager
142: * @param clr The ClassLoaderResolver
143: * @param serialised Whether the type is serialised
144: * @param embedded Whether the type is embedded
145: * @return The mapping for the class.
146: */
147: public abstract JavaTypeMapping getMapping(Class c,
148: StoreManager storeMgr, ClassLoaderResolver clr,
149: boolean serialised, boolean embedded);
150:
151: /**
152: * Utility to return the adapter time in case there are rounding issues with
153: * millisecs etc.
154: * @param time The timestamp
155: * @return The time in millisecs
156: */
157: public abstract long getAdapterTime(Timestamp time);
158:
159: /**
160: * Accessor for the datastore major version number.
161: * @return Major version number
162: */
163: public abstract int getDatastoreMajorVersion();
164:
165: /**
166: * Accessor for the datastore minor version number.
167: * @return Minor version number
168: */
169: public abstract int getDatastoreMinorVersion();
170:
171: /**
172: * Method to generate a modulus expression. The binary % operator is said to
173: * yield the remainder of its operands from an implied division; the
174: * left-hand operand is the dividend and the right-hand operand is the
175: * divisor.
176: * @param operand1 the left expression
177: * @param operand2 the right expression
178: * @return The Expression for modulus
179: */
180: public abstract NumericExpression modOperator(
181: ScalarExpression operand1, ScalarExpression operand2);
182:
183: /**
184: * Verifies if the given <code>columnDef</code> is an identity field type for the datastore.
185: * @param columnDef the datastore type name
186: * @return true when the <code>columnDef</code> has values for identity generation in the datastore
187: **/
188: boolean isIdentityFieldDataType(String columnDef);
189:
190: /**
191: * Whether this datastore adapter support identity fields.
192: * The column could be things like "AUTOINCREMENT", "IDENTITY", "SERIAL" in SQL.
193: * @return whether identity fields are supported.
194: */
195: public abstract boolean supportsIdentityFields();
196:
197: /**
198: * Whether this datastore adapter supports sequences.
199: * @return whether sequences are supported.
200: **/
201: public abstract boolean supportsSequences();
202:
203: /**
204: * Whether the datastore will support setting the query fetch size to the supplied value.
205: * @param size The value to set to
206: * @return Whether it is supported.
207: */
208: boolean supportsQueryFetchSize(int size);
209:
210: /**
211: * Accessor for whether this adapter stores lower case identifiers.
212: * @return Whether lowercase identifiers are stored
213: */
214: public boolean isStoresLowerCaseIdentifiers();
215:
216: /**
217: * Accessor for whether this adapter stores "lowercase" identifiers.
218: * @return Whether "lowercase" identifiers are stored
219: */
220: public boolean isStoresLowerCaseQuotedIdentifiers();
221:
222: /**
223: * Accessor for whether this adapter stores MixedCase identifiers.
224: * @return Whether MixedCase identifiers are stored
225: */
226: public boolean isStoresMixedCaseIdentifiers();
227:
228: /**
229: * Accessor for whether this adapter "MixedCase" identifiers.
230: * @return Whether "MixedCase" identifiers are stored
231: */
232: public boolean isStoresMixedCaseQuotedIdentifiers();
233:
234: /**
235: * Accessor for whether this adapter stores UPPERCASE identifiers.
236: * @return Whether UPPERCASE identifiers are stored
237: */
238: public boolean isStoresUpperCaseIdentifiers();
239:
240: /**
241: * Accessor for whether this adapter stores "UPPERCASE" identifiers.
242: * @return Whether "UPPERCASE" identifiers are stored
243: */
244: public boolean isStoresUpperCaseQuotedIdentifiers();
245:
246: /**
247: * Accessor for whether bit is really mapped in the datastore to boolean.
248: * TODO Abstract this out to RDBMS
249: * @return Whether bit is really stored as a boolean
250: */
251: boolean isBitReallyBoolean();
252:
253: /**
254: * Method to return this object as a string.
255: * @return String version of this object.
256: */
257: public abstract String toString();
258: }
|