A ContentHandler provides the details of a
content handler registration.
Each ContentHandler contains the ID, content types, suffixes,
actions, and action names. It provides the ID,
authority, and application name and version of the content handler.
The values are set when the content handler is
{@link Registry#register register}ed.
ContentHandler instances are immutable and thread safe.
Content handlers can only be changed by re-registering which
returns a new ContentHandler instance.
The registered content handlers can be queried using the query methods
of {@link Registry}.
Content Types
For the purposes of this API, content types are simple opaque
strings that are NOT case-sensitive. All comparisons are performed
using case-insensitive string comparisons.
By convention, the {@link #UNIVERSAL_TYPE UNIVERSAL_TYPE}
is used to indicate any type. A content
handler that can support any type of content should include it as
one of types when it is registered. Any application can get the list
of universal handlers with a query for the UNIVERSAL_TYPE .
Handlers with this type are only returned
by Registry.findHandler or
Registry.forType if the type requested
is equal to UNIVERSAL_TYPE .
The most common content types are MIME types.
RFC-2046
defines the
Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types.
It defines the general structure of the MIME media typing system and
defines an initial set of media types.
RFC-2048
describes the specific IANA registration procedures for
MIME-related facilities.
Other strings may be used as content types, but only if the type
system semantics are well defined. An example of where the type system
semantics are well defined is in the XML
messaging schema.
Suffixes
A content handler can declare a set of suffixes that identify
content it can handle based on the syntax of a URL.
The suffix is a case-insensitive string that
includes punctuation, for example ".png".
For some URLs and content storage mechanisms, such as
file systems, the content type is not readily available.
To accommodate this,
a mapping can be used to associate URL suffixes with content
handlers. The common practice in file systems is to map filename
extensions to content types. For example, a file ending in
.png
can be identified as content type image/png . This
mapping is used if the content access mechanism does not support
content typing or if the content type is not available from
the content.
For the http
protocol, that supports a mechanism to identify the content type,
the suffix matching MUST be used to identify content handlers if
the type is not defined for a particular URL.
RFC 2396 -
Uniform Resource Identifiers (URI): Generic Syntax
describes the syntax of URI's and the path component.
Suffix matching consists of comparing each of the registered
suffixes with the last n characters of the path component of the URL,
where n is the length of the suffix.
The comparison is case-insensitive and is done using the equivalent of
java.lang.String.regionMatches .
If multiple suffixes would match, the longest suffix that
matches is used.
Actions
Each content handler registers a set of actions
it supports.
Actions are Java strings representing semantic functions the
content handler can perform on every content type and suffix
registered.
Actions are case-sensitive strings.
The set of actions is extensible but applications should
choose from the following actions when appropriate:
{@link ContentHandler#ACTION_OPEN open},
{@link ContentHandler#ACTION_EDIT edit},
{@link ContentHandler#ACTION_NEW new},
{@link ContentHandler#ACTION_SEND send},
{@link ContentHandler#ACTION_SAVE save},
{@link ContentHandler#ACTION_EXECUTE execute},
{@link ContentHandler#ACTION_SELECT select},
{@link ContentHandler#ACTION_INSTALL install},
{@link ContentHandler#ACTION_PRINT print}, and
{@link ContentHandler#ACTION_STOP stop}.
The content handler application should provide localized action
names for each action.
The action names are used by applications that need to present the
possible actions to users in locale appropriate terminology.
A mapping for each action to action name should be created
for each locale using the
{@link ActionNameMap#ActionNameMap ActionNameMap.ActionNameMap} method.
The action name maps for all the locales supported by the
content handler MUST be included when the content handler is
registered.
The attribute Microedition-Handler-<n>-<locale>
is used to declare action names in the application packaging.
Locale Strings
A locale string MUST include a language code,
and may include a country code and a variant.
The values are separated by a delimiter defined by the Java
runtime environment.
For MIDP, locale strings follow the definition of the
system property microedition.locale and
the delimiter MUST be a hyphen ("-" = U+002D).
The values for the language, country code and variant are not
validated.
Application developers should refer to
ISO-639-1 for language codes and to ISO-3166-1 for country codes. |