KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > rmi > interfaces > Parameters


1 package com.daffodilwoods.rmi.interfaces;
2
3 import java.io.Externalizable JavaDoc;
4 import java.io.ObjectOutput JavaDoc;
5 import java.io.IOException JavaDoc;
6 import java.io.ObjectInput JavaDoc;
7
8 public class Parameters
9     implements Externalizable JavaDoc {
10   Object JavaDoc parameters;
11   /**
12    * 0 - Object[]
13    * 1 - HashMap
14    * 2 - _VariableValues
15    */

16
17   int type;
18   public static int OBJECT_ARRAY = 0;
19   public static int HASHMAP = 1;
20   public static int VARIABLEVALUE = 2;
21   boolean blobClobPresent;
22
23   public Parameters() {
24   }
25
26   public void setObjects(Object JavaDoc params) {
27     parameters = params;
28   }
29
30   public void setType(int type0) {
31     type = type0;
32   }
33
34   public void setBlobClobPresent(){
35     blobClobPresent = true;
36   }
37   public Object JavaDoc getObjects() {
38     return parameters;
39   }
40
41   public int getType() {
42     return type;
43   }
44
45   public boolean isBlobClobPresent(){
46     return blobClobPresent;
47   }
48
49   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
50     out.writeInt(type);
51     boolean noParameters = parameters == null;
52     out.writeBoolean(noParameters);
53     out.writeBoolean(blobClobPresent);
54     if (noParameters == false) {
55       if (type == OBJECT_ARRAY) {
56         Object JavaDoc[] params = (Object JavaDoc[]) parameters;
57         out.writeInt(params.length);
58         for (int i = 0; i < params.length; i++) {
59           out.writeObject(params[i]);
60         }
61       }
62       else {
63         out.writeInt(0);
64         out.writeObject(parameters);
65       }
66     }
67   }
68
69   public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
70       ClassNotFoundException JavaDoc {
71     type = in.readInt();
72     boolean noParameters = in.readBoolean();
73     blobClobPresent = in.readBoolean();
74     if (noParameters == false) {
75       int count = in.readInt();
76       if (type == OBJECT_ARRAY) {
77         Object JavaDoc[] params = new Object JavaDoc[count];
78         for (int i = 0; i < count; i++) {
79           params[i] = in.readObject();
80         }
81         parameters = params;
82       }
83       else
84         parameters = in.readObject();
85     }
86   }
87
88 }
89
Popular Tags