|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
net.rim.device.api.xml.jaxp.WBXMLWriter
public class WBXMLWriter
This class implements a WBXML writer as a SAX parser handler. The writer can be passed to
any parser and will write WBXML to the specified OutputStream.
The three methods
setTagTable(String[] tagTable),
setAttrStartTable(String[] attrStartTable), and
setAttrValueTable(String[] attrValueTable)
are typically used to set up the tag table, the attribute-name table, and
and the attribute-value table for generating the corresponding WBXML.
| Field Summary |
|---|
| Fields inherited from interface net.rim.device.api.xml.WBXMLConstants |
|---|
CHARSET_ISO_8859_1, CHARSET_UTF_8, END, ENTITY, EXT_0, EXT_1, EXT_2, EXT_I_0, EXT_I_1, EXT_I_2, EXT_T_0, EXT_T_1, EXT_T_2, ISO_8859_1, LITERAL, LITERAL_A, LITERAL_AC, LITERAL_C, OPAQUE, PI, PUBLIC_ID_UNKNOWN, PUBLIC_ID_WML10, PUBLIC_ID_WML11, PUBLIC_ID_WML12, PUBLIC_ID_WML13, STR_I, STR_T, SWITCH_PAGE, UTF_8, WBXML_1_1, WBXML_1_2, WBXML_1_3 |
| Constructor Summary | ||
|---|---|---|
WBXMLWriter(OutputStream out)
This class implements a WBXML writer as a SAX parser handler. |
||
| Method Summary | ||
|---|---|---|
void |
cdataSection(char[] text,
int offset,
int length)
Receives notification of a CDATA section. |
|
void |
characters(char[] ch,
int start,
int length)
Receive notification of character data inside an element. |
|
void |
comment(char[] text,
int offset,
int length)
Receives notification of a comment. |
|
void |
defaultAttribute(String element,
String attribute,
String defaultValue)
Receives notification of a default attribute value declaration. |
|
void |
endDTD(String name,
String publicIdStr,
String systemId,
String body)
|
|
void |
endDocument()
|
|
void |
endElement(String uri,
String localName,
String qName)
Receive notification of the end of an element. |
|
void |
endEntityReference(String name)
Receives notification of the end of an entity reference. |
|
void |
entityDecl(String name,
String value)
Receives notification of a general entity declaration. |
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Receive notification of ignorable whitespace in element content. |
|
void |
processingInstruction(String target,
String data)
Receive notification of a processing instruction. |
|
InputSource |
resolveEntity(String publicId,
String systemId)
Resolve an external entity. |
|
void |
setAttrStartTable(int page,
String[] attrStartTable)
Sets the attribute start table for a given page. |
|
void |
setAttrStartTable(String[] attrStartTable)
Sets the attribute start table. |
|
void |
setAttrValueTable(int page,
String[] attrValueTable)
Sets the attribute value table for a given page. |
|
void |
setAttrValueTable(String[] attrValueTable)
Sets the attribute value table. |
|
void |
setCharset(int charset)
Sets the character set for the written WBXML. |
|
void |
setEncoding(String encoding)
Sets the encoding for the written WBXML. |
|
void |
setEntityResolver(EntityResolver entityResolver)
Sets the entity resolver for this writer. |
|
void |
setPublicID(int publicID)
Sets the written WBXML public ID. |
|
void |
setTagTable(int page,
String[] tagTable)
Sets the tag code page for a given page. |
|
void |
setTagTable(String[] tagTable)
Sets the tag code page. |
|
void |
setVersion(int version)
Sets the version of the WBXML. |
|
void |
startAndEndElement(String eUri,
String localName,
String qName,
Attributes attributes)
Handles self-closing element. |
|
void |
startDTD()
Implementation of RIMExtendedHandler |
|
void |
startDocument()
|
|
void |
startElement(String eUri,
String localName,
String qName,
Attributes attributes)
Receive notification of the start of an element. |
|
void |
startEntityReference(String name,
String publicId,
String systemId)
Receives notification of the start of an entity reference. |
|
void |
startPrefixMapping(String prefix,
String uri)
Receive notification of the start of a Namespace mapping. |
|
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endPrefixMapping, error, fatalError, notationDecl, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WBXMLWriter(OutputStream out)
This class implements a WBXML writer as a SAX parser handler. The writer can be passed to
any parser and will write WBXML to the specified OutputStream.
out - A stream to receive the WBXML output.| Method Detail |
|---|
public void setCharset(int charset)
Sets the character set for the written WBXML.
charset - The character set. It must be one of
net.rim.device.api.xml.WBXMLConstants.CHARSET_ISO_8859_1 or
net.rim.device.api.xml.WBXMLConstants.CHARSET_UTF_8.net.rim.device.api.xml.WBXMLConstants.public void setPublicID(int publicID)
Sets the written WBXML public ID.
publicId - The public ID. It must be one of
net.rim.device.api.xml.WBXMLConstants.PUBLIC_ID_WML10,
net.rim.device.api.xml.WBXMLConstants.PUBLIC_ID_WML11,
net.rim.device.api.xml.WBXMLConstants.PUBLIC_ID_WML12, or
net.rim.device.api.xml.WBXMLConstants.PUBLIC_ID_WML13.net.rim.device.api.xml.WBXMLConstants.public void setVersion(int version)
Sets the version of the WBXML.
The - version. It must be one of
net.rim.device.api.xml.WBXMLConstants.WBXML_1_1,
net.rim.device.api.xml.WBXMLConstants.WBXML_1_2, or
net.rim.device.api.xml.WBXMLConstants.WBXML_1_3.net.rim.device.api.xml.WBXMLConstants.
public void setTagTable(int page,
String[] tagTable)
Sets the tag code page for a given page.
page - The page number.tagTable - The tags.
IllegalArgumentException - if page exceeds 256 (the
tag code space has only 256 code pages.), or if page
equals 255 (the code page 255 is reserved for implementation-specific
or experimental use.), or if the number of elements in the input table
tagTable exceeds 59.public void setTagTable(String[] tagTable)
Sets the tag code page.
tagTable - The tags.
IllegalArgumentException - if the number of pages needed exceeds the maximum
number of code pages allowed (255).
public void setAttrStartTable(int page,
String[] attrStartTable)
Sets the attribute start table for a given page.
page - The page number.attrStartTable - The attribute names to define.
IllegalArgumentException - if page exceeds 256 (the
attribute start code space has only 256 code pages.), or if page
equals 255 (the code page 255 is reserved for implementation-specific
or experimental use.), or if the number of elements in the input table
attrStartTable exceeds 118.public void setAttrStartTable(String[] attrStartTable)
Sets the attribute start table.
attrStartTable - The attribute names to define.
IllegalArgumentException - if the number of pages needed exceeds the maximum
number of code pages allowed (255).
public void setAttrValueTable(int page,
String[] attrValueTable)
Sets the attribute value table for a given page.
page - The page number.attrValueTable - The attribute values to define.
IllegalArgumentException - if page exceeds 256 (the
attribute value code space has only 256 code pages.), or if page
equals 255 (the code page 255 is reserved for implementation-specific
or experimental use.), or if the number of elements in the input table
attrValueTable exceeds 118.public void setAttrValueTable(String[] attrValueTable)
Sets the attribute value table.
attrValueTable - The attribute values to define.
IllegalArgumentException - if the number of pages needed exceeds the maximum
number of code pages allowed (255).
public void setEncoding(String encoding)
throws IOException
Sets the encoding for the written WBXML.
encoding - The encoding. It must be one of
net.rim.device.api.xml.WBXMLConstants.UTF_8 or
net.rim.device.api.xml.WBXMLConstants.ISO_8859_1.
IllegalArgumentException - if the encoding is
not supported for WBXML.
IOExceptionnet.rim.device.api.xml.WBXMLConstants.public void setEntityResolver(EntityResolver entityResolver)
Sets the entity resolver for this writer. If the parser encounters external parsed entities, it asks the writer to resolve them.
entityResolver - The entity resolver.public void startDTD()
startDTD in interface RIMExtendedHandler
public void endDTD(String name,
String publicIdStr,
String systemId,
String body)
throws SAXException
endDTD in interface RIMExtendedHandlername - The document name.publicIdStr - The public ID of the DTD external subset (or null).systemId - The sytem ID of the DTD external subset (or null of no external subset specified).body - The body of the DTD. This includes all characters between .
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
Obtains the token value for the public identifier.
public void comment(char[] text,
int offset,
int length)
throws SAXException
RIMExtendedHandler
comment in interface RIMExtendedHandlertext - The comment characters not including .offset - The start position in the character array.length - The number of characters to use from the character array.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
public void cdataSection(char[] text,
int offset,
int length)
throws SAXException
RIMExtendedHandler
cdataSection in interface RIMExtendedHandlertext - The CDATA characters not including .offset - The start position in the character array.length - The number of characters to use from the character array.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
public void startEntityReference(String name,
String publicId,
String systemId)
throws SAXException
RIMExtendedHandler
startEntityReference in interface RIMExtendedHandlername - The name of the entity.publicId - The public ID of the entity.systemId - The system ID of the entity or null if this is an internal entity
SAXException - Any SAX exception, possibly
wrapping another exception.
public void endEntityReference(String name)
throws SAXException
RIMExtendedHandler
endEntityReference in interface RIMExtendedHandlername - The name of the entity.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
public void entityDecl(String name,
String value)
throws SAXException
RIMExtendedHandler
entityDecl in interface RIMExtendedHandlername - The name of the entity.value - The entity's replacement text.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
public void defaultAttribute(String element,
String attribute,
String defaultValue)
throws SAXException
RIMExtendedHandler
defaultAttribute in interface RIMExtendedHandlerelement - The qualified name of the element.attribute - The qualified name of the attribute.defaultValue - The default attribute value.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.
public void characters(char[] ch,
int start,
int length)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
characters in interface ContentHandlercharacters in class DefaultHandlerch - The characters.start - The start position in the character array.length - The number of characters to use from the
character array.
SAXException - any SAX exception, possibly
wrapping another exceptionDefaultHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method to take specific actions for each chunk of ignorable whitespace (such as adding data to a node or buffer, or printing it to a file).
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class DefaultHandlerch - The whitespace characters.start - The start position in the character array.length - The number of characters to use from the
character array.
SAXException - any SAX exception, possibly
wrapping another exceptionDefaultHandler.ignorableWhitespace(char[], int, int)
public void processingInstruction(String target,
String data)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
processingInstruction in interface ContentHandlerprocessingInstruction in class DefaultHandlertarget - The processing instruction target.data - The processing instruction data, or null if
none is supplied.
SAXException - any SAX exception, possibly
wrapping another exceptionDefaultHandler.processingInstruction(java.lang.String, java.lang.String)
public void startDocument()
throws SAXException
startDocument in interface ContentHandlerstartDocument in class DefaultHandlerSAXException - any SAX exception, possibly
wrapping another exception
public void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class DefaultHandlerSAXException - any SAX exception, possibly
wrapping another exception
public void startAndEndElement(String eUri,
String localName,
String qName,
Attributes attributes)
throws SAXException
Handles self-closing element.
startAndEndElement in interface RIMExtendedHandlerattributes - The specified or defaulted attributes.
SAXException - Thrown if a SAX exception, possibly
wrapping another exception, occurs.net.rim.device.api.xml.jaxp.RIMExtendedDefaultHandler#startAndEndElement.
public void startElement(String eUri,
String localName,
String qName,
Attributes attributes)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
startElement in interface ContentHandlerstartElement in class DefaultHandlereUri - The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName - The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName - The qualified name (with prefix), or the
empty string if qualified names are not available.attributes - The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object.
SAXException - any SAX exception, possibly
wrapping another exceptionDefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(String uri,
String localName,
String qName)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
endElement in interface ContentHandlerendElement in class DefaultHandleruri - The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName - The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName - The qualified name (with prefix), or the
empty string if qualified names are not available.
SAXException - any SAX exception, possibly
wrapping another exceptionDefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void startPrefixMapping(String prefix,
String uri)
throws SAXException
DefaultHandlerBy default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each Namespace prefix scope (such as storing the prefix mapping).
startPrefixMapping in interface ContentHandlerstartPrefixMapping in class DefaultHandlerprefix - The Namespace prefix being declared.uri - The Namespace URI mapped to the prefix.
SAXException - the client may throw
an exception during processingDefaultHandler.startPrefixMapping(java.lang.String, java.lang.String)
public InputSource resolveEntity(String publicId,
String systemId)
throws SAXException,
IOException
DefaultHandlerAlways return null, so that the parser will use the system identifier provided in the XML document. This method implements the SAX default behaviour: application writers can override it in a subclass to do special translations such as catalog lookups or URI redirection.
resolveEntity in interface EntityResolverresolveEntity in class DefaultHandlerpublicId - The public identifer, or null if none is
available.systemId - The system identifier provided in the XML
document.
SAXException - Any SAX exception, possibly
wrapping another exception.
IOException - A Java-specific IO exception,
possibly the result of creating a new InputStream
or Reader for the InputSource.DefaultHandler.resolveEntity(java.lang.String, java.lang.String)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.