01: /**********************************************************************
02: Copyright (c) 2002 Mike Martin (TJDO) 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:
16: Contributors:
17: 2003 Andy Jefferson - coding standards and javadocs
18: ...
19: **********************************************************************/package org.jpox.store.mapping;
20:
21: import java.sql.Timestamp;
22:
23: import org.jpox.ClassLoaderResolver;
24: import org.jpox.store.expression.LogicSetExpression;
25: import org.jpox.store.expression.QueryExpression;
26: import org.jpox.store.expression.ScalarExpression;
27: import org.jpox.store.expression.SqlTemporalExpression;
28: import org.jpox.store.expression.SqlTimestampLiteral;
29:
30: /**
31: * SCO Mapping for an SQLTimestamp type.
32: *
33: * @version $Revision: 1.14 $
34: **/
35: public class SqlTimestampMapping extends SingleFieldMapping implements
36: SimpleDatastoreRepresentation {
37: private static java.sql.Timestamp mappingSampleValue = new java.sql.Timestamp(
38: new java.util.Date().getTime());
39:
40: public Object getSampleValue(ClassLoaderResolver clr) {
41: return mappingSampleValue;
42: }
43:
44: public ScalarExpression newLiteral(QueryExpression qs, Object value) {
45: ScalarExpression expr = new SqlTimestampLiteral(qs, this ,
46: (Timestamp) value);
47: return expr;
48: }
49:
50: public ScalarExpression newScalarExpression(QueryExpression qs,
51: LogicSetExpression te) {
52: ScalarExpression expr = new SqlTemporalExpression(qs, this , te);
53: return expr;
54: }
55:
56: public Class getJavaType() {
57: return java.sql.Timestamp.class;
58: }
59: }
|