01: // Copyright (c) 2001 Per M.A. Bothner and Brainfood Inc.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.expr;
05:
06: import gnu.lists.Convert;
07:
08: /** Override gnu.lists.Convert to use Kawa number and Char classes. */
09:
10: public class KawaConvert extends Convert {
11: public static Convert instance = new KawaConvert();
12:
13: public static Convert getInstance() {
14: return instance;
15: }
16:
17: public static void setInstance(Convert value) {
18: instance = value;
19: };
20:
21: public Object charToObject(char ch) {
22: return gnu.text.Char.make(ch);
23: }
24:
25: public char objectToChar(Object obj) {
26: return ((gnu.text.Char) obj).charValue();
27: }
28:
29: public Object byteToObject(byte value) {
30: return gnu.math.IntNum.make(value);
31: }
32:
33: public Object shortToObject(short value) {
34: return gnu.math.IntNum.make(value);
35: }
36:
37: public Object intToObject(int value) {
38: return gnu.math.IntNum.make(value);
39: }
40:
41: public Object longToObject(long value) {
42: return gnu.math.IntNum.make(value);
43: }
44:
45: public Object byteToObjectUnsigned(byte value) {
46: return gnu.math.IntNum.make(value & 0xFF);
47: }
48:
49: public Object shortToObjectUnsigned(short value) {
50: return gnu.math.IntNum.make(value & 0xFFFF);
51: }
52:
53: public Object intToObjectUnsigned(int value) {
54: return gnu.math.IntNum.make((long) value & 0xFFFFFFFFL);
55: }
56:
57: public Object longToObjectUnsigned(long value) {
58: return gnu.math.IntNum.makeU(value);
59: }
60:
61: public Object floatToObject(float value) {
62: return gnu.math.DFloNum.make(value);
63: }
64:
65: public Object doubleToObject(double value) {
66: return gnu.math.DFloNum.make(value);
67: }
68:
69: }
|