KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > test > xmlrpc > TypeMap


1 /******************************************************************************
2  * TypeMap.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.test.xmlrpc;
11
12 import java.util.*;
13
14 public class TypeMap
15 {
16     Calendar mycal = Calendar.getInstance();
17
18     public class Box
19     {
20         public int dimensions[];
21         public long bgcolor;
22         public String JavaDoc name;
23
24         public Box(int h, int w, long bc, String JavaDoc str)
25         {
26             dimensions = new int[2];
27             dimensions[0] = w;
28             dimensions[1] = h;
29             bgcolor = bc;
30             name = str;
31         }
32     };
33
34     public TypeMap()
35     {}
36
37     // METHODS
38

39
40     public boolean getBool()
41
42     {
43         return mycal.getFirstDayOfWeek() == Calendar.SUNDAY;
44     }
45
46     public Map getProperties()
47     {
48         return System.getProperties();
49     }
50
51     public List getList()
52     {
53         Locale lc[] = Calendar.getAvailableLocales();
54         List loc_lst = Arrays.asList(lc);
55
56         Vector cl = new Vector();
57
58         for (int i = 0, n = loc_lst.size(); i < n; ++i)
59         {
60             String JavaDoc dc = ((Locale)loc_lst.get(i)).getDisplayCountry();
61             if (!dc.equals("")) cl.add(dc);
62         }
63
64         return cl;
65     }
66
67     public String JavaDoc getString()
68     {
69         return mycal.getTime().toString();
70     }
71
72     public int getInt()
73     {
74         return mycal.get(Calendar.YEAR);
75     }
76
77     public double getDouble()
78     {
79         return Math.sin(Math.PI/4);
80     }
81
82     public Box getObject()
83     {
84         return new Box(100, 200, 0xe055cd, "rect1");
85     }
86
87     public ObjectMapper getMappedObject()
88     {
89         return new ObjectMapper(100, 200, 0xe055cd, "rect1");
90     }
91
92     public void getVoid()
93     {
94         System.err.println("getVoid called!");
95     }
96
97     // Argument mapping testers
98

99
100     public boolean callWithArg(Object JavaDoc obj, String JavaDoc obj_type)
101     {
102         boolean match = false;
103         try
104         {
105             if (Class.forName(obj_type) == obj.getClass())
106                 match = true;
107         }
108         catch (Throwable JavaDoc ex)
109         {
110         }
111         return match;
112     }
113
114     public boolean callWithInt(int n)
115     {
116         return true;
117     }
118
119     public boolean callWithDouble(double d)
120     {
121         return true;
122     }
123
124     public boolean callWithBoolean(boolean b)
125     {
126         return true;
127     }
128
129     public boolean callWithList(List l)
130     {
131         return true;
132     }
133
134     public boolean callWithMap(Map m)
135     {
136         return true;
137     }
138 }
Popular Tags