1 /* -------------------------------------------------------------------
2 * Java source file for the class WrapperToPrimitiveShortConverter
3 *
4 * Copyright (c), 2002, Masahiro Takatsuka.
5 * All Rights Researved.
6 *
7 * Original Author: Masahiro Takatsuka (masa@jbeans.net)
8 * $Author: takatsukam $
9 *
10 * $Date: 2003/07/25 04:51:45 $
11 *
12 * $Id: WrapperToPrimitiveShortConverter.java,v 1.1.1.1 2003/07/25 04:51:45 takatsukam Exp $
13 *
14 * Reference: Document no:
15 * ___ ___
16 *
17 * To Do:
18 * ___
19 *
20 ------------------------------------------------------------------- */
21
22 /* --------------------------- Package ---------------------------- */
23 package net.jbeans.data.converter;
24
25 /* ------------------ Import classes (packages) ------------------- *//package-summary/html">color="#329900"> ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900"> ------------------ Import classes (packages) ------------------- */
26 import net.jbeans.data.*;
27
28 /*====================================================================
29 Implementation of class WrapperToPrimitiveShortConverter
30 ====================================================================*/
31 /***
32 * generally describe WrapperToPrimitiveShortConverter in here
33 *
34 * @version $Revision: 1.1.1.1 $
35 * @author Masahiro Takatsuka (masa@jbeans.net)
36 * @see DataConverter
37 */
38
39 public final class WrapperToPrimitiveShortConverter extends DataConverter {
40 private static final int WRAPPER_TO_PRIMITIVE_SHORT_COUNT = 7;
41
42 private static final int BYTE = 0;
43 private static final int DOUBLE = 1;
44 private static final int FLOAT = 2;
45 private static final int INTEGER = 3;
46 private static final int LONG = 4;
47 private static final int SHORT = 5;
48 private static final int BOOLEAN = 6;
49
50 /***
51 * Initializes acceptable soruce and target types.
52 */
53 protected void setDataTypes() {
54 this.sourceTypes = new Class[WRAPPER_TO_PRIMITIVE_SHORT_COUNT];
55 this.sourceTypes[BYTE] = Byte.class;
56 this.sourceTypes[DOUBLE] = Double.class;
57 this.sourceTypes[FLOAT] = Float.class;
58 this.sourceTypes[INTEGER] = Integer.class;
59 this.sourceTypes[LONG] = Long.class;
60 this.sourceTypes[SHORT] = Short.class;
61 this.sourceTypes[BOOLEAN] = Boolean.class;
62 this.targetTypes = new Class[1];
63 this.targetTypes[0] = Short.TYPE;
64 }
65
66 /***
67 * Converts the specified object "obj" into an object of a class "class1".
68 */
69 protected Object convert(Object obj, Class class1) throws InvalidDataTypeException, UnsupportedTypeException {
70 System.out.println("StringToPrimitiveShortConverter: emtpy method");
71 return null;
72 }
73
74 public final short convert(Number obj, String className) throws InvalidDataTypeException, UnsupportedTypeException {
75 return obj.shortValue();
76 }
77
78 public final short convert(Boolean obj, String className) throws InvalidDataTypeException, UnsupportedTypeException {
79 return (short)((obj.booleanValue() == true) ? 1 : 0);
80 }
81 }
This page was automatically generated by Maven