Java Doc for XMLOutputter.java in  » Workflow-Engines » OpenWFE » org » jdom » output » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » OpenWFE » org.jdom.output 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jdom.output.XMLOutputter

XMLOutputter
public class XMLOutputter implements Cloneable(Code)
Outputs a JDOM document as a stream of bytes. The outputter can manage many styles of document formatting, from untouched to pretty printed. The default is to output the document content exactly as created, but this can be changed by setting a new Format object. For pretty-print output, use Format.getPrettyFormat . For whitespace-normalized output, use Format.getCompactFormat .

There are XMLOutputter.output output(...) methods to print any of the standard JDOM classes, including Document and Element, to either a Writer or an OutputStream. Warning: When outputting to a Writer, make sure the writer's encoding matches the encoding setting in the Format object. This ensures the encoding in which the content is written (controlled by the Writer configuration) matches the encoding placed in the document's XML declaration (controlled by the XMLOutputter). Because a Writer cannot be queried for its encoding, the information must be passed to the Format manually in its constructor or via the Format.setEncoding method. The default encoding is UTF-8.

The methods XMLOutputter.outputString outputString(...) are for convenience only; for top performance you should call one of the XMLOutputter.output output(...) methods and pass in your own Writer or OutputStream if possible.

XML declarations are always printed on their own line followed by a line seperator (this doesn't change the semantics of the document). To omit printing of the declaration use Format.setOmitDeclaration . To omit printing of the encoding in the declaration use Format.setOmitEncoding . Unfortunatly there is currently no way to know the original encoding of the document.

Empty elements are by default printed as <empty/>, but this can be configured with Format.setExpandEmptyElements to cause them to be expanded to <empty></empty>.
version:
   $Revision: 1.2 $, $Date: 2005/05/03 07:02:04 $
author:
   Brett McLaughlin
author:
   Jason Hunter
author:
   Jason Reid
author:
   Wolfgang Werner
author:
   Elliotte Rusty Harold
author:
   David & Will (from Post Tool Design)
author:
   Dan Schaffer
author:
   Alex Chaffee
author:
   Bradley S. Huffman


Inner Class :protected class NamespaceStack extends org.jdom.output.NamespaceStack

Field Summary
protected  FormatcurrentFormat
    
final protected static  FormatpreserveFormat
    

Constructor Summary
public  XMLOutputter()
     This will create an XMLOutputter with the default Format matching Format.getRawFormat .
public  XMLOutputter(Format format)
     This will create an XMLOutputter with the specified format characteristics.
public  XMLOutputter(XMLOutputter that)
     This will create an XMLOutputter with all the options as set in the given XMLOutputter.

Method Summary
public  Objectclone()
     Returns a copy of this XMLOutputter.
public  StringescapeAttributeEntities(String str)
     This will take the pre-defined entities in XML 1.0 and convert their character representation to the appropriate entity reference, suitable for XML attributes.
public  StringescapeElementEntities(String str)
     This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.
Parameters:
  str - String input to escape.
public  FormatgetFormat()
     Returns the current format in use by the outputter.
public  voidoutput(Document doc, OutputStream out)
     This will print the Document to the given output stream.
public  voidoutput(DocType doctype, OutputStream out)
     Print out the DocType .
public  voidoutput(Element element, OutputStream out)
     Print out an Element , including its Attribute s, and all contained (child) elements, etc.
public  voidoutput(List list, OutputStream out)
     This will handle printing out a list of nodes.
public  voidoutput(CDATA cdata, OutputStream out)
     Print out a CDATA node.
public  voidoutput(Text text, OutputStream out)
     Print out a Text node.
public  voidoutput(Comment comment, OutputStream out)
     Print out a Comment .
public  voidoutput(ProcessingInstruction pi, OutputStream out)
     Print out a ProcessingInstruction .
public  voidoutput(EntityRef entity, OutputStream out)
     Print out a EntityRef .
public  voidoutput(Document doc, Writer out)
     This will print the Document to the given Writer.

Warning: using your own Writer may cause the outputter's preferred character encoding to be ignored.

public  voidoutput(DocType doctype, Writer out)
     Print out the DocType .
public  voidoutput(Element element, Writer out)
     Print out an Element , including its Attribute s, and all contained (child) elements, etc.
public  voidoutput(List list, Writer out)
     This will handle printing out a list of nodes.
public  voidoutput(CDATA cdata, Writer out)
     Print out a CDATA node.
public  voidoutput(Text text, Writer out)
     Print out a Text node.
public  voidoutput(Comment comment, Writer out)
     Print out a Comment .
public  voidoutput(ProcessingInstruction pi, Writer out)
     Print out a ProcessingInstruction .
public  voidoutput(EntityRef entity, Writer out)
     Print out a EntityRef .
public  voidoutputElementContent(Element element, OutputStream out)
     This will handle printing out an Element 's content only, not including its tag, and attributes.
public  voidoutputElementContent(Element element, Writer out)
     This will handle printing out an Element 's content only, not including its tag, and attributes.
public  StringoutputString(Document doc)
     Return a string representing a document.
public  StringoutputString(DocType doctype)
     Return a string representing a DocType.
public  StringoutputString(Element element)
     Return a string representing an element.
public  StringoutputString(List list)
     Return a string representing a list of nodes.
public  StringoutputString(CDATA cdata)
     Return a string representing a CDATA node.
public  StringoutputString(Text text)
     Return a string representing a Text node.
public  StringoutputString(Comment comment)
     Return a string representing a comment.
public  StringoutputString(ProcessingInstruction pi)
     Return a string representing a PI.
public  StringoutputString(EntityRef entity)
     Return a string representing an entity.
protected  voidprintAttributes(Writer out, List attributes, Element parent, NamespaceStack namespaces)
     This will handle printing of a Attribute list.
protected  voidprintCDATA(Writer out, CDATA cdata)
     This will handle printing of CDATA text.
protected  voidprintComment(Writer out, Comment comment)
     This will handle printing of comments.
protected  voidprintDeclaration(Writer out, Document doc, String encoding)
     This will handle printing of the declaration.
protected  voidprintDocType(Writer out, DocType docType)
     This handle printing the DOCTYPE declaration if one exists.
protected  voidprintElement(Writer out, Element element, int level, NamespaceStack namespaces)
     This will handle printing of a Element , its Attribute s, and all contained (child) elements, etc.
protected  voidprintEntityRef(Writer out, EntityRef entity)
     This will handle printing a EntityRef . Only the entity reference such as &entity; will be printed.
protected  voidprintProcessingInstruction(Writer out, ProcessingInstruction pi)
     This will handle printing of processing instructions.
protected  voidprintText(Writer out, Text text)
     This will handle printing of Text strings.
public  voidsetFormat(Format newFormat)
     Sets the new format logic for the outputter.
public  StringtoString()
     Return a string listing of the settings for this XMLOutputter instance.

Field Detail
currentFormat
protected Format currentFormat(Code)



preserveFormat
final protected static Format preserveFormat(Code)




Constructor Detail
XMLOutputter
public XMLOutputter()(Code)
This will create an XMLOutputter with the default Format matching Format.getRawFormat .



XMLOutputter
public XMLOutputter(Format format)(Code)
This will create an XMLOutputter with the specified format characteristics. Note the format object is cloned internally before use.



XMLOutputter
public XMLOutputter(XMLOutputter that)(Code)
This will create an XMLOutputter with all the options as set in the given XMLOutputter. Note that XMLOutputter two = (XMLOutputter)one.clone(); would work equally well.
Parameters:
  that - the XMLOutputter to clone




Method Detail
clone
public Object clone()(Code)
Returns a copy of this XMLOutputter.



escapeAttributeEntities
public String escapeAttributeEntities(String str)(Code)
This will take the pre-defined entities in XML 1.0 and convert their character representation to the appropriate entity reference, suitable for XML attributes. It does not convert the single quote (') because it's not necessary as the outputter writes attributes surrounded by double-quotes.
Parameters:
  str - String input to escape. String with escaped content.



escapeElementEntities
public String escapeElementEntities(String str)(Code)
This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.
Parameters:
  str - String input to escape. String with escaped content.



getFormat
public Format getFormat()(Code)
Returns the current format in use by the outputter. Note the Format object returned is a clone of the one used internally.



output
public void output(Document doc, OutputStream out) throws IOException(Code)
This will print the Document to the given output stream. The characters are printed using the encoding specified in the constructor, or a default of UTF-8.
Parameters:
  doc - Document to format.
Parameters:
  out - OutputStream to use.
throws:
  IOException - - if there's any problem writing.



output
public void output(DocType doctype, OutputStream out) throws IOException(Code)
Print out the DocType .
Parameters:
  doctype - DocType to output.
Parameters:
  out - OutputStream to use.



output
public void output(Element element, OutputStream out) throws IOException(Code)
Print out an Element , including its Attribute s, and all contained (child) elements, etc.
Parameters:
  element - Element to output.
Parameters:
  out - Writer to use.



output
public void output(List list, OutputStream out) throws IOException(Code)
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
Parameters:
  list - List of nodes.
Parameters:
  out - OutputStream to use.



output
public void output(CDATA cdata, OutputStream out) throws IOException(Code)
Print out a CDATA node.
Parameters:
  cdata - CDATA to output.
Parameters:
  out - OutputStream to use.



output
public void output(Text text, OutputStream out) throws IOException(Code)
Print out a Text node. Perfoms the necessary entity escaping and whitespace stripping.
Parameters:
  text - Text to output.
Parameters:
  out - OutputStream to use.



output
public void output(Comment comment, OutputStream out) throws IOException(Code)
Print out a Comment .
Parameters:
  comment - Comment to output.
Parameters:
  out - OutputStream to use.



output
public void output(ProcessingInstruction pi, OutputStream out) throws IOException(Code)
Print out a ProcessingInstruction .
Parameters:
  pi - ProcessingInstruction to output.
Parameters:
  out - OutputStream to use.



output
public void output(EntityRef entity, OutputStream out) throws IOException(Code)
Print out a EntityRef .
Parameters:
  entity - EntityRef to output.
Parameters:
  out - OutputStream to use.



output
public void output(Document doc, Writer out) throws IOException(Code)
This will print the Document to the given Writer.

Warning: using your own Writer may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.


Parameters:
  doc - Document to format.
Parameters:
  out - Writer to use.
throws:
  IOException - - if there's any problem writing.



output
public void output(DocType doctype, Writer out) throws IOException(Code)
Print out the DocType .
Parameters:
  doctype - DocType to output.
Parameters:
  out - Writer to use.



output
public void output(Element element, Writer out) throws IOException(Code)
Print out an Element , including its Attribute s, and all contained (child) elements, etc.
Parameters:
  element - Element to output.
Parameters:
  out - Writer to use.



output
public void output(List list, Writer out) throws IOException(Code)
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
Parameters:
  list - List of nodes.
Parameters:
  out - Writer to use.



output
public void output(CDATA cdata, Writer out) throws IOException(Code)
Print out a CDATA node.
Parameters:
  cdata - CDATA to output.
Parameters:
  out - Writer to use.



output
public void output(Text text, Writer out) throws IOException(Code)
Print out a Text node. Perfoms the necessary entity escaping and whitespace stripping.
Parameters:
  text - Text to output.
Parameters:
  out - Writer to use.



output
public void output(Comment comment, Writer out) throws IOException(Code)
Print out a Comment .
Parameters:
  comment - Comment to output.
Parameters:
  out - Writer to use.



output
public void output(ProcessingInstruction pi, Writer out) throws IOException(Code)
Print out a ProcessingInstruction .
Parameters:
  pi - ProcessingInstruction to output.
Parameters:
  out - Writer to use.



output
public void output(EntityRef entity, Writer out) throws IOException(Code)
Print out a EntityRef .
Parameters:
  entity - EntityRef to output.
Parameters:
  out - Writer to use.



outputElementContent
public void outputElementContent(Element element, OutputStream out) throws IOException(Code)
This will handle printing out an Element 's content only, not including its tag, and attributes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
Parameters:
  element - Element to output.
Parameters:
  out - OutputStream to use.



outputElementContent
public void outputElementContent(Element element, Writer out) throws IOException(Code)
This will handle printing out an Element 's content only, not including its tag, and attributes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
Parameters:
  element - Element to output.
Parameters:
  out - Writer to use.



outputString
public String outputString(Document doc)(Code)
Return a string representing a document. Uses an internal StringWriter. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  doc - Document to format.



outputString
public String outputString(DocType doctype)(Code)
Return a string representing a DocType. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  doctype - DocType to format.



outputString
public String outputString(Element element)(Code)
Return a string representing an element. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  element - Element to format.



outputString
public String outputString(List list)(Code)
Return a string representing a list of nodes. The list is assumed to contain legal JDOM nodes.
Parameters:
  list - List to format.



outputString
public String outputString(CDATA cdata)(Code)
Return a string representing a CDATA node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  cdata - CDATA to format.



outputString
public String outputString(Text text)(Code)
Return a string representing a Text node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  text - Text to format.



outputString
public String outputString(Comment comment)(Code)
Return a string representing a comment. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  comment - Comment to format.



outputString
public String outputString(ProcessingInstruction pi)(Code)
Return a string representing a PI. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  pi - ProcessingInstruction to format.



outputString
public String outputString(EntityRef entity)(Code)
Return a string representing an entity. Warning: a String is Unicode, which may not match the outputter's specified encoding.
Parameters:
  entity - EntityRef to format.



printAttributes
protected void printAttributes(Writer out, List attributes, Element parent, NamespaceStack namespaces) throws IOException(Code)
This will handle printing of a Attribute list.
Parameters:
  attributes - List of Attribute objcts
Parameters:
  out - Writer to use



printCDATA
protected void printCDATA(Writer out, CDATA cdata) throws IOException(Code)
This will handle printing of CDATA text.
Parameters:
  cdata - CDATA to output.
Parameters:
  out - Writer to use.



printComment
protected void printComment(Writer out, Comment comment) throws IOException(Code)
This will handle printing of comments.
Parameters:
  comment - Comment to write.
Parameters:
  out - Writer to use.



printDeclaration
protected void printDeclaration(Writer out, Document doc, String encoding) throws IOException(Code)
This will handle printing of the declaration. Assumes XML version 1.0 since we don't directly know.
Parameters:
  doc - Document whose declaration to write.
Parameters:
  out - Writer to use.
Parameters:
  encoding - The encoding to add to the declaration



printDocType
protected void printDocType(Writer out, DocType docType) throws IOException(Code)
This handle printing the DOCTYPE declaration if one exists.
Parameters:
  docType - Document whose declaration to write.
Parameters:
  out - Writer to use.



printElement
protected void printElement(Writer out, Element element, int level, NamespaceStack namespaces) throws IOException(Code)
This will handle printing of a Element , its Attribute s, and all contained (child) elements, etc.
Parameters:
  element - Element to output.
Parameters:
  out - Writer to use.
Parameters:
  level - int level of indention.
Parameters:
  namespaces - List stack of Namespaces in scope.



printEntityRef
protected void printEntityRef(Writer out, EntityRef entity) throws IOException(Code)
This will handle printing a EntityRef . Only the entity reference such as &entity; will be printed. However, subclasses are free to override this method to print the contents of the entity instead.
Parameters:
  entity - EntityRef to output.
Parameters:
  out - Writer to use.



printProcessingInstruction
protected void printProcessingInstruction(Writer out, ProcessingInstruction pi) throws IOException(Code)
This will handle printing of processing instructions.
Parameters:
  pi - ProcessingInstruction to write.
Parameters:
  out - Writer to use.



printText
protected void printText(Writer out, Text text) throws IOException(Code)
This will handle printing of Text strings.
Parameters:
  text - Text to write.
Parameters:
  out - Writer to use.



setFormat
public void setFormat(Format newFormat)(Code)
Sets the new format logic for the outputter. Note the Format object is cloned internally before use.
Parameters:
  newFormat - the format to use for output



toString
public String toString()(Code)
Return a string listing of the settings for this XMLOutputter instance. a string listing the settings for this XMLOutputter instance



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.