public class KQMLParser extends Object implements KQML
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
KQMLmessage
Modifier and Type | Field and Description |
---|---|
private TokenParser |
parser |
ACT, ACTOR, AGENT, BACKSLASH, CLOSE, CONTENT, FROM, IN_REPLY_TO, LANGUAGE, ONTOLOGY, OPEN, QUOTE, RECEIVER, RECEIVERS, REPLY_WITH, SENDER, TO
ACCEPT, ACCEPT_PROPOSAL, ACK, ACTION, ADD_OBSERVER, ADVERTISE, AFFIRMATIVE_REPLY, AGREE, ASSEMBLE, BLANK, CAG_CASA, CANCEL, CD, CFP, CHANGE_MEMBERSHIP, CHAT_MESSAGE, CONCLUDE, CONFIRM, CONSIDER, CONTRACT, CONVERSATION_ID, CREATE, CREATE_CD, CREDITOR, DATA_CASA, DEBTOR, DELETE_CD, DELETE_DATA_CD, DELETE_HISTORY_CD, DELETE_INFO, DESTROY, DISCHARGE, DISCONFIRM, DONE, ENCRYPTION_ALGORITHM, ENTITY, EVALUATE, EVENT, EVENT_ADVERTISEMENT_ADDED, EVENT_ADVERTISEMENT_EVENT, EVENT_ADVERTISEMENT_REMOVED, EVENT_BANNER_CHANGED, EVENT_CD_EVENT, EVENT_CD_NEW_MEMBER, EVENT_CHANGED_COMMANDS, EVENT_CHAT_MESSAGE_RECEIVED, EVENT_CLOSE_PORT, EVENT_DEFERRED_EXECUTION, EVENT_DEFERRED_EXECUTION_DELAYED, EVENT_EXECUTABLE, EVENT_EXITED, EVENT_EXITING, EVENT_FAILED_PERFORMATIVES_UPDATE, EVENT_FIND_INSTANCES, EVENT_GET_CD_PARTICIPANTS, EVENT_GET_DATA_CD, EVENT_GET_HISTORY_CD, EVENT_INSERTED_PERFORMATIVES, EVENT_INVITE_CD, EVENT_JOIN_CD, EVENT_JOIN_CD_FAILED, EVENT_JOIN_CD_REPEATED, EVENT_LAC_EVENT, EVENT_MESSAGE_EVENT, EVENT_MESSAGE_IGNORED, EVENT_MESSAGE_INCOMING, EVENT_MESSAGE_OBSERVED, EVENT_MESSAGE_OUTGOING, EVENT_MESSAGE_PARTICIPANT, EVENT_MESSAGE_RECEIVED, EVENT_MESSAGE_SEND_FAILED, EVENT_MESSAGE_SENT, EVENT_PARTICIPANT_CD, EVENT_POLICY_APPLIED, EVENT_POST_STRING, EVENT_PUT_DATA_CD, EVENT_RECURRING, EVENT_RECURRINGEXECUTABLE, EVENT_REGISTER_INSTANCE, EVENT_REGISTER_INSTANCE_LOCAL, EVENT_REGISTER_INSTANCE_REMOTE, EVENT_REGISTER_TYPE, EVENT_SC_EVENT, EVENT_SC_PERFORM_ACTION, EVENT_SC_START, EVENT_SC_STOP, EVENT_SC_VIOLATION, EVENT_STRATEGY_CHANGED, EVENT_UNREGISTER_INSTANCE, EVENT_UNREGISTER_TYPE, EVENT_UPDATE_URL_CD, EVENT_WITHDRAW_CD, EXECUTE, EXIT, FAILURE, FIND_INSTANCE, FIPA_SL, FORWARD_MESSAGE, GET, GET_ACTS, GET_AGENTS, GET_AGENTS_REGISTERED, GET_AGENTS_RUNNING, GET_CDS, GET_DATA, GET_HISTORY, GET_INFO, GET_MEMBERS, GET_NAME, GET_ONTOLOGY, GET_YELLOW_PAGES, GUI_ACTION_REQUEST, INFORM, INFORM_IF, INFORM_REF, INFORM_USERS_LIST, INVITE_CD, JOIN_CD, KQML, LAC_CLOSING, LANGUAGE_VERSION, MESSAGE_FORWARDED, METHOD_CALL, MONITOR, NACK, NEGATIVE, NEGATIVE_REPLY, NEW_COMMAND, NOT, NOT_UNDERSTOOD, NOTIFY, NOTIFY_COMPLETE, NOTIFY_FAILURE, NULL, OBSERVE, OBSERVE_MEMBERSHIP, OBSERVE_MESSAGES, ONTOLOGY_VERSION, PERFORM, PERFORMATIVE, PERSISTENT_ACTION, PETITION, PHYSICAL_ACT, PING, POSITIVE, PRIORITY, PROPAGATE, PROPOSE, PROXY, PUT_DATA, QUERY_IF, QUERY_IF_REPLY, QUERY_REF, QUERY_REF_REPLY, RECIPIENTS, REFUSE, REGISTER, REGISTER_AGENTTYPE, REGISTER_INSTANCE, REGISTER_YELLOWPAGES, REJECT_PROPOSAL, RELEASE, REMOVE_ADVERTISEMENT, REPLY, REPLY_BY, REPLY_TO, REQUEST, REQUEST_ACK, REQUEST_AKA_MAC_LIST, REQUEST_USER_LIST, REQUEST_WHEN, REQUEST_WHENEVER, RESOLVE_URL, RUN, RUN_AGENT, SAVE_INFO, SEARCH, SECURITY_AGENT_USERS_LIST, SECURITY_AUTHENTICATE, SECURITY_AUTHORIZE, SECURITY_CHECK_ACCESS, SECURITY_VOTE, SENSE, SIGNATURE, SIGNATURE_METHOD, SPECIFIC_AKA_LIST, SUBSCRIBE, SUCCESS, TIME_MESSAGE, TIMEOUT_NEVER, TOP, UNADVERTISE, UNREGISTER, UNREGISTER_AGENTTYPE, UNREGISTER_INSTANCE, UPDATE, VERIFY, WITHDRAW_CD, XML
Constructor and Description |
---|
KQMLParser()
Constructs a new parser that is ready parse new strings.
|
KQMLParser(String string)
Constructs a new parser with the string specified.
|
Modifier and Type | Method and Description |
---|---|
private String |
checkToken(String token,
String compare) |
KQMLMessage |
getKQMLMessage()
Parses the previously specified string
|
protected String |
getToken()
Retrieves the next token from the internal
TokenParser object
and throws an exception if none exists. |
protected String |
getToken(String compare)
Retrieves the next token from the internal
TokenParser object
and throws an exception if none exists. |
protected String |
getTokenAcceptingParenGroups(String compare) |
void |
parse()
Parses the previously specified string for the purpose of validation as a
KQML message.
|
void |
reset(String string)
Resets the parser and sets the about-to-be-parsed string to the one specified.
|
private TokenParser parser
public KQMLParser()
public KQMLParser(String string)
string
- string to parse as a KQML messagepublic void reset(String string)
string
- string to parse as a KQML messagepublic KQMLMessage getKQMLMessage() throws KQMLMessageFormatException
MLMessageFormatException
- when the string does not appear to be a
KQML message and cannot be parsed as such.KQMLMessageFormatException
public void parse() throws KQMLMessageFormatException
MLMessageFormatException
- when the string does not appear to be a
KQML message and cannot be parsed as such.KQMLMessageFormatException
protected String getToken(String compare) throws KQMLMessageFormatException
TokenParser
object
and throws an exception if none exists. This method is used primarily to
fetch perspectives and parameters' value after that parameter has been
identified. If the value is null, as in no perspective or no value was
found, then the string is considered to be mal-formed. compare
- if not null
the token retrieved is compared this value, if it
does not match an exception is thrown. This can be used to automatically throw
an exception when a string is expected.
If null
an exception is thrown only if the end of message marker 'CLOSE'
is found.MLMessageFormatException
- no parameter value was found where there should
have been some value. Poorly formatted string?KQMLMessageFormatException
KQML.CLOSE
protected String getTokenAcceptingParenGroups(String compare) throws KQMLMessageFormatException
KQMLMessageFormatException
private String checkToken(String token, String compare) throws KQMLMessageFormatException
KQMLMessageFormatException
protected String getToken() throws KQMLMessageFormatException
TokenParser
object
and throws an exception if none exists. This is used to fetch the next
parameter from the target string. If the token is null, as in no parameter
was found, then the string is considered to be mal-formed since this method
should only be called when other parameters are expected in the string. MLMessageFormatException
- no parameter value was found where there should
have been some value. Poorly formatted string?KQMLMessageFormatException