Java Doc for Serializer.java in  » XML » xalan » org » apache » xml » serializer » 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 » XML » xalan » org.apache.xml.serializer 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.xml.serializer.Serializer

Serializer
public interface Serializer (Code)
The Serializer interface is implemented by a serializer to enable users to:
  • get and set streams or writers
  • configure the serializer with key/value properties
  • get an org.xml.sax.ContentHandler or a DOMSerializer to provide input to

Here is an example using the asContentHandler() method:

 java.util.Properties props = 
 OutputPropertiesFactory.getDefaultMethodProperties(Method.TEXT);
 Serializer ser = SerializerFactory.getSerializer(props);
 java.io.PrintStream ostream = System.out; 
 ser.setOutputStream(ostream);
 // Provide the SAX input events
 ContentHandler handler = ser.asContentHandler();
 handler.startDocument();
 char[] chars = { 'a', 'b', 'c' };
 handler.characters(chars, 0, chars.length);
 handler.endDocument();
 ser.reset(); // get ready to use the serializer for another document
 // of the same output method (TEXT).
 

As an alternate to supplying a series of SAX events as input through the ContentHandler interface, the input to serialize may be given as a DOM.

For example:

 org.w3c.dom.Document     inputDoc;
 org.apache.xml.serializer.Serializer   ser;
 java.io.Writer owriter;
 java.util.Properties props = 
 OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
 Serializer ser = SerializerFactory.getSerializer(props);
 owriter = ...;  // create a writer to serialize the document to
 ser.setWriter( owriter );
 inputDoc = ...; // create the DOM document to be serialized
 DOMSerializer dser = ser.asDOMSerializer(); // a DOM will be serialized
 dser.serialize(inputDoc); // serialize the DOM, sending output to owriter
 ser.reset(); // get ready to use the serializer for another document
 // of the same output method.
 
This interface is a public API.
See Also:   Method
See Also:   OutputPropertiesFactory
See Also:   SerializerFactory
See Also:   DOMSerializer
See Also:   ContentHandler




Method Summary
public  ContentHandlerasContentHandler()
     Return a ContentHandler interface to provide SAX input to.
public  DOMSerializerasDOMSerializer()
     Return a DOMSerializer interface into this serializer.
public  PropertiesgetOutputFormat()
     Returns the output format properties for this serializer.
public  OutputStreamgetOutputStream()
     Get the output stream where the events will be serialized to.
public  WritergetWriter()
     Get the character stream where the events will be serialized to.
public  booleanreset()
     This method resets the serializer.
public  voidsetOutputFormat(Properties format)
    
public  voidsetOutputStream(OutputStream output)
     Specifies an output stream to which the document should be serialized.
public  voidsetWriter(Writer writer)
     Specifies a writer to which the document should be serialized.



Method Detail
asContentHandler
public ContentHandler asContentHandler() throws IOException(Code)
Return a ContentHandler interface to provide SAX input to. Through the returned object the document to be serailized, as a series of SAX events, can be provided to the serialzier. If the serializer does not support the ContentHandler interface, it will return null.

In principle only one of asDOMSerializer() or asContentHander() should be called. A ContentHandler interface into this serializer,or null if the serializer is not SAX 2 capable
throws:
  IOException - An I/O exception occured




asDOMSerializer
public DOMSerializer asDOMSerializer() throws IOException(Code)
Return a DOMSerializer interface into this serializer. Through the returned object the document to be serialized, a DOM, can be provided to the serializer. If the serializer does not support the DOMSerializer interface, it should return null.

In principle only one of asDOMSerializer() or asContentHander() should be called. A DOMSerializer interface into this serializer,or null if the serializer is not DOM capable
throws:
  IOException - An I/O exception occured




getOutputFormat
public Properties getOutputFormat()(Code)
Returns the output format properties for this serializer. The output format key/value pairs in use.



getOutputStream
public OutputStream getOutputStream()(Code)
Get the output stream where the events will be serialized to. reference to the result stream, or null if only a writer wasset.



getWriter
public Writer getWriter()(Code)
Get the character stream where the events will be serialized to. Reference to the result Writer, or null.



reset
public boolean reset()(Code)
This method resets the serializer. If this method returns true, the serializer may be used for subsequent serialization of new documents. It is possible to change the output format and output stream prior to serializing, or to reuse the existing output format and output stream or writer. True if serializer has been reset and can be reused



setOutputFormat
public void setOutputFormat(Properties format)(Code)



setOutputStream
public void setOutputStream(OutputStream output)(Code)
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified in the output Properties is used, or if no encoding was specified, the default for the selected output method.

Only one of setWriter() or setOutputStream() should be called.
Parameters:
  output - The output stream




setWriter
public void setWriter(Writer writer)(Code)
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified for the output Properties must be identical to the output format used with the writer.

Only one of setWriter() or setOutputStream() should be called.
Parameters:
  writer - The output writer stream




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