01: /**********************************************************************
02: Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15: Contributors:
16: Andy Jefferson - removed getUpdateInputParameter,getInsertionInputParameter
17: ...
18: **********************************************************************/package org.jpox.store.mapping;
19:
20: import org.jpox.ClassLoaderResolver;
21: import org.jpox.store.expression.IntegerLiteral;
22: import org.jpox.store.expression.LogicSetExpression;
23: import org.jpox.store.expression.NumericExpression;
24: import org.jpox.store.expression.QueryExpression;
25: import org.jpox.store.expression.ScalarExpression;
26:
27: /**
28: * Mapping for Index Columns.
29: *
30: * This class is for internal use only. It should not be used in user mappings nor
31: * extended.
32: *
33: * @version $Revision: 1.14 $
34: **/
35: public class IndexMapping extends SingleFieldMapping implements
36: SimpleDatastoreRepresentation {
37: private static Integer mappingSampleValue = new Integer(0);
38:
39: /**
40: * Accessor for a sample value for this field
41: * @return Sample field value
42: */
43: public Object getSampleValue(ClassLoaderResolver clr) {
44: return mappingSampleValue;
45: }
46:
47: /**
48: * Accessor for a new literal for this mapping.
49: * @param qs The QueryStatement
50: * @param value The value of the object
51: * @return The new literal
52: */
53: public ScalarExpression newLiteral(QueryExpression qs, Object value) {
54: return new IntegerLiteral(qs, this , (Number) value);
55: }
56:
57: /**
58: * Accessor for a new literal for this mapping.
59: * @param qs The QueryStatement
60: * @param te The table Expression
61: * @return The new literal
62: */
63: public ScalarExpression newScalarExpression(QueryExpression qs,
64: LogicSetExpression te) {
65: return new NumericExpression(qs, this , te);
66: }
67:
68: /**
69: * Accessor for whether to include this column in any fetch statement
70: * @return Whether to include the column when fetching.
71: */
72: public boolean includeInFetchStatement() {
73: return false;
74: }
75:
76: /**
77: * Accessor for the type represented here, returning the class itself
78: * @return This class.
79: */
80: public Class getJavaType() {
81: return Integer.class;
82: }
83: }
|