001: /**********************************************************************
002: Copyright (c) 2004 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: Contributors:
016: ...
017: **********************************************************************/package org.jpox.store.mapping;
018:
019: import org.jpox.store.DatastoreField;
020:
021: /**
022: * Representation of the mapping of a datastore type.
023: *
024: * @version $Revision: 1.7 $
025: */
026: public interface DatastoreMapping {
027: /**
028: * Whether the field mapped is nullable.
029: * @return true if is nullable
030: */
031: boolean isNullable();
032:
033: /**
034: * The datastore field mapped.
035: * @return the DatastoreField
036: */
037: DatastoreField getDatastoreField();
038:
039: /**
040: * The mapping for the java type that this datastore mapping is used by.
041: * This will return null if this simply maps a datastore field in the datastore and has
042: * no associated java type in a class.
043: * @return the JavaTypeMapping
044: */
045: JavaTypeMapping getJavaTypeMapping();
046:
047: /**
048: * Accessor for whether the mapping is decimal-based.
049: * @return Whether the mapping is decimal based
050: */
051: boolean isDecimalBased();
052:
053: /**
054: * Accessor for whether the mapping is integer-based.
055: * @return Whether the mapping is integer based
056: */
057: boolean isIntegerBased();
058:
059: /**
060: * Accessor for whether the mapping is string-based.
061: * @return Whether the mapping is string based
062: */
063: boolean isStringBased();
064:
065: /**
066: * Accessor for whether the mapping is bit-based.
067: * @return Whether the mapping is bit based
068: */
069: boolean isBitBased();
070:
071: /**
072: * Accessor for whether the mapping is boolean-based.
073: * @return Whether the mapping is boolean based
074: */
075: boolean isBooleanBased();
076:
077: /**
078: * Sets a <code>value</code> into <code>preparedStatement</code>
079: * at position specified by <code>paramIndex</code>.
080: * @param preparedStatement a datastore object that executes statements in the database
081: * @param paramIndex the position of the value in the statement
082: * @param value the value
083: */
084: void setBoolean(Object preparedStatement, int paramIndex,
085: boolean value);
086:
087: /**
088: * Sets a <code>value</code> into <code>preparedStatement</code>
089: * at position specified by <code>paramIndex</code>.
090: * @param preparedStatement a datastore object that executes statements in the database
091: * @param paramIndex the position of the value in the statement
092: * @param value the value
093: */
094: void setChar(Object preparedStatement, int paramIndex, char value);
095:
096: /**
097: * Sets a <code>value</code> into <code>preparedStatement</code>
098: * at position specified by <code>paramIndex</code>.
099: * @param preparedStatement a datastore object that executes statements in the database
100: * @param paramIndex the position of the value in the statement
101: * @param value the value
102: */
103: void setByte(Object preparedStatement, int paramIndex, byte value);
104:
105: /**
106: * Sets a <code>value</code> into <code>preparedStatement</code>
107: * at position specified by <code>paramIndex</code>.
108: * @param preparedStatement a datastore object that executes statements in the database
109: * @param paramIndex the position of the value in the statement
110: * @param value the value
111: */
112: void setShort(Object preparedStatement, int paramIndex, short value);
113:
114: /**
115: * Sets a <code>value</code> into <code>preparedStatement</code>
116: * at position specified by <code>paramIndex</code>.
117: * @param preparedStatement a datastore object that executes statements in the database
118: * @param paramIndex the position of the value in the statement
119: * @param value the value
120: */
121: void setInt(Object preparedStatement, int paramIndex, int value);
122:
123: /**
124: * Sets a <code>value</code> into <code>preparedStatement</code>
125: * at position specified by <code>paramIndex</code>.
126: * @param preparedStatement a datastore object that executes statements in the database
127: * @param paramIndex the position of the value in the statement
128: * @param value the value
129: */
130: void setLong(Object preparedStatement, int paramIndex, long value);
131:
132: /**
133: * Sets a <code>value</code> into <code>preparedStatement</code>
134: * at position specified by <code>paramIndex</code>.
135: * @param preparedStatement a datastore object that executes statements in the database
136: * @param paramIndex the position of the value in the statement
137: * @param value the value
138: */
139: void setFloat(Object preparedStatement, int paramIndex, float value);
140:
141: /**
142: * Sets a <code>value</code> into <code>preparedStatement</code>
143: * at position specified by <code>paramIndex</code>.
144: * @param preparedStatement a datastore object that executes statements in the database
145: * @param paramIndex the position of the value in the statement
146: * @param value the value
147: */
148: void setDouble(Object preparedStatement, int paramIndex,
149: double value);
150:
151: /**
152: * Sets a <code>value</code> into <code>preparedStatement</code>
153: * at position specified by <code>paramIndex</code>.
154: * @param preparedStatement a datastore object that executes statements in the database
155: * @param paramIndex the position of the value in the statement
156: * @param value the value
157: */
158: void setString(Object preparedStatement, int paramIndex,
159: String value);
160:
161: /**
162: * Sets a <code>value</code> into <code>preparedStatement</code>
163: * at position specified by <code>paramIndex</code>.
164: * @param preparedStatement a datastore object that executes statements in the database
165: * @param paramIndex the position of the value in the statement
166: * @param value the value
167: */
168: void setObject(Object preparedStatement, int paramIndex,
169: Object value);
170:
171: /**
172: * Obtains a value from <code>resultSet</code>
173: * at position specified by <code>exprIndex</code>.
174: * @param resultSet an object returned from the datastore with values
175: * @param exprIndex the position of the value in the result
176: * @return the value
177: */
178: boolean getBoolean(Object resultSet, int exprIndex);
179:
180: /**
181: * Obtains a value from <code>resultSet</code>
182: * at position specified by <code>exprIndex</code>.
183: * @param resultSet an object returned from the datastore with values
184: * @param exprIndex the position of the value in the result
185: * @return the value
186: */
187: char getChar(Object resultSet, int exprIndex);
188:
189: /**
190: * Obtains a value from <code>resultSet</code>
191: * at position specified by <code>exprIndex</code>.
192: * @param resultSet an object returned from the datastore with values
193: * @param exprIndex the position of the value in the result
194: * @return the value
195: */
196: byte getByte(Object resultSet, int exprIndex);
197:
198: /**
199: * Obtains a value from <code>resultSet</code>
200: * at position specified by <code>exprIndex</code>.
201: * @param resultSet an object returned from the datastore with values
202: * @param exprIndex the position of the value in the result
203: * @return the value
204: */
205: short getShort(Object resultSet, int exprIndex);
206:
207: /**
208: * Obtains a value from <code>resultSet</code>
209: * at position specified by <code>exprIndex</code>.
210: * @param resultSet an object returned from the datastore with values
211: * @param exprIndex the position of the value in the result
212: * @return the value
213: */
214: int getInt(Object resultSet, int exprIndex);
215:
216: /**
217: * Obtains a value from <code>resultSet</code>
218: * at position specified by <code>exprIndex</code>.
219: * @param resultSet an object returned from the datastore with values
220: * @param exprIndex the position of the value in the result
221: * @return the value
222: */
223: long getLong(Object resultSet, int exprIndex);
224:
225: /**
226: * Obtains a value from <code>resultSet</code>
227: * at position specified by <code>exprIndex</code>.
228: * @param resultSet an object returned from the datastore with values
229: * @param exprIndex the position of the value in the result
230: * @return the value
231: */
232: float getFloat(Object resultSet, int exprIndex);
233:
234: /**
235: * Obtains a value from <code>resultSet</code>
236: * at position specified by <code>exprIndex</code>.
237: * @param resultSet an object returned from the datastore with values
238: * @param exprIndex the position of the value in the result
239: * @return the value
240: */
241: double getDouble(Object resultSet, int exprIndex);
242:
243: /**
244: * Obtains a value from <code>resultSet</code>
245: * at position specified by <code>exprIndex</code>.
246: * @param resultSet an object returned from the datastore with values
247: * @param exprIndex the position of the value in the result
248: * @return the value
249: */
250: String getString(Object resultSet, int exprIndex);
251:
252: /**
253: * Obtains a value from <code>resultSet</code>
254: * at position specified by <code>exprIndex</code>.
255: * @param resultSet an object returned from the datastore with values
256: * @param exprIndex the position of the value in the result
257: * @return the value
258: */
259: Object getObject(Object resultSet, int exprIndex);
260: }
|