| java.lang.Object org.jasig.portal.serialize.BaseMarkupSerializer org.jasig.portal.serialize.XMLSerializer
XMLSerializer | public class XMLSerializer extends BaseMarkupSerializer (Code) | | Implements an XML serializer supporting both DOM and SAX pretty
serializing. For usage instructions see
Serializer .
If an output stream is used, the encoding is taken from the
output format (defaults to UTF-8). If a writer is
used, make sure the writer uses the same encoding (if applies)
as specified in the output format.
The serializer supports both DOM and SAX. SAX serializing is done by firing
SAX events and using the serializer as a document handler. DOM serializing is done
by calling
XMLSerializer.serialize(Document) or by using DOM Level 3
org.w3c.dom.ls.LSSerializer and
serializing with
org.w3c.dom.ls.LSSerializer.write ,
org.w3c.dom.ls.LSSerializer.writeToString .
If an I/O exception occurs while serializing, the serializer
will not throw an exception directly, but only throw it
at the end of serializing (either DOM or SAX's
org.xml.sax.DocumentHandler.endDocument .
For elements that are not specified as whitespace preserving,
the serializer will potentially break long text lines at space
boundaries, indent lines, and serialize elements on separate
lines. Line terminators will be regarded as spaces, and
spaces at beginning of line will be stripped.
author: Assaf Arkin author: Rahul Srivastava author: Elena Litani IBM version: $Revision: 36683 $ $Date: 2006-08-23 15:08:00 -0700 (Wed, 23 Aug 2006) $ See Also: Serializer |
Method Summary | |
protected void | checkUnboundNamespacePrefixedNode(Node node) DOM Level 3:
Check a node to determine if it contains unbound namespace prefixes. | public void | endElement(String namespaceURI, String localName, String rawName) | public void | endElement(String tagName) | public void | endElementIO(String namespaceURI, String localName, String rawName) | protected String | getEntityRef(int ch) | protected void | printEscaped(String source) | protected void | printText(String text, boolean preserveSpace, boolean unescaped) | protected void | printText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped) | protected void | printXMLChar(int ch) | public boolean | reset() | protected void | serializeElement(Element elem) Called to serialize a DOM element. | public void | setNamespaces(boolean namespaces) This methods turns on namespace fixup algorithm during
DOM serialization. | public void | setOutputFormat(OutputFormat format) | protected void | startDocument(String rootTagName) Called to serialize the document's DOCTYPE by the root element.
The document type declaration must name the root element,
but the root element is only known when that element is serialized,
and not at the start of the document.
This method will check if it has not been called before (
XMLSerializer._started ),
will serialize the document type declaration, and will serialize all
pre-root comments and PIs that were accumulated in the document
(see
XMLSerializer.serializePreRoot ). | public void | startElement(String namespaceURI, String localName, String rawName, Attributes attrs) | public void | startElement(String tagName, AttributeList attrs) |
DEBUG | final protected static boolean DEBUG(Code) | | |
fLocalNSBinder | protected NamespaceSupport fLocalNSBinder(Code) | | stores all namespace bindings on the current element
|
fNSBinder | protected NamespaceSupport fNSBinder(Code) | | stores namespaces in scope
|
fNamespacePrefixes | protected boolean fNamespacePrefixes(Code) | | Controls whether namespace prefixes will be printed out during serialization
|
fNamespaces | protected boolean fNamespaces(Code) | | Controls whether namespace fixup should be performed during
the serialization.
NOTE: if this field is set to true the following
fields need to be initialized: fNSBinder, fLocalNSBinder, fSymbolTable,
XMLSymbols.EMPTY_STRING, fXmlSymbol, fXmlnsSymbol
|
fSymbolTable | protected SymbolTable fSymbolTable(Code) | | symbol table for serialization
|
XMLSerializer | public XMLSerializer(Writer writer, OutputFormat format)(Code) | | Constructs a new serializer that writes to the specified writer
using the specified output format. If format is null,
will use a default output format.
Parameters: writer - The writer to use Parameters: format - The output format to use, null for the default |
XMLSerializer | public XMLSerializer(OutputStream output, OutputFormat format)(Code) | | Constructs a new serializer that writes to the specified output
stream using the specified output format. If format
is null, will use a default output format.
Parameters: output - The output stream to use Parameters: format - The output format to use, null for the default |
checkUnboundNamespacePrefixedNode | protected void checkUnboundNamespacePrefixedNode(Node node) throws IOException(Code) | | DOM Level 3:
Check a node to determine if it contains unbound namespace prefixes.
Parameters: node - The node to check for unbound namespace prefices |
printText | protected void printText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped) throws IOException(Code) | | |
printXMLChar | protected void printXMLChar(int ch) throws IOException(Code) | | print text data
|
reset | public boolean reset()(Code) | | |
setNamespaces | public void setNamespaces(boolean namespaces)(Code) | | This methods turns on namespace fixup algorithm during
DOM serialization.
See Also: org.w3c.dom.ls.LSSerializer Parameters: namespaces - |
startDocument | protected void startDocument(String rootTagName) throws IOException(Code) | | Called to serialize the document's DOCTYPE by the root element.
The document type declaration must name the root element,
but the root element is only known when that element is serialized,
and not at the start of the document.
This method will check if it has not been called before (
XMLSerializer._started ),
will serialize the document type declaration, and will serialize all
pre-root comments and PIs that were accumulated in the document
(see
XMLSerializer.serializePreRoot ). Pre-root will be serialized even if
this is not the first root element of the document.
|
Methods inherited from org.jasig.portal.serialize.BaseMarkupSerializer | protected String appendAnchorIfNecessary(String elementName, String attributeName, String attributeValue)(Code)(Java Doc) public ContentHandler asContentHandler() throws IOException(Code)(Java Doc) public DOMSerializer asDOMSerializer() throws IOException(Code)(Java Doc) public DocumentHandler asDocumentHandler() throws IOException(Code)(Java Doc) public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException(Code)(Java Doc) public void characters(char[] chars, int start, int length) throws SAXException(Code)(Java Doc) protected void characters(String text) throws IOException(Code)(Java Doc) protected void checkUnboundNamespacePrefixedNode(Node node) throws IOException(Code)(Java Doc) public void comment(char[] chars, int start, int length) throws SAXException(Code)(Java Doc) public void comment(String text) throws IOException(Code)(Java Doc) protected ElementState content() throws IOException(Code)(Java Doc) public void elementDecl(String name, String model) throws SAXException(Code)(Java Doc) public void endCDATA()(Code)(Java Doc) public void endDTD()(Code)(Java Doc) public void endDocument() throws SAXException(Code)(Java Doc) public void endEntity(String name)(Code)(Java Doc) public void endNonEscaping()(Code)(Java Doc) public void endPrefixMapping(String prefix) throws SAXException(Code)(Java Doc) public void endPreserving()(Code)(Java Doc) protected ElementState enterElementState(String namespaceURI, String localName, String rawName, boolean preserveSpace)(Code)(Java Doc) public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) protected void fatalError(String message) throws IOException(Code)(Java Doc) protected ElementState getElementState()(Code)(Java Doc) abstract protected String getEntityRef(int ch)(Code)(Java Doc) protected String getPrefix(String namespaceURI)(Code)(Java Doc) public void ignorableWhitespace(char[] chars, int start, int length) throws SAXException(Code)(Java Doc) public void internalEntityDecl(String name, String value) throws SAXException(Code)(Java Doc) protected boolean isDocumentState()(Code)(Java Doc) protected ElementState leaveElementState()(Code)(Java Doc) protected DOMError modifyDOMError(String message, short severity, String type, Node node)(Code)(Java Doc) public void notationDecl(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) protected void prepare() throws IOException(Code)(Java Doc) protected void printCDATAText(String text) throws IOException(Code)(Java Doc) protected void printDoctypeURL(String url) throws IOException(Code)(Java Doc) protected void printEscaped(int ch) throws IOException(Code)(Java Doc) protected void printEscaped(String source) throws IOException(Code)(Java Doc) final void printHex(int ch) throws IOException(Code)(Java Doc) protected void printText(char[] chars, int start, int length, boolean preserveSpace, boolean unescaped) throws IOException(Code)(Java Doc) protected void printText(String text, boolean preserveSpace, boolean unescaped) throws IOException(Code)(Java Doc) final public void processingInstruction(String target, String code) throws SAXException(Code)(Java Doc) public void processingInstructionIO(String target, String code) throws IOException(Code)(Java Doc) public boolean reset()(Code)(Java Doc) public void serialize(Element elem) throws IOException(Code)(Java Doc) public void serialize(DocumentFragment frag) throws IOException(Code)(Java Doc) public void serialize(Document doc) throws IOException(Code)(Java Doc) abstract protected void serializeElement(Element elem) throws IOException(Code)(Java Doc) protected void serializeNode(Node node) throws IOException(Code)(Java Doc) protected void serializePreRoot() throws IOException(Code)(Java Doc) public void setDocumentLocator(Locator locator)(Code)(Java Doc) public void setOutputByteStream(OutputStream output)(Code)(Java Doc) public void setOutputCharStream(Writer writer)(Code)(Java Doc) public void setOutputFormat(OutputFormat format)(Code)(Java Doc) public void skippedEntity(String name) throws SAXException(Code)(Java Doc) public void startAnchoring(String anchorId)(Code)(Java Doc) public void startCDATA()(Code)(Java Doc) final public void startDTD(String name, String publicId, String systemId) throws SAXException(Code)(Java Doc) public void startDocument() throws SAXException(Code)(Java Doc) public void startEntity(String name)(Code)(Java Doc) public void startNonEscaping()(Code)(Java Doc) public void startPrefixMapping(String prefix, String uri) throws SAXException(Code)(Java Doc) public void startPreserving()(Code)(Java Doc) public void stopAnchoring()(Code)(Java Doc) protected void surrogates(int high, int low) throws IOException(Code)(Java Doc) public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException(Code)(Java Doc)
|
|
|