javolution.xml.stream

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 » Science » javolution 5.2 » javolution.xml.stream 
javolution.xml.stream

Provides StAX-like XML readers/writers which do not require object creation (such as String) and are consequently faster and more time predictable than standard StAX classes.

The main difference with "javax.xml.stream.*" classes is the use of CharSequence instead of String. Since String is a CharSequence (JDK 1.4+), most existing StAX code requires very little modification to be used with these new classes.

For more information about the usage of this package please read the documentation for the {@link javolution.xml.stream.XMLStreamReader} and {@link javolution.xml.stream.XMLStreamWriter} interfaces.

For more information about StAX (Streaming API for XML) in general see Wikipedia: StAX

Java Source File NameTypeComment
AttributesImpl.javaClass This class provides the implementation of the Attributes interface for the StAX parser.
EntitiesImpl.javaClass This class holds defined entities while parsing.
Location.javaInterface Provides information on the location of an event.
NamespaceContext.javaInterface This interface represents the XML namespace context stack while parsing.
NamespacesImpl.javaClass This class represents the namespaces stack while parsing.
XMLInputFactory.javaClass

The class represents the factory for getting XMLStreamReader intances.

The XMLInputFactory.newInstance() default implementation automatically ObjectFactory.recycle recycles any reader which has been XMLStreamReader.close closed .

Usage example:[code] // Lets read a CharSequence input. String xml = "..."; CharSequenceReader in = new CharSequenceReader().setInput(xml); // Creates a factory of readers coalescing adjacent character data. XMLInputFactory factory = XMLInputFactory.newInstance(); factory.setProperty(XMLInputFactory.IS_COALESCING, true); // Creates a new reader (potentially recycled). XMLStreamReader reader = factory.createXMLStreamReader(in); // Parses XML. for (int e=reader.next(); e != XMLStreamConstants.END_DOCUMENT; e = reader.next()) { switch (e) { // Event. ... } } reader.close(); // Automatically recycles this writer.

XMLOutputFactory.javaClass

The class represents the factory for getting XMLStreamWriter intances.

The XMLOutputFactory.newInstance() default implementation automatically ObjectFactory.recycle recycles any writer which has been XMLStreamWriter.close closed .

Usage example:[code] // Lets format to an appendable. TextBuilder xml = new TextBuilder(); AppendableWriter out = new AppendableWriter(xml); // Creates a factory producing writers using tab indentation. XMLOutpuFactory factory = XMLOutputFactory.newInstance(); factory.setProperty(XMLOutputFactory.INDENTATION, "/t"); // Creates a new writer (potentially recycled). XMLStreamWriter writer = factory.createXMLStreamReader(out); // Formats to XML. writer.writeStartDocument(); writer.writeStartElement(...); ... writer.close(); // Automatically recycles this writer.

XMLStreamConstants.javaInterface This interface declares the constants used in this API.
XMLStreamException.javaClass This class represents the base exception for unexpected processing errors.
XMLStreamReader.javaInterface

This interface is similar to javax.xml.stream.XMLStreamReader; but it does not forces dynamic allocation when parsing (its methods returns CharArray CharArray instances instead of String ).

Except for the speed (faster) and its real-time characteristics the usage/behavior is about the same as its StAX counterpart.

The CharArray CharArray instances returned by this reader supports fast primitive conversions as illustrated below:[code] // Creates a new reader (potentially recycled).

XMLStreamReaderImpl.javaClass

This class represents a javolution.lang.Reusable reusable implementation of XMLStreamWriter .

Except for the types being used ( CharArray CharArray / CharSequence CharSequence instead of String ) the parsing behavior is about the same as for the standard javax.xml.stream.XMLStreamReader (although several times faster).

The CharArray CharArray instances returned by this reader supports fast primitive conversions as illustrated below:[code] // Creates reader for an input sream with unknown encoding. XMLStreamReaderImpl xmlReader = new XMLStreamReaderImpl().setInput(inputStream); // Parses. for (int e=xmlReader.next(); e != XMLStreamConstants.END_DOCUMENT; e = xmlReader.next()) { switch (e) { // Event. case XMLStreamConstants.START_ELEMENT: if (xmlReader.getLocalName().equals("Time")) { // Reads primitive types (int) attributes directly. int hour = xmlReader.getAttributeValue("hour").toInt(); int minute = xmlReader.getAttributeValue("minute").toInt(); int second = xmlReader.getAttributeValue("second").toInt(); ... } ... break; } } // Closes reader, it is automatically reset() and can be reused! xmlReader.close(); [/code]

This reader returns all contiguous character data in a single chunk (always coalescing).

XMLStreamWriter.javaInterface

This interface is similar to javax.xml.stream.XMLStreamWriter; but it does not forces dynamic allocation when formatting (any CharSequence CharSequence can be used instead of String ).

Except for the speed (faster) and the added flexibility, the usage/behavior is about the same as its StAX counterpart.

This writer does not require creating new String objects during XML formatting.

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