|
|||||||||
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.XMLWriter
public class XMLWriter
This class implements an XML writer as a SAX parser handler. The writer can be passed to any parser and will write XML to the specified OutputStream. For example, an XML pretty-printer can be written as follows:
XMLWriter writer = new XMLWriter( outStream ); writer.setPrettyPrint(); SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); parser.parse( inputStream, writer );
Constructor Summary | ||
---|---|---|
XMLWriter(OutputStream out)
Creates an XMLWriter. |
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 publicId,
String systemId,
String body)
Receives notification of the end of the document type definition (DTD). |
|
void |
endDocument()
Receive notification of the end of the document. |
|
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 |
setEntityResolver(EntityResolver entityResolver)
Sets the entity resolver for this writer. |
|
void |
setExpandingEntities(boolean expand)
Indicates whether this writer should expand entities or print them as entity references, such as &ent;. |
|
void |
setPreserveSpacing()
Configure this writer to print XML as close to the original as possible. |
|
void |
setPrettyPrint()
Configures this writer to pretty-print the XML. |
|
void |
setPrintCompressedOutput()
Configures this writer to print XML with no unnecessary whitespace. |
|
void |
startAndEndElement(String uri,
String localName,
String qName,
Attributes attributes)
Receives notification of the start and end of an element. |
|
void |
startDTD()
Receives notification of the start of the document type definition (DTD). |
|
void |
startDocument()
Receive notification of the beginning of the document. |
|
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 XMLWriter(OutputStream out)
out
- A stream to receive the XML output.Method Detail |
---|
public void setPrettyPrint()
public void setPrintCompressedOutput()
public void setPreserveSpacing()
Note: This is the default.
public void setEntityResolver(EntityResolver entityResolver)
entityResolver
- The entity resolver.public void setExpandingEntities(boolean expand)
expand
- true to expand entities; false otherwise.public void startDTD()
RIMExtendedHandler
startDTD
in interface RIMExtendedHandler
This method is only public for implementation reasons. Do not use or override.
public void endDTD(String name, String publicId, String systemId, String body) throws SAXException
RIMExtendedHandler
endDTD
in interface RIMExtendedHandler
name
- The document name.publicId
- 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.This method is only public for implementation reasons. Do not use or override.
public void comment(char[] text, int offset, int length) throws SAXException
RIMExtendedHandler
comment
in interface RIMExtendedHandler
text
- 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.This method is only public for implementation reasons. Do not use or override.
public void cdataSection(char[] text, int offset, int length) throws SAXException
RIMExtendedHandler
cdataSection
in interface RIMExtendedHandler
text
- 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.This method is only public for implementation reasons. Do not use or override.
public void startEntityReference(String name, String publicId, String systemId) throws SAXException
RIMExtendedHandler
startEntityReference
in interface RIMExtendedHandler
name
- 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.This method is only public for implementation reasons. Do not use or override.
public void endEntityReference(String name) throws SAXException
RIMExtendedHandler
endEntityReference
in interface RIMExtendedHandler
name
- The name of the entity.
SAXException
- Thrown if a SAX exception, possibly
wrapping another exception, occurs.This method is only public for implementation reasons. Do not use or override.
public void entityDecl(String name, String value) throws SAXException
RIMExtendedHandler
entityDecl
in interface RIMExtendedHandler
name
- The name of the entity.value
- The entity's replacement text.
SAXException
- Thrown if a SAX exception, possibly
wrapping another exception, occurs.This method is only public for implementation reasons. Do not use or override.
public void defaultAttribute(String element, String attribute, String defaultValue) throws SAXException
RIMExtendedHandler
defaultAttribute
in interface RIMExtendedHandler
element
- 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.This method is only public for implementation reasons. Do not use or override.
public void characters(char[] ch, int start, int length) throws SAXException
DefaultHandler
By 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 ContentHandler
characters
in class DefaultHandler
ch
- 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 exceptionThis method is only public for implementation reasons. Do not use or override.
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
DefaultHandler
By 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 ContentHandler
ignorableWhitespace
in class DefaultHandler
ch
- 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 exceptionThis method is only public for implementation reasons. Do not use or override.
public void processingInstruction(String target, String data) throws SAXException
DefaultHandler
By 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 ContentHandler
processingInstruction
in class DefaultHandler
target
- The processing instruction target.data
- The processing instruction data, or null if
none is supplied.
SAXException
- any SAX exception, possibly
wrapping another exceptionThis method is only public for implementation reasons. Do not use or override.
public void startDocument() throws SAXException
DefaultHandler
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).
startDocument
in interface ContentHandler
startDocument
in class DefaultHandler
SAXException
- any SAX exception, possibly
wrapping another exceptionThis method is only public for implementation reasons. Do not use or override.
public void endDocument() throws SAXException
DefaultHandler
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).
endDocument
in interface ContentHandler
endDocument
in class DefaultHandler
SAXException
- any SAX exception, possibly
wrapping another exceptionThis method is only public for implementation reasons. Do not use or override.
public void startAndEndElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
RIMExtendedHandler
startAndEndElement
in interface RIMExtendedHandler
attributes
- The specified or defaulted attributes.
SAXException
- Thrown if a SAX exception, possibly
wrapping another exception, occurs.This method is only public for implementation reasons. Do not use or override.
public void startElement(String eUri, String localName, String qName, Attributes attributes) throws SAXException
DefaultHandler
By 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 ContentHandler
startElement
in class DefaultHandler
eUri
- 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 exceptionThis method is only public for implementation reasons. Do not use or override.
public void endElement(String uri, String localName, String qName) throws SAXException
DefaultHandler
By 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 ContentHandler
endElement
in class DefaultHandler
uri
- 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 exceptionThis method is only public for implementation reasons. Do not use or override.
public void startPrefixMapping(String prefix, String uri) throws SAXException
DefaultHandler
By 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 ContentHandler
startPrefixMapping
in class DefaultHandler
prefix
- The Namespace prefix being declared.uri
- The Namespace URI mapped to the prefix.
SAXException
- the client may throw
an exception during processingThis method is only public for implementation reasons. Do not use or override.
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
DefaultHandler
Always 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 EntityResolver
resolveEntity
in class DefaultHandler
publicId
- 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.This method is only public for implementation reasons. Do not use or override.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal