Methods Summary |
---|
public static ImpsErrorInfo | checkResultError(Primitive response)Checks if the response primitive indicates successful.
PrimitiveElement result = response.getElement(ImpsTags.Result);
if (result == null) {
return null;
}
String resultCode = result.getChild(ImpsTags.Code).getContents();
if (!ImpsConstants.SUCCESS_CODE.equals(resultCode)) {
PrimitiveElement descElem = result.getChild(ImpsTags.Description);
String errorDesc = (descElem == null) ? "" : descElem.getContents();
int statusCode = parseInt(resultCode, ImErrorInfo.ILLEGAL_SERVER_RESPONSE);
return new ImpsErrorInfo(statusCode, errorDesc, response);
}
return null;
|
static synchronized java.lang.String | genSessionCookie()
if(sSessionCookie == null) {
Random random = new Random();
sSessionCookie = System.currentTimeMillis() + "" + random.nextInt();
}
return sSessionCookie + (sSessionCookieNumber++);
|
public static java.util.Map | getClientInfo()
return Collections.unmodifiableMap(sClientInfo);
|
public static boolean | isFalse(java.lang.String value)Checks if a string is a boolean value of false in IMPS.
return ImpsConstants.FALSE.equalsIgnoreCase(value);
|
public static boolean | isQualifiedPresence(PrimitiveElement elem)Check whether the presence element has a qualified attribute value.
An attribute value is invalid when:
1. An attribute is authorized but not yet updated for the first time
2. The user wants to indicate that the value of the attribute is unknown.
if (null == elem || null == elem.getChild(ImpsTags.Qualifier)) {
return false;
}
return ImpsUtils.isTrue(elem.getChildContents(ImpsTags.Qualifier));
|
public static boolean | isTrue(java.lang.String value)Checks if a string is a boolean value of true IMPS.
// TODO: v1.2 doesn't support ClientContentLimit
sClientInfo = new HashMap<String, String>();
sClientInfo.put(ImpsTags.ClientType, ImpsClientCapability.getClientType());
sClientInfo.put(ImpsTags.ClientProducer, ImpsConstants.CLIENT_PRODUCER);
sClientInfo.put(ImpsTags.ClientVersion, ImpsConstants.CLIENT_VERSION);
return ImpsConstants.TRUE.equalsIgnoreCase(value);
|
public static int | parseInt(java.lang.String s, int defaultValue)
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
// ignore
return defaultValue;
}
|
public static long | parseLong(java.lang.String s, long defaultValue)
try {
return Long.parseLong(s);
} catch (NumberFormatException e) {
// ignore
return defaultValue;
}
|
public static java.lang.String | toImpsBool(boolean isTrue)Return the IMPS String presentation of the boolean value
if (isTrue) {
return ImpsConstants.TRUE;
}
return ImpsConstants.FALSE;
|
public static java.lang.String | trim(java.lang.String str)Returns a copy of the string, with leading and trailing whitespace
omitted. Unlike the standard trim which just removes '\u0020'(the space
character), it removes all possible leading and trailing whitespace
character.
if (null == str || "".equals(str))
return str;
int strLen = str.length();
int start = 0;
while (start < strLen && Character.isWhitespace(str.charAt(start)))
start++;
int end = strLen - 1;
while (end >= 0 && Character.isWhitespace(str.charAt(end)))
end--;
if (end < start)
return "";
str = str.substring(start, end + 1);
return str;
|