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: Contributors:
16: Andy Jefferson - coding standards and javadocs
17: ...
18: **********************************************************************/package org.jpox.store.mapping;
19:
20: import java.sql.Date;
21:
22: import org.jpox.ClassLoaderResolver;
23: import org.jpox.store.expression.LogicSetExpression;
24: import org.jpox.store.expression.QueryExpression;
25: import org.jpox.store.expression.ScalarExpression;
26: import org.jpox.store.expression.SqlDateLiteral;
27: import org.jpox.store.expression.SqlTemporalExpression;
28:
29: /**
30: * SCO Mapping for an SQLDate type.
31: * Maps between a java.sql.Date object and an SQL "DATE" type in the datatsore.
32: *
33: * @version $Revision: 1.13 $
34: **/
35: public class SqlDateMapping extends SingleFieldMapping implements
36: SimpleDatastoreRepresentation {
37: private static java.sql.Date mappingSampleValue = new java.sql.Date(
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 SqlDateLiteral(qs, this ,
46: (Date) 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.Date.class;
58: }
59: }
|