Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: mobile/jmsapi/Id_class.java


1   /** Java class "Id_class.java" generated from Poseidon for UML.
2    *  Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
3    *  Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
4    */
5   package mobile.jmsapi;
6   
7   import java.util.Vector;
8   import mobile.protocol.Reply;
9   import mobile.protocol.Request;
10  import mobile.Library;
11  import mobile.bearer.http.Protocol;
12  
13  /**
14   * <p>
15   * This is parent class for all classes in the jmsapi package.
16   * </p>
17   */
18  public abstract class Id_class implements Protocol{
19  
20    ///////////////////////////////////////
21    // attributes
22  
23  
24  /**
25   * <p>
26   * Represents vector of created instances of this class
27   * </p>
28   */
29      static private Vector instances = new Vector();
30  
31      public int id;
32  
33    ////////////////////////////////////////////
34    // operations
35  
36    protected void log(String s){
37           System.out.println(s);
38      }
39  
40  /**
41   * <p>
42   * "subclass responsibility" method - should return QUEUE in QueueSession and
43   * TOPIC in TopicSession
44   * </p><p>
45   *
46   * @return a proper bit mask for Requests
47   * </p>
48   */
49    protected abstract int TYPE_MASK();
50  
51  
52    /**
53     * <p>
54     *   call a Library.getRequestManager().processRequest() method, with proper
55     *   atributes
56     * </p>
57     * <p>
58     * @param _code is code of a request sent do MobileRequestManager
59     * </p><p>
60     * @return a processRequest() result
61     *
62     */
63    protected Reply request(int _code)
64      throws Throwable
65    {
66      Request   req = new Request();
67      req.code = _code;
68      return Library.getRequestManager().processRequest(req);
69    }
70  
71    /**
72     * <p>
73     *   call a Library.getRequestManager().processRequest() method, with proper
74     *   atributes
75     * </p>
76     * <p>
77     * @param req is a request sent to MobileRequestManager
78     * </p><p>
79     * @return a processRequest() result
80     *
81     */
82  
83    protected Reply request(Request req)
84      throws Throwable
85    {
86      return Library.getRequestManager().processRequest(req);
87    }
88  
89    /**
90     * <p>
91     *   call a Library.getRequestManager().processRequest() method, with proper
92     *   atributes
93     * </p>
94     * <p>
95     * @param _code is code of a request sent do MobileRequestManager
96     * @param obj1 is an object put on a 1st place in the request data array
97     * </p><p>
98     * @return a processRequest() result
99     */
100   protected Reply request(int _code, Object obj1)
101     throws Throwable
102   {
103     Request req = new Request();
104     Object[] data;
105     req.code = _code;
106     data = new Object[1];
107     data[0] = obj1;
108     req.setData(data);
109     return Library.getRequestManager().processRequest(req);
110   }
111 
112   /**
113    * <p>
114    *   call a Library.getRequestManager().processRequest() method, with proper
115    *   atributes
116    * </p>
117    * <p>
118    * @param _code is code of a request sent do MobileRequestManager
119    * @param obj1 is an object put on a 1st place in the request data array
120    * @param obj2 is an object put on a 2nd place in the request data array
121    * </p><p>
122    * @return a processRequest() result
123    */
124   protected Reply request(int _code, Object obj1, Object obj2)
125     throws Throwable
126   {
127     Request req = new Request();
128     Object[] data;
129     req.code = _code;
130     data = new Object[2];
131     data[0] = obj1;
132     data[1] = obj2;
133     req.setData(data);
134     return Library.getRequestManager().processRequest(req);
135   }
136 
137   /**
138    * <p>
139    *   call a Library.getRequestManager().processRequest() method, with proper
140    *   atributes
141    * </p>
142    * <p>
143    * @param _code is code of a request sent do MobileRequestManager
144    * @param obj1 is an object put on a 1st place in the request data array
145    * @param obj2 is an object put on a 2nd place in the request data array
146    * @param obj3 is an object put on a 3rd place in the request data array
147    * </p><p>
148    * @return a processRequest() result
149    */
150   protected Reply request(int _code, Object obj1, Object obj2, Object obj3)
151     throws Throwable
152   {
153     Request   req = new Request();
154     Object[]  data;
155     req.code = _code;
156     data = new Object[3];
157     data[0] = obj1;
158     data[1] = obj2;
159     data[2] = obj3;
160     req.setData(data);
161     return Library.getRequestManager().processRequest(req);
162   }
163 
164   /**
165    * <p>
166    *   call a Library.getRequestManager().processRequest() method, with proper
167    *   atributes
168    * </p>
169    * <p>
170    * @param _code is code of a request sent do MobileRequestManager
171    * @param obj1 is an object put on a 1st place in the request data array
172    * @param obj2 is an object put on a 2nd place in the request data array
173    * @param obj3 is an object put on a 3rd place in the request data array
174    * @param obj4 is an object put on a 4th place in the request data array
175    * </p><p>
176    * @return a processRequest() result
177    */
178   protected Reply request(int _code, Object obj1, Object obj2, Object obj3, Object obj4)
179     throws Throwable
180   {
181     Request   req = new Request();
182     Object[]  data;
183     req.code = _code;
184       data = new Object[4];
185       data[0] = obj1;
186       data[1] = obj2;
187       data[2] = obj3;
188       data[3] = obj4;
189       req.setData(data);
190       return Library.getRequestManager().processRequest(req);
191   }
192 
193   /**
194    * <p>
195    *   call a Library.getRequestManager().processRequest() method, with proper
196    *   atributes
197    * </p>
198    * <p>
199    * @param _code is code of a request sent do MobileRequestManager
200    * @param obj1 is an object put on a 1st place in the request data array
201    * @param obj2 is an object put on a 2nd place in the request data array
202    * @param obj3 is an object put on a 3rd place in the request data array
203    * @param obj4 is an object put on a 4th place in the request data array
204    * @param obj5 is an object put on a 5th place in the request data array
205    * </p><p>
206    * @return a processRequest() result
207    */
208   protected Reply request(int _code, Object obj1, Object obj2, Object obj3, Object obj4, Object obj5)
209     throws Throwable
210   {
211     Request   req = new Request();
212     Object[]  data;
213     req.code = _code;
214     data = new Object[1];
215     data[0] = obj1;
216     data[1] = obj2;
217     data[2] = obj3;
218     data[3] = obj4;
219     data[4] = obj5;
220     req.setData(data);
221     return Library.getRequestManager().processRequest(req);
222   }
223 
224   /**
225    * <p>
226    * Find an object of this class with a specified id. id atribute is unique
227    * among all instances of this class and it's subclasses
228    * </p><p>
229    * @param _id is a specified id
230    * </p>
231    * <p>
232    * @return an object with specified id, or null if none was found
233    * </p>
234    */
235   static public Id_class getObject(int _id)
236   {
237     for (int i = 0; i < instances.size(); i++)
238     {
239       if (( (Id_class) instances.elementAt(i)).id == _id)
240         return (Id_class) instances.elementAt(i);
241     }
242     return null;
243   }
244 
245   protected long strToLong(String str)
246   {
247     long val = 0;
248 
249     for ( int pos = 0; pos < str.length(); pos ++)
250     {
251       val *= 10;
252       val += (((int) str.charAt(pos)) - 48);
253     }
254 
255     return val;
256   }
257 
258   protected boolean strToBool(String str)
259   {
260     if (str.trim().equals("true"))
261       return true;
262     return false;
263   }
264 
265 
266   Id_class ()
267   {
268      instances.addElement(this);
269   }
270 } // end Id_class
271 
272 
273 
274 
275