Package jade.lang.acl
Class StringACLCodec
- java.lang.Object
-
- jade.lang.acl.StringACLCodec
-
- All Implemented Interfaces:
ACLCodec
public class StringACLCodec extends 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$ $Revision$
- Author:
- Fabio Bellifemine - CSELT S.p.A., Nicolas Lhuillier - Motorola
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jade.lang.acl.ACLCodec
ACLCodec.CodecException
-
-
Field Summary
Fields Modifier and Type Field Description static StringNAMEString constant for the name of the ACL representation managed by this ACL codec.-
Fields inherited from interface jade.lang.acl.ACLCodec
DEFAULT_CHARSET
-
-
Constructor Summary
Constructors Constructor Description StringACLCodec()constructor for the codec.StringACLCodec(Reader r, Writer w)constructor for the codec.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidappendACLExpression(StringBuffer str, String slotName, String slotValue)append to the passed StringBuffer the slot name and value separated by a blank char and followed by a newline.ACLMessagedecode()decode and parses the next message from the Reader passed in the constructor.ACLMessagedecode(byte[] data, String charset)Recovers anACLMessageobject back from raw data, using the specific message representation to interpret the byte sequence.AIDdecodeAID()Parse an agent identifier, without it being included within an ACL message.byte[]encode(ACLMessage msg, String charset)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.StringgetName()Query the name of the message representation handled by thisCodecobject.voidwrite(ACLMessage msg)encodes the message and writes it into the Writer passed in the constructor.
-
-
-
Field Detail
-
NAME
public static final String NAME
String constant for the name of the ACL representation managed by this ACL codec.- See Also:
- Constant Field Values
-
-
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
-
decodeAID
public AID decodeAID() throws ACLCodec.CodecException
Parse an agent identifier, without it being included within an ACL message.- Throws:
ACLCodec.CodecException
-
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 callflushon the writer.
-
encode
public byte[] encode(ACLMessage msg, String charset)
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.
-
decode
public ACLMessage decode(byte[] data, String charset) throws ACLCodec.CodecException
Description copied from interface:ACLCodecRecovers anACLMessageobject back from raw data, using the specific message representation to interpret the byte sequence.- Specified by:
decodein interfaceACLCodec- Parameters:
data- The byte sequence containing the encoded message.charset- Charset encoding to use (e.g. US_ASCII, UTF-8, etc)- Returns:
- A new
ACLMessageobject, built from the raw data. - Throws:
ACLCodec.CodecException- If some kind of syntax error occurs.- See Also:
ACLCodec#decode(byte[] data)
-
getName
public String getName()
Description copied from interface:ACLCodecQuery the name of the message representation handled by thisCodecobject. The FIPA standard representations have a name starting with"fipa.acl.rep.".
-
appendACLExpression
public static void appendACLExpression(StringBuffer str, String slotName, String slotValue)
append to the passed StringBuffer the slot name and value separated by a blank char and followed by a newline. If the value contains a blank, then it is quoted. if the value is null or its length is zero, the method does nothing.
-
-