javolution.xml.stream

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Natural Language Processing
51.Net
52.Parser
53.PDF
54.Portal
55.Profiler
56.Project Management
57.Report
58.RSS RDF
59.Rule Engine
60.Science
61.Scripting
62.Search Engine
63.Security
64.Sevlet Container
65.Source Control
66.Swing Library
67.Template Engine
68.Test Coverage
69.Testing
70.UML
71.Web Crawler
72.Web Framework
73.Web Mail
74.Web Server
75.Web Services
76.Web Services apache cxf 2.2.6
77.Web Services AXIS2
78.Wiki Engine
79.Workflow Engines
80.XML
81.XML UI
Java Source Code / Java Documentation  » Development » Javolution » 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
w___w_w__.___j__av___a___2s_.c__o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.