ProtocolPushImplpublic class ProtocolPushImpl extends com.sun.midp.io.j2me.push.ProtocolPush Implementation of push behaviour. |
Fields Summary |
---|
private static ProtocolPushImpl | pushInstanceInstance |
Methods Summary |
---|
public void | checkRegistration(java.lang.String connection, java.lang.String midlet, java.lang.String filter)Called when registration is checked.
// for cbs: protocol, the filter is ignored
if (connection.startsWith("cbs://")) {
return;
}
if (filter == null || filter.length() == 0) {
throw new IllegalArgumentException("NULL of empty filter");
}
/*
* for sms: the filter is compared against MSISDN field of the push message
*
* msisdn ::== "+" digits | digits
* digit ::== "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
* digits ::== digit | digit digits
*
* '*' and '?' are allowed according to the MIDP spec.
*/
for (int i = (filter.charAt(0) == '+") ? 1 : 0;
i < filter.length(); i++) {
char ch = filter.charAt(i);
if ((ch >= '0" && ch <= '9") || ch == '*" || ch == '?") {
continue;
}
throw new IllegalArgumentException("Invalid filter: " + filter);
}
| protected com.sun.midp.io.j2me.push.ProtocolPush | getInstance()Get instance of this class.
if (pushInstance == null) {
pushInstance = new ProtocolPushImpl();
}
return (ProtocolPush)pushInstance;
| public void | registerConnection(com.sun.midp.midlet.MIDletSuite midletSuite, java.lang.String connection, java.lang.String midlet, java.lang.String filter)Called when registration is established.
checkIsNotHost(connection, false);
if (connection.startsWith("sms://")) {
try {
Class.forName("com.sun.midp.io.j2me.sms.Protocol");
} catch (ClassNotFoundException e) {
throw new ConnectionNotFoundException(
"Connection not supported");
}
/*
* Check the suite permission for the connection
* and close the connection immediately.
*/
try {
midletSuite.checkForPermission(Permissions.SMS_SERVER,
connection);
} catch (InterruptedException ie) {
throw new InterruptedIOException(
"Interrupted while trying to ask the user permission");
}
} else if (connection.startsWith("cbs://")) {
try {
Class.forName("com.sun.midp.io.j2me.cbs.Protocol");
} catch (ClassNotFoundException e) {
throw new ConnectionNotFoundException(
"Connection not supported");
}
try {
midletSuite.checkForPermission(Permissions.CBS_SERVER,
connection);
} catch (InterruptedException ie) {
throw new InterruptedIOException(
"Interrupted while trying to ask the user permission");
}
}
|
|