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.Timestamp;
21: import java.util.Date;
22:
23: import org.jpox.store.expression.QueryExpression;
24: import org.jpox.store.expression.ScalarExpression;
25:
26: /**
27: * SCO Mapping for java.util.Date type.
28: *
29: * @version $Revision: 1.12 $
30: **/
31: public class DateMapping extends SqlTimestampMapping {
32: public ScalarExpression newLiteral(QueryExpression qs, Object value) {
33: return super .newLiteral(qs, new Timestamp(((Date) value)
34: .getTime()));
35: }
36:
37: public Class getJavaType() {
38: return Date.class;
39: }
40:
41: /**
42: * Method to return the default length of this type in the datastore.
43: * java.util.Date requires 28 characters ("dow mon dd hh:mm:ss zzz yyyy")
44: * @param index The index position
45: * @return The default length
46: */
47: public int getDefaultLength(int index) {
48: return 28;
49: }
50: }
|