01: /**********************************************************************
02: Copyright (c) 2006 Nicolas Dufailly 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: 2006 Nicolas Dufailly - initial contribution
17: ...
18: **********************************************************************/package org.jpox.store.mapping;
19:
20: import java.awt.image.BufferedImage;
21:
22: import org.jpox.ClassLoaderResolver;
23: import org.jpox.ClassNameConstants;
24: import org.jpox.exceptions.JPOXUserException;
25: import org.jpox.store.expression.LogicSetExpression;
26: import org.jpox.store.expression.QueryExpression;
27: import org.jpox.store.expression.ScalarExpression;
28:
29: /**
30: * Support java.awt.image.BufferedImage
31: * @version $Revision: 1.5 $
32: */
33: public class BufferedImageMapping extends SingleFieldMapping {
34:
35: private static BufferedImage sampleValue = new BufferedImage(1, 1,
36: BufferedImage.TYPE_INT_RGB);
37:
38: public Object getSampleValue(ClassLoaderResolver clr) {
39: return sampleValue;
40: }
41:
42: public Class getJavaType() {
43: return (BufferedImage.class);
44: }
45:
46: /**
47: * Accessor for the name of the java-type actually used when mapping the particular datastore
48: * field. Returns java.io.Serializable
49: * @param index requested datastore field index.
50: * @return the name of java-type for the requested datastore field.
51: */
52: public String getJavaTypeForDatastoreMapping(int index) {
53: return ClassNameConstants.JAVA_IO_SERIALIZABLE;
54: }
55:
56: public ScalarExpression newLiteral(QueryExpression qExpr,
57: Object literal) {
58: throw new JPOXUserException(getJavaType().getName()
59: + " is not supported in queries.").setFatal();
60: }
61:
62: public ScalarExpression newScalarExpression(QueryExpression qExpr,
63: LogicSetExpression expr) {
64: throw new JPOXUserException(getJavaType().getName()
65: + " is not supported in queries.").setFatal();
66: }
67: }
|