public void message(FipaMessage aFipaMessage) {
FIPA.Envelope[] envelopes = aFipaMessage.messageEnvelopes;
byte[] payload = aFipaMessage.messageBody;
Envelope env = new Envelope();
// Read all the envelopes sequentially, so that later slots
// overwrite earlier ones.
for(int e = 0; e < envelopes.length; e++) {
FIPA.Envelope IDLenv = envelopes[e];
// Read in the 'to' slot
if(IDLenv.to.length > 0)
env.clearAllTo();
for(int i = 0; i < IDLenv.to.length; i++) {
AID id = unmarshalAID(IDLenv.to[i]);
env.addTo(id);
}
// Read in the 'from' slot
if(IDLenv.from.length > 0) {
AID id = unmarshalAID(IDLenv.from[0]);
env.setFrom(id);
}
// Read in the 'intended-receiver' slot
if(IDLenv.intendedReceiver.length > 0)
env.clearAllIntendedReceiver();
for(int i = 0; i < IDLenv.intendedReceiver.length; i++) {
AID id = unmarshalAID(IDLenv.intendedReceiver[i]);
env.addIntendedReceiver(id);
}
// Read in the 'encrypted' slot
//if(IDLenv.encrypted.length > 0)
// env.clearAllEncrypted();
//for(int i = 0; i < IDLenv.encrypted.length; i++) {
// String word = IDLenv.encrypted[i];
// env.addEncrypted(word);
//}
// Read in the other slots
if(IDLenv.comments.length() > 0)
env.setComments(IDLenv.comments);
if(IDLenv.aclRepresentation.length() > 0)
env.setAclRepresentation(IDLenv.aclRepresentation);
if(IDLenv.payloadLength > 0)
env.setPayloadLength(new Long(IDLenv.payloadLength));
if(IDLenv.payloadEncoding.length() > 0)
env.setPayloadEncoding(IDLenv.payloadEncoding);
if(IDLenv.date.length > 0) {
Date d = unmarshalDateTime(IDLenv.date[0]);
env.setDate(d);
}
// Read in the 'received' stamp
if(IDLenv.received.length > 0)
env.addStamp(unmarshalReceivedObj(IDLenv.received[0]));
// Read in the 'user-defined properties' slot
if(IDLenv.userDefinedProperties.length > 0)
env.clearAllProperties();
for(int i = 0; i < IDLenv.userDefinedProperties.length; i++) {
env.addProperties(unmarshalProperty(IDLenv.userDefinedProperties[i]));
}
}
//String tmp = "\n\n"+(new java.util.Date()).toString()+" RECEIVED IIOP MESSAGE"+ "\n" + env.toString() + "\n" + new String(payload);
//System.out.println(tmp);