Methods Summary |
---|
public boolean | Do() return false;
|
public void | addArg(java.lang.Object arg)
argList.addElement(arg);
|
public java.util.Vector | argList()
Vector listCopy = (Vector)argList.clone();
return listCopy;
|
public java.lang.Object | getArg(int idx)
Object arg = null;
if (idx < argList.size()) {
arg = argList.elementAt(idx);
}
return arg;
|
public boolean | handles(java.lang.String msgId) return false;
|
public java.lang.String | messageID()
return id;
|
public Message | newCopy() return new Message(id);
|
public boolean | readArgs(java.io.InputStream ins)
boolean success = true;
// Read tokens until the "end-of-message" token is seen.
try {
DataInputStream din = new DataInputStream(ins);
String token = din.readUTF();
while (token.compareTo(endToken) != 0) {
// If an object argument is coming, read with an ObjectInputStream
if (token.compareTo("#OBJ") == 0) {
// Next argument is a non-string Object
ObjectInputStream oin = new ObjectInputStream(ins);
Object oarg = oin.readObject();
addArg(oarg);
}
else {
// The string itself is the argument, so save it
addArg(token);
}
token = din.readUTF();
}
}
catch (Exception e) {
// Failed to read complete argument list.
success = false;
}
return success;
|
public void | setId(java.lang.String mid)
id = mid;
|
public boolean | writeArgs(java.io.OutputStream outs)
int len = argList.size();
boolean success = true;
// Write each argument in order
try {
DataOutputStream dout = new DataOutputStream(outs);
for (int i = 0; i < len; i++) {
Object arg = argList.elementAt(i);
try {
String sarg = (String)arg;
System.out.println("m: sending token \"" + sarg + "\"");
dout.writeUTF(sarg);
}
catch (ClassCastException ce) {
// Argument wasn't a string, so send it as an object
System.out.println("m: sending object");
dout.writeUTF("#OBJ");
ObjectOutputStream oout = new ObjectOutputStream(outs);
oout.writeObject(arg);
}
catch (Exception e) {
// Something else went wrong, indicate failure
success = false;
System.out.println("m: Got exception writing args");
}
}
// Finish with the end-of-message token
dout.writeUTF(endToken);
}
catch (IOException e) {
success = false;
}
return success;
|