01: /**********************************************************************
02: Copyright (c) 2003 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:
16: Contributors:
17: 2003 Andy Jefferson - coding standards
18: ...
19: **********************************************************************/package org.jpox.store.mapping;
20:
21: import org.jpox.ClassLoaderResolver;
22: import org.jpox.ClassNameConstants;
23: import org.jpox.store.expression.LogicSetExpression;
24: import org.jpox.store.expression.ObjectExpression;
25: import org.jpox.store.expression.ObjectLiteral;
26: import org.jpox.store.expression.QueryExpression;
27: import org.jpox.store.expression.ScalarExpression;
28:
29: /**
30: * Maps a field as serialised.
31: *
32: * @version $Revision: 1.7 $
33: **/
34: public class SerialisedMapping extends SingleFieldMapping implements
35: SimpleDatastoreRepresentation {
36: /**
37: * Accessor for a sample value for this type.
38: * @return The sample value
39: */
40: public Object getSampleValue(ClassLoaderResolver clr) {
41: return null;
42: }
43:
44: /**
45: * Accessor for the (Java) type of data represented here
46: * @return java.lang.Object
47: */
48: public Class getJavaType() {
49: return Object.class;
50: }
51:
52: /**
53: * Accessor for the name of the java-type actually used when mapping the particular datastore
54: * field. Returns Serializable since the object needs to be Serialisable
55: * @param index requested datastore field index.
56: * @return the name of java-type for the requested datastore field.
57: */
58: public String getJavaTypeForDatastoreMapping(int index) {
59: return ClassNameConstants.JAVA_IO_SERIALIZABLE;
60: }
61:
62: // ------------------------------------- JDOQL Methods -------------------------------------------
63:
64: public ScalarExpression newLiteral(QueryExpression qs, Object value) {
65: return new ObjectLiteral(qs, this , value, getType());
66: }
67:
68: public ScalarExpression newScalarExpression(QueryExpression qs,
69: LogicSetExpression te) {
70: return new ObjectExpression(qs, this, te);
71: }
72: }
|