jade.lang.acl
Class StringACLCodec

java.lang.Object
  |
  +--jade.lang.acl.StringACLCodec

public class StringACLCodec
extends java.lang.Object
implements ACLCodec

This class implements the FIPA String codec for ACLMessages. Notice that it is not possible to convey a sequence of bytes over a StringACLCodec because the bytes with the 8th bit ON cannot properly converted into a char.

Version:
$Date: 2002/12/11 09:37:45 $ $Revision: 2.9 $
Author:
Fabio Bellifemine - CSELT S.p.A.

Inner classes inherited from class jade.lang.acl.ACLCodec
ACLCodec.CodecException
 
Field Summary
static java.lang.String NAME
           
 
Constructor Summary
StringACLCodec()
          constructor for the codec.
StringACLCodec(java.io.Reader r, java.io.Writer w)
          constructor for the codec.
 
Method Summary
 ACLMessage decode()
          decode and parses the next message from the Reader passed in the constructor.
 ACLMessage decode(byte[] data)
          Recovers an ACLMessage object back from raw data, using the specific message representation to interpret the byte sequence.
 byte[] encode(ACLMessage msg)
          If the content of the message is a byteSequence, then this method encodes the content in Base64 and automatically sets the value of the encoding slot.
 java.lang.String getName()
          Query the name of the message representation handled by this Codec object.
 void write(ACLMessage msg)
          encodes the message and writes it into the Writer passed in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
Constructor Detail

StringACLCodec

public StringACLCodec()
constructor for the codec. The standard input is used as an input stream of ACL messages. The standard output is used to write encoded ACL messages.

StringACLCodec

public StringACLCodec(java.io.Reader r,
                      java.io.Writer w)
constructor for the codec.
Method Detail

decode

public ACLMessage decode()
                  throws ACLCodec.CodecException
decode and parses the next message from the Reader passed in the constructor.
Returns:
the ACLMessage
Throws:
ACLCodec.CodecException - if any Exception occurs during the parsing/reading operation

write

public void write(ACLMessage msg)
encodes the message and writes it into the Writer passed in the constructor. Notice that this method does not call flush on the writer.

encode

public byte[] encode(ACLMessage msg)
If the content of the message is a byteSequence, then this method encodes the content in Base64 and automatically sets the value of the encoding slot.
Specified by:
encode in interface ACLCodec
See Also:
ACLCodec.encode(ACLMessage msg)

decode

public ACLMessage decode(byte[] data)
                  throws ACLCodec.CodecException
Description copied from interface: ACLCodec
Recovers an ACLMessage object back from raw data, using the specific message representation to interpret the byte sequence.
Specified by:
decode in interface ACLCodec
See Also:
ACLCodec.decode(byte[] data)

getName

public java.lang.String getName()
Description copied from interface: ACLCodec
Query the name of the message representation handled by this Codec object. The FIPA standard representations have a name starting with "fipa.acl.rep.".
Specified by:
getName in interface ACLCodec
Returns:
the name of this encoding according to the FIPA specifications