public class StringACLCodec extends Object implements ACLCodec
ACLCodec.CodecException
Modifier and Type | Field and Description |
---|---|
private static String |
BASE64ENCODING_KEY
Key of the user-defined parameter used to signal the automatic JADE
conversion of the content into Base64 encoding
|
private static String |
BASE64ENCODING_VALUE
Value of the user-defined parameter used to signal the automatic JADE
conversion of the content into Base64 encoding
|
private static String |
CONTENT |
private static String |
CONVERSATION_ID |
private static String |
ENCODING |
private static String |
illegalFirstChar |
private static String |
IN_REPLY_TO |
private static String |
LANGUAGE |
static String |
NAME
String constant for the name of the ACL representation managed
by this ACL codec.
|
private static String |
ONTOLOGY |
(package private) Writer |
out |
(package private) ACLParser |
parser |
private static String |
PROTOCOL |
private static String |
RECEIVER |
private static String |
REPLY_BY |
private static String |
REPLY_TO |
private static String |
REPLY_WITH |
private static String |
SENDER |
DEFAULT_CHARSET
Constructor and Description |
---|
StringACLCodec()
constructor for the codec.
|
StringACLCodec(Reader r,
Writer w)
constructor for the codec.
|
Modifier and Type | Method and Description |
---|---|
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.
|
private void |
checkBase64Encoding(ACLMessage msg)
if there was an automatical Base64 encoding, then it performs
automatic decoding.
|
ACLMessage |
decode()
decode and parses the next message from the Reader passed in the
constructor.
|
ACLMessage |
decode(byte[] data,
String charset)
Recovers an
ACLMessage object back from raw data,
using the specific message representation to interpret the byte
sequence. |
AID |
decodeAID()
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.
|
private static String |
escape(String s) |
String |
getName()
Query the name of the message representation handled by this
Codec object. |
private static boolean |
isAWord(String s)
Test if the given string is a legal word using the FIPA ACL spec.
|
private static String |
quotedString(String str)
Take a java String and quote it to form a legal FIPA ACL string.
|
(package private) static String |
toString(ACLMessage msg)
If a user-defined parameter contain a blank char inside, then it is skipped for FIPA-compatibility
|
void |
write(ACLMessage msg)
encodes the message and writes it into the Writer passed in the
constructor.
|
public static final String NAME
private static final String BASE64ENCODING_KEY
private static final String BASE64ENCODING_VALUE
private static final String SENDER
private static final String RECEIVER
private static final String CONTENT
private static final String REPLY_WITH
private static final String IN_REPLY_TO
private static final String REPLY_TO
private static final String LANGUAGE
private static final String ENCODING
private static final String ONTOLOGY
private static final String REPLY_BY
private static final String PROTOCOL
private static final String CONVERSATION_ID
ACLParser parser
Writer out
private static final String illegalFirstChar
public StringACLCodec()
private void checkBase64Encoding(ACLMessage msg)
public ACLMessage decode() throws ACLCodec.CodecException
ACLCodec.CodecException
- if any Exception occurs during the
parsing/reading operationpublic AID decodeAID() throws ACLCodec.CodecException
ACLCodec.CodecException
public void write(ACLMessage msg)
flush
on the writer.private static String quotedString(String str)
static String toString(ACLMessage msg)
ACLMessage.toString()
public byte[] encode(ACLMessage msg, String charset)
public ACLMessage decode(byte[] data, String charset) throws ACLCodec.CodecException
ACLCodec
ACLMessage
object back from raw data,
using the specific message representation to interpret the byte
sequence.decode
in interface ACLCodec
data
- The byte sequence containing the encoded message.charset
- Charset encoding to use (e.g. US_ASCII, UTF-8, etc)ACLMessage
object, built from the raw
data.ACLCodec.CodecException
- If some kind of syntax error occurs.ACLCodec#decode(byte[] data)
public String getName()
ACLCodec
Codec
object. The FIPA standard representations have
a name starting with "fipa.acl.rep."
.public static void appendACLExpression(StringBuffer str, String slotName, String slotValue)
private static boolean isAWord(String s)