Methods Summary |
---|
public void | addCompletionListener(MessageCompletionListener l)
completionListeners.add(l);
|
public void | complete(boolean bOnlyNonDelayed, boolean success, java.lang.Object data)Sets the message complete and fires of the listeners who are waiting
for a response.
//System.out.println("complete called with " + bOnlyNonDelayed);
if (completed || (bOnlyNonDelayed && completeDelayed)) {
//System.out.println("exit early" + completed);
return;
}
triggerCompletionListeners(success, data);
completed = true;
|
public void | debug(java.lang.String message)
debug(message, null);
|
public void | debug(java.lang.String message, java.lang.Throwable t)
try {
AEDiagnosticsLogger diag_logger = AEDiagnostics.getLogger("v3.CMsgr");
String out = "[" + getListenerId() + ":" + getOperationId() + "] "
+ message;
diag_logger.log(out);
if (t != null) {
diag_logger.log(t);
}
if (com.aelitis.azureus.util.Constants.DIAG_TO_STDOUT) {
System.out.println(out);
if (t != null) {
t.printStackTrace();
}
}
} catch (Throwable t2) {
Debug.out(t2);
}
|
public java.util.List | getDecodedArray()
if ( ! isParamArray() ) {
throw new IllegalStateException("Decoded parameter is not a List");
}
return (List) decodedParams;
|
public java.util.List | getDecodedList()
if ( ! isParamList() ) {
throw new IllegalStateException("Decoded parameter is not a List");
}
return (List) decodedParams;
|
public java.util.Map | getDecodedMap()
if ( ! isParamObject() ) {
throw new IllegalStateException("Decoded parameter is not a Map");
}
return (Map) decodedParams;
|
public java.lang.String | getFullMessage()
return sFullMessage;
|
public java.lang.String | getListenerId()
return listenerId;
|
public java.lang.String | getOperationId()
return operationId;
|
public java.lang.String | getParams()
return params;
|
public java.lang.String | getReferer()
return referer;
|
public int | getSequence()
return sequence;
|
public boolean | isParamArray()
return paramType == ARRAY_PARAM;
|
public boolean | isParamList()
return paramType == LIST_PARAM;
|
public boolean | isParamObject()
return paramType == OBJECT_PARAM;
|
protected void | parse()Parses the full message into its component parts.
String text = sFullMessage;
// DJH: StringTokenizer was not used so that listeners
// could define their message format
int delimSeqNum = text.indexOf(MESSAGE_DELIM);
if ( delimSeqNum == -1 ) {
throw new IllegalArgumentException("Message has no delimeters: " + text);
}
if ( delimSeqNum == text.length() - 1 ) {
throw new IllegalArgumentException("Message has no sequence number: " + text);
}
int delimListener = text.indexOf(MESSAGE_DELIM, delimSeqNum + 1);
if ( delimListener == -1 || delimListener == text.length() - 1 ) {
throw new IllegalArgumentException("Message has no listener ID: " + text);
}
try {
sequence = Integer.parseInt(text.substring(delimSeqNum + 1, delimListener));
}
catch ( NumberFormatException e ) {
System.err.println("Plese put the throw back in once souk fixes the seq # bug");
sequence = seqFake++;
//throw new IllegalArgumentException("Message has no sequence number: " + text);
}
int delimOperation = text.indexOf(MESSAGE_DELIM, delimListener + 1);
if ( delimOperation == -1 || delimOperation == text.length() - 1 ) {
// listener ID without operation
throw new IllegalArgumentException("Message has no operation ID: " + text);
}
listenerId = text.substring(delimListener + 1, delimOperation);
int delimParams = text.indexOf(MESSAGE_DELIM, delimOperation + 1);
if ( delimParams == -1 ) {
// operation without parameters
operationId = text.substring(delimOperation + 1);
}
else if ( delimParams == text.length() - 1 ) {
// operation without parameters
operationId = text.substring(delimOperation + 1, delimParams);
params = null;
paramType = NO_PARAM;
decodedParams = null;
}
else {
// operation with parameters
operationId = text.substring(delimOperation + 1, delimParams);
params = text.substring(delimParams + 1);
char leading = params.charAt(0);
try {
switch ( leading ) {
case '{":
paramType = OBJECT_PARAM;
decodedParams = JSONUtils.decodeJSON(params);
break;
case '[":
paramType = ARRAY_PARAM;
Map decodeJSON = JSONUtils.decodeJSON(params);
if (decodeJSON != null) {
decodedParams = decodeJSON.get("value");
} else {
decodedParams = null;
}
break;
default:
paramType = LIST_PARAM;
decodedParams = JSFunctionParametersParser.parse(params);
break;
}
} catch (Exception e) {
decodedParams = null;
}
if (decodedParams == null) {
paramType = NO_PARAM;
}
}
|
public void | removeCompletionListener(MessageCompletionListener l)
completionListeners.remove(l);
|
public void | setCompleteDelayed(boolean bCompleteDelayed)
completeDelayed = bCompleteDelayed;
|
public void | setReferer(java.lang.String referer)
this.referer = referer;
|
public java.lang.String | toString()
return "[" + sequence + "] " + listenerId + "."
+ operationId + "(" + params + ")";
|
private void | triggerCompletionListeners(boolean success, java.lang.Object data)
for (Iterator iterator = completionListeners.iterator(); iterator.hasNext();) {
MessageCompletionListener l = (MessageCompletionListener) iterator.next();
try {
l.completed(success, data);
} catch (Exception e) {
Debug.out(e);
}
}
|