01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: FloatPkFieldMapping.java 5445 2004-09-17 08:25:02Z joaninh $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ejb.lib;
25:
26: /**
27: * Conversion java.lang.Float <-> java.lang.String. <br>
28: * This conversion is useful only for primary key field because JORM does not support float as primary key field.
29: * The StorageType is the JORM type, and the MemoryType is the JOnAS type (bean field type).
30: * @author Helene Joanin
31: */
32: public class FloatPkFieldMapping {
33:
34: /**
35: * Retrieves the java type corresponding to the type into the data support.
36: * @return a Class object (never null).
37: */
38: public static Class getStorageType() {
39: return String.class;
40: }
41:
42: /**
43: * Retrieves the java type corresponding to the type in memory.
44: * @return a Class object (never null).
45: */
46: public static Class getMemoryType() {
47: return Float.class;
48: }
49:
50: /**
51: * Converts a value from the data support into a value in memory
52: * @param storagevalue is the value store in the support (can be null).
53: * @return the value in memory (can be null).
54: */
55: public static Object toMemory(Object storagevalue) {
56: if (storagevalue == null) {
57: return null;
58: }
59: return (storagevalue instanceof Float ? storagevalue
60: : new Float((String) storagevalue));
61: }
62:
63: /**
64: * Converts a value from the data support into a value in memory
65: * @param memoryvalue the value in memory (can be null).
66: * @return is the value store in the support (can be null).
67: */
68: public static Object toStorage(Object memoryvalue) {
69: return memoryvalue.toString();
70: }
71: }
|