Fields Summary |
---|
String | IDThe content handler ID.
Lengths up to 256 characters MUST be supported.
The ID may be null . |
private String[] | typesThe types that are supported by this content handler.
If there are no types registered, the this field MUST either be
null or refer to an empty array . |
private String[] | suffixesThe suffixes of URLs that are supported by this content handler.
If there are no suffixes, then this field MUST be null .
The suffixes MUST include any and all punctuation. For example,
the string ".png" . |
private String[] | actionsThe actions that are supported by this content handler.
If there are no actions, then this field MSUT be null . |
javax.microedition.content.ActionNameMap[] | actionnamesThe action names that are defined by this content handler. |
final int | seqnoThe sequence number of this instance; monotonic increasing. |
private static int | nextSeqnoThe next sequence number to assign. |
RequestListenerImpl | listenerImplThe RequestListenerImpl; if a listener is set. |
public static final String[] | ZERO_STRINGSEmpty String array to return when needed. |
private static final javax.microedition.content.ActionNameMap[] | ZERO_ACTIONNAMESEmpty ActionNameMap to return when needed. |
private static final String | LOCALE_PROPProperty name for the current locale. |
int | storageIdThe MIDlet suite storagename that contains the MIDlet. |
String | appnameThe Name from parsing the Property for the MIDlet
with this classname. |
String | versionThe Version parsed from MIDlet-Version attribute. |
String | classnameThe application class name that implements this content
handler. Note: Only the application that registered the class
will see the classname; for other applications the value will be
null . |
String | authorityThe authority that authenticated this ContentHandler. |
private String[] | accessRestrictedThe accessRestrictions for this ContentHandler. |
int | registrationMethodIndicates content handler registration method:
dynamic registration from the API, static registration from install
or native content handler.
Must be similar to enum in jsr211_registry.h |
static final int | REGISTERED_STATICContent handler statically registered during installation |
static final int | REGISTERED_DYNAMICDynamically registered content handler via API |
static final int | REGISTERED_NATIVENative platform content handler |
int | requestCallsCount of requests retrieved via {@link #getRequest}. |
boolean | removedInstance is a registration or unregistration.
An unregistration needs only storageId and classname. |
Methods Summary |
---|
public int | accessAllowedCount()Gets the number of IDs allowed access by the content handler.
The number of IDs must be equal to the length of the array
of accessRestricted passed to
{@link javax.microedition.content.Registry#register Registry.register}.
If the number of IDs is zero then all applications and
content handlers are allowed access.
return getAccessRestricted().length;
|
public void | cancelGetRequest()Cancel a pending getRequest .
This method will force a Thread blocked in a call to the
getRequest method for the same application
context to return early.
If no Thread is blocked; this call has no effect.
InvocationStore.cancel();
|
public static java.lang.String[] | copy(java.lang.String[] strings)Checks that all of the string references are non-null
and not zero length. If either the argument is null or
is an empty array the default ZERO length string array is used.
if (strings != null && strings.length > 0) {
String[] copy = new String[strings.length];
for (int i = 0; i < strings.length; i++) {
if (strings[i].length() == 0) {
throw new IllegalArgumentException("string length is 0");
}
copy[i] = strings[i];
}
return strings;
} else {
return ZERO_STRINGS;
}
|
private static javax.microedition.content.ActionNameMap[] | copy(javax.microedition.content.ActionNameMap[] actionnames)Checks that all of the actionname references are non-null.
if (actionnames != null && actionnames.length > 0) {
ActionNameMap[] copy = new ActionNameMap[actionnames.length];
for (int i = 0; i < actionnames.length; i++) {
// Check for null
if (actionnames[i] == null) {
throw new NullPointerException();
}
copy[i] = actionnames[i];
}
return copy;
} else {
return ZERO_ACTIONNAMES;
}
|
public static javax.microedition.content.ContentHandler[] | copy(javax.microedition.content.ContentHandler[] handlers)Copy an array of ContentHandlers making a new ContentHandler
for each ContentHandler. Make copies of any mutiple object.
ContentHandler[] h = new ContentHandler[handlers.length];
for (int i = 0; i < handlers.length; i++) {
h[i] = handlers[i];
}
return h;
|
boolean | equals(com.sun.midp.content.ContentHandlerImpl other)Compare two ContentHandlerImpl's for equality.
Classname, storageID, and seqno must match.
return seqno == other.seqno &&
storageId == other.storageId &&
classname.equals(other.classname);
|
protected boolean | finish(InvocationImpl invoc, int status)Finish this Invocation and set the status for the response.
The finish method may only be called when this
Invocation
has a status of ACTIVE or HOLD .
The content handler may modify the URL, type, action, or
arguments before invoking finish .
If the method {@link Invocation#getResponseRequired} returns
true then the modified
values MUST be returned to the invoking application.
int currst = invoc.getStatus();
if (currst != Invocation.ACTIVE && currst != Invocation.HOLD) {
throw new IllegalStateException("Status already set");
}
// If ACTIVE or HOLD it must be an InvocationImpl
return invoc.finish(status);
|
private java.lang.String | get(int index, java.lang.String[] strings)Gets the value at index in the string array.
if (index < 0 || index >= strings.length) {
throw new IndexOutOfBoundsException();
}
return strings[index];
|
public java.lang.String | getAccessAllowed(int index)Gets the nth ID of an application or content handler
allowed access to this content handler.
The ID returned for each index must be the equal to the ID
at the same index in the accessAllowed array passed to
{@link javax.microedition.content.Registry#register Registry.register}.
return get(index, getAccessRestricted());
|
private java.lang.String[] | getAccessRestricted()Get accesses for the content handler.
if (accessRestricted == null) {
accessRestricted =
RegistryStore.getArrayField(ID, RegistryStore.FIELD_ACCESSES);
}
return accessRestricted;
|
public java.lang.String | getAction(int index)Get the nth action supported by the content handler.
return get(index, getActions());
|
public int | getActionCount()Get the number of actions supported by the content handler.
return getActions().length;
|
public javax.microedition.content.ActionNameMap | getActionNameMap()Get the mapping of actions to action names for the current
locale supported by this content handler. The behavior is
the same as invoking {@link #getActionNameMap} with the current
locale.
String locale = System.getProperty(LOCALE_PROP);
return (locale == null) ? null : getActionNameMap(locale);
|
public javax.microedition.content.ActionNameMap | getActionNameMap(java.lang.String locale)Get the mapping of actions to action names for the requested
locale supported by this content handler.
The locale is matched against the available locales.
If a match is found it is used. If an exact match is
not found, then the locale string is shortened and retried
if either of the "_" or "-" delimiters is present.
The locale is shortened by retaining only the characters up to
but not including the last occurence of the delimiter
(either "_" or "-").
The shortening and matching is repeated as long as the string
contains one of the delimiters.
Effectively, this will try the full locale and then try
without the variant or country code, if they were present.
while (locale.length() > 0) {
for (int i = 0; i < getActionNames().length; i++) {
if (locale.equals(getActionNames()[i].getLocale())) {
return getActionNames()[i];
}
}
int lastdash = locale.lastIndexOf('-");
if (lastdash < 0) {
break;
}
locale = locale.substring(0, lastdash);
}
return null;
|
public javax.microedition.content.ActionNameMap | getActionNameMap(int index)Gets the nth ActionNameMap supported by the
content handler.
if (index < 0 || index >= getActionNames().length) {
throw new IndexOutOfBoundsException();
}
return getActionNames()[index];
|
public int | getActionNameMapCount()Gets the number of action name maps supported by the content handler.
return getActionNames().length;
|
private javax.microedition.content.ActionNameMap[] | getActionNames()Get actions names for the content handler.
if (actionnames == null) {
String [] locales =
RegistryStore.getArrayField(ID, RegistryStore.FIELD_LOCALES);
String [] names =
RegistryStore.getArrayField(ID, RegistryStore.FIELD_ACTION_MAP);
actionnames = new ActionNameMap[locales.length];
for (int index = 0; index < locales.length; index++) {
String [] temp = new String[getActions().length];
System.arraycopy(names,
index * getActions().length,
temp,
0,
getActions().length);
actionnames[index] = new ActionNameMap(getActions(),
temp,
locales[index]);
}
}
return actionnames;
|
java.lang.String[] | getActions()Get actions supported by the content handler.
if (actions == null) {
actions =
RegistryStore.getArrayField(ID, RegistryStore.FIELD_ACTIONS);
}
return actions;
|
public java.lang.String | getAppName()Returns the name used to present this content handler to a user.
The value is extracted from the normal installation information
about the content handler application.
loadAppData();
return appname;
|
public java.lang.String | getAuthority()Gets the name of the authority that authorized this application.
This value MUST be null unless the device has been
able to authenticate this application.
If non-null , it is the string identifiying the
authority. For example,
if the application was a signed MIDlet, then this is the
"subject" of the certificate used to sign the application.
The format of the authority for X.509 certificates is defined
by the MIDP Printable Representation of X.509 Distinguished
Names as defined in class
javax.microedition.pki.Certificate .
loadAppData();
return authority;
|
public java.lang.String | getID()Get the content handler ID. The ID uniquely identifies the
application which contains the content handler.
After registration and for every registered handler,
the ID MUST NOT be null .
return ID;
|
public InvocationImpl | getRequest(boolean wait, javax.microedition.content.Invocation invocation)Gets the next Invocation request pending for this
ContentHandlerServer.
The method can be unblocked with a call to
{@link #cancelGetRequest cancelGetRequest}.
The application should process the Invocation as
a request to perform the action on the content.
// Application has tried to get a request; reset cleanup flags on all
if (requestCalls == 0) {
InvocationStore.setCleanup(storageId, classname, false);
}
requestCalls++;
InvocationImpl invoc =
InvocationStore.getRequest(storageId, classname, wait);
if (invoc != null) {
// Keep track of number of requests delivered to the application
AppProxy.requestForeground(invoc.invokingSuiteId,
invoc.invokingClassname,
invoc.suiteId,
invoc.classname);
invoc.invocation = invocation;
}
return invoc;
|
public java.lang.String | getSuffix(int index)Get the nth suffix supported by the content handler.
return get(index, getSuffixes());
|
public int | getSuffixCount()Get the number of suffixes supported by the content handler.
return getSuffixes().length;
|
java.lang.String[] | getSuffixes()Get suffixes supported by the content handler.
if (suffixes == null) {
suffixes =
RegistryStore.getArrayField(ID, RegistryStore.FIELD_SUFFIXES);
}
return suffixes;
|
public java.lang.String | getType(int index)Get the nth type supported by the content handler.
return get(index, getTypes());
|
public int | getTypeCount()Get the number of types supported by the content handler.
return getTypes().length;
|
java.lang.String[] | getTypes()Get types supported by the content handler.
if (types == null) {
types = RegistryStore.getArrayField(ID, RegistryStore.FIELD_TYPES);
}
return types;
|
public java.lang.String | getVersion()Gets the version number of this content handler.
The value is extracted from the normal installation information
about the content handler application.
loadAppData();
return version;
|
private boolean | has(java.lang.String string, java.lang.String[] strings, boolean ignoreCase)Determines if the string is in the array.
int len = string.length(); // Throw NPE if null
for (int i = 0; i < strings.length; i++) {
if (strings[i].length() == len &&
string.regionMatches(ignoreCase, 0, strings[i], 0, len)) {
return true;
}
}
return false;
|
public boolean | hasAction(java.lang.String action)Determine if a action is supported by the content handler.
return has(action, getActions(), false);
|
public boolean | hasSuffix(java.lang.String suffix)Determine if a suffix is supported by the content handler.
return has(suffix, getSuffixes(), true);
|
public boolean | hasType(java.lang.String type)Determine if a type is supported by the content handler.
return has(type, getTypes(), true);
|
public boolean | isAccessAllowed(java.lang.String ID)Determines if an ID MUST be allowed access by the content handler.
Access MUST be allowed if the ID has a prefix that exactly matches
any of the IDs returned by {@link #getAccessAllowed}.
The prefix comparison is equivalent to
java.lang.String.startsWith .
ID.length(); // check for null
if (getAccessRestricted().length == 0) {
return true;
}
for (int i = 0; i < getAccessRestricted().length; i++) {
if (ID.startsWith(getAccessRestricted()[i])) {
return true;
}
}
return false;
|
private void | loadAppData()Initializes fields retrieved from AppProxy 'by-demand'.
if (appname == null) {
try {
AppProxy app =
AppProxy.getCurrent().forApp(storageId, classname);
appname = app.getApplicationName();
version = app.getVersion();
authority = app.getAuthority();
} catch (Throwable t) {
}
if (appname == null) {
appname = "";
}
}
|
protected void | requestNotify()Notify the request listener of a pending request.
Overridden by subclass.
|
public void | setListener(javax.microedition.content.RequestListener listener)Set the listener to be notified when a new request is
available for this content handler. The request MUST
be retrieved using {@link #getRequest}.
synchronized (this) {
if (listener != null || listenerImpl != null) {
// Create or update the active listener thread
if (listenerImpl == null) {
listenerImpl =
new RequestListenerImpl(this, listener);
} else {
listenerImpl.setListener(listener);
}
// If the listener thread no longer needed; clear it
if (listener == null) {
listenerImpl = null;
}
}
}
|
public java.lang.String | toString()Debug routine to print the values.
if (AppProxy.LOG_INFO) {
StringBuffer sb = new StringBuffer(80);
sb.append("CH:");
sb.append(" classname: ");
sb.append(classname);
sb.append(", removed: ");
sb.append(removed);
sb.append(", flag: ");
sb.append(registrationMethod);
sb.append(", types: ");
toString(sb, types);
sb.append(", ID: ");
sb.append(ID);
sb.append(", suffixes: ");
toString(sb, suffixes);
sb.append(", actions: ");
toString(sb, actions);
sb.append(", access: ");
toString(sb, accessRestricted);
sb.append(", suiteID: ");
sb.append(storageId);
sb.append(", authority: ");
sb.append(authority);
sb.append(", appname: ");
sb.append(appname);
return sb.toString();
} else {
return super.toString();
}
|
private void | toString(java.lang.StringBuffer sb, java.lang.String[] strings)Append all of the strings inthe array to the string buffer.
if (strings == null) {
sb.append("null");
return;
}
for (int i = 0; i < strings.length; i++) {
if (i > 0) {
sb.append(':");
}
sb.append(strings[i]);
}
|