Java Doc for XMLStreamUtils.java in  » XML » stax-utils » javanet » staxutils » 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 » stax utils » javanet.staxutils 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javanet.staxutils.XMLStreamUtils

XMLStreamUtils
public class XMLStreamUtils (Code)
Static utility methods useful when handling XML Streams.
author:
   Christian Niles
version:
   $Revision: 1.8 $




Method Summary
final public static  StringattributeValue(XMLStreamReader reader, String name)
     Returns the value of the attribute with the given non-qualified name.
Parameters:
  reader - The xml stream reader
Parameters:
  name - The name of the attribute.
final public static  StringattributeValue(XMLStreamReader reader, QName name)
     Returns the value of the attribute with the given name.
Parameters:
  reader - The xml stream reader
Parameters:
  name - The name of the attribute.
final public static  voidcopy(XMLEventReader reader, XMLEventConsumer consumer)
     Copies the content read from the specified source stream to the provided result stream.
final public static  voidcopy(XMLEventReader reader, XMLEventWriter writer)
     Copies the content read from the specified source stream to the provided result stream.
final public static  voidcopy(XMLStreamReader reader, XMLStreamWriter writer)
     Copies the content read from the specified source stream to the provided result stream.
final public static  voidcopy(XMLStreamReader reader, XMLStreamWriter writer, XMLInputFactory factory)
     Copies the content read from the specified source stream to the provided result stream.
final public static  voidcopy(Source source, XMLStreamWriter writer)
     Copies the content read from a TrAX Source to a StAX XMLStreamWriter .
final public static  voidcopy(Source source, XMLEventWriter writer)
     Copies the content read from a TrAX Source to a StAX XMLEventWriter .
final public static  voidcopy(XMLEventReader reader, Result result)
     Copies the content read from a StAX XMLEventReader to a TrAX Result .
final public static  voidcopy(XMLStreamReader reader, Result result)
     Copies the content read from a StAX XMLStreamReader to a TrAX Result .
final public static  voidcopyElement(XMLEventReader reader, XMLEventConsumer consumer)
     Copies an element and all its content from the provided event reader, to the provided event consumer.
final public static  voidcopyElementContent(XMLEventReader reader, XMLEventConsumer consumer)
     Copies all events within a StartElement until the matching EndElement is reached.
final public static  StringgetEventTypeName(int eventType)
     Returns the name of the specified stream event constant.
Parameters:
  eventType - The event constant, such asXMLStreamConstants.START_DOCUMENT.
public static  StartElementmergeAttributes(StartElement tag, Iterator attrs, XMLEventFactory factory)
     Constructs a new StartElement that merges the attributes and namespaces found in the specified StartElement, with the provided attributes.
final public static  StartElementnextElement(XMLEventReader reader)
     Reads the events from the provided event stream until either a start or end tag is encountered.
final public static  StartElementnextElement(XMLEventReader reader, QName name)
     Reads the events from the provided event stream until either a start or end tag is encountered.
final public static  XMLEventnextTag(XMLEventReader reader)
     Advances the event stream until it encounters a start or end tag, but does not actaully read the event.
Parameters:
  reader - The reader to peek.
final public static  StringreadTextElement(XMLEventReader reader, QName elemName)
     Reads the text content of an element.
final public static  voidrequireElement(XMLStreamReader reader, QName name)
     Static utility method that throws an exception if the supplied reader's cursor doesn't point to a START_ELEMENT with the given name.
final public static  voidrequireStartElement(XMLEventReader reader, QName qname)
     Utility method that throws an exception if the provided reader is not positioned before a StartElement event with the specified tag name.
Parameters:
  reader - The reader to test.
Parameters:
  qname - The required name of the start-tag.
final public static  voidskipElement(XMLEventReader reader)
     Skips all events within a single element, including its start and end tags.
final public static  voidskipElement(XMLStreamReader reader)
     Skips the complete content of the element at the specified reader's cursor.
final public static  voidskipElementContent(XMLEventReader reader)
     Skips all events within a StartElement until the matching EndElement is reached.
final public static  voidskipElementContent(XMLStreamReader reader)
     Skips an element's complete content.



Method Detail
attributeValue
final public static String attributeValue(XMLStreamReader reader, String name)(Code)
Returns the value of the attribute with the given non-qualified name.
Parameters:
  reader - The xml stream reader
Parameters:
  name - The name of the attribute. The value of the unqualified attribute, or nullif the attribute wasn't present.



attributeValue
final public static String attributeValue(XMLStreamReader reader, QName name)(Code)
Returns the value of the attribute with the given name.
Parameters:
  reader - The xml stream reader
Parameters:
  name - The name of the attribute. The value of the attribute, or null if theattribute wasn't present.



copy
final public static void copy(XMLEventReader reader, XMLEventConsumer consumer) throws XMLStreamException(Code)
Copies the content read from the specified source stream to the provided result stream. This method is exactly the same as calling XMLEventWriter.add(XMLEventReader) , and is provided only for completeness.
Parameters:
  reader - The source stream.
Parameters:
  consumer - The destination stream.
throws:
  XMLStreamException - If an error occurs copying the streamcontents.



copy
final public static void copy(XMLEventReader reader, XMLEventWriter writer) throws XMLStreamException(Code)
Copies the content read from the specified source stream to the provided result stream. This method is exactly the same as calling XMLEventWriter.add(XMLEventReader) , and is provided only for completeness.
Parameters:
  reader - The source stream.
Parameters:
  writer - The destination stream.
throws:
  XMLStreamException - If an error occurs copying the streamcontents.



copy
final public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException(Code)
Copies the content read from the specified source stream to the provided result stream.
Parameters:
  reader - The source stream.
Parameters:
  writer - The destination stream.
throws:
  XMLStreamException - If an error occurs copying the streamcontents.



copy
final public static void copy(XMLStreamReader reader, XMLStreamWriter writer, XMLInputFactory factory) throws XMLStreamException(Code)
Copies the content read from the specified source stream to the provided result stream.
Parameters:
  reader - The source stream.
Parameters:
  writer - The destination stream.
Parameters:
  factory - An optional input factory used to create any intermediatestreams.
throws:
  XMLStreamException - If an error occurs copying the streamcontents.



copy
final public static void copy(Source source, XMLStreamWriter writer) throws XMLStreamException(Code)
Copies the content read from a TrAX Source to a StAX XMLStreamWriter .
Parameters:
  source - The content source.
Parameters:
  writer - The destination stream.
throws:
  XMLStreamException - If an error occurs copying the content to thestream.



copy
final public static void copy(Source source, XMLEventWriter writer) throws XMLStreamException(Code)
Copies the content read from a TrAX Source to a StAX XMLEventWriter .
Parameters:
  source - The content source.
Parameters:
  writer - The destination event stream.
throws:
  XMLStreamException - If an error occurs copying the content to theevent stream.



copy
final public static void copy(XMLEventReader reader, Result result) throws XMLStreamException(Code)
Copies the content read from a StAX XMLEventReader to a TrAX Result .
Parameters:
  reader - The source event stream.
Parameters:
  result - The destination Result.
throws:
  XMLStreamException - If an error occurs copying the content to theresult.



copy
final public static void copy(XMLStreamReader reader, Result result) throws XMLStreamException(Code)
Copies the content read from a StAX XMLStreamReader to a TrAX Result .
Parameters:
  reader - The source stream.
Parameters:
  result - The destination Result.
throws:
  XMLStreamException - If an error occurs copying the content to theresult.



copyElement
final public static void copyElement(XMLEventReader reader, XMLEventConsumer consumer) throws XMLStreamException(Code)
Copies an element and all its content from the provided event reader, to the provided event consumer. The event reader must be positioned before a start element event, or this method has no effect.
Parameters:
  reader - The reader from which to read the events.
Parameters:
  consumer - The destination for read events, or null toignore all events.
throws:
  XMLStreamException - If an error occurs reading or writing theevents.



copyElementContent
final public static void copyElementContent(XMLEventReader reader, XMLEventConsumer consumer) throws XMLStreamException(Code)
Copies all events within a StartElement until the matching EndElement is reached. This method assumes that the reader is positioned after the StartElement event, and when the method completes, the stream will be positioned before the EndElement event, but it will not consume the end tag.
Parameters:
  reader - The event stream to read, positioned after theStartElement
Parameters:
  consumer - The destination for events read from teh stream, ornull to ignore the events completely.
throws:
  XMLStreamException - If an error occurs reading events.



getEventTypeName
final public static String getEventTypeName(int eventType)(Code)
Returns the name of the specified stream event constant.
Parameters:
  eventType - The event constant, such asXMLStreamConstants.START_DOCUMENT. The name of the specified event, or "UNKNOWN" if theconstant isn't valid.



mergeAttributes
public static StartElement mergeAttributes(StartElement tag, Iterator attrs, XMLEventFactory factory)(Code)
Constructs a new StartElement that merges the attributes and namespaces found in the specified StartElement, with the provided attributes. The returned StartElement will contain all the attributes and namespaces of the original, plus those defined in the map.
Parameters:
  tag - The original StartElement
Parameters:
  attrs - An iterator of Atributes to add to the element. A new StartElement that contains all the original attributes andnamespaces, plus the provided attributes.



nextElement
final public static StartElement nextElement(XMLEventReader reader) throws XMLStreamException(Code)
Reads the events from the provided event stream until either a start or end tag is encountered. In the former case, the start tag will be returned, but if an end tag is encountered, null will be returned. After returning, the stream will be positioned just before the returned start element. The start element will not be consumed by this method.
Parameters:
  reader - The event stream from which to read. The StartElement read from the stream, or null ifan end tag was found first, or the stream ended before a startelement was found.
throws:
  XMLStreamException - If an error occurs reading the stream.



nextElement
final public static StartElement nextElement(XMLEventReader reader, QName name) throws XMLStreamException(Code)
Reads the events from the provided event stream until either a start or end tag is encountered. In the former case, the start tag will be returned if it matches the specified QName, but if it doesn't match, an end tag is encountered, or the stream ends, null will be returned. After returning, the stream will be positioned just before the start element. The start element will not be consumed by this method.
Parameters:
  reader - The event stream from which to read.
Parameters:
  name - The name of the element to read, or null toread any start tag. The StartElement read from the stream, or null ifthe encountered start tag didn't match the specified QName, anend tag was found first, or the stream ended before a startelement was found.
throws:
  XMLStreamException - If an error occurs reading the stream.



nextTag
final public static XMLEvent nextTag(XMLEventReader reader) throws XMLStreamException(Code)
Advances the event stream until it encounters a start or end tag, but does not actaully read the event.
Parameters:
  reader - The reader to peek. The next StartElement or EndElement event, retrieved usingpeek(), or null if the end of thestream was encountered before any tag event.
throws:
  XMLStreamException - If an error occurs reading the stream.



readTextElement
final public static String readTextElement(XMLEventReader reader, QName elemName) throws XMLStreamException(Code)
Reads the text content of an element. The reader should be positioned in front of a StartElement event, and will be read up to and including the end element tag.
Parameters:
  reader - The event stream from which to read the element text.
Parameters:
  elemName - The optional name of the element being read. If thisparamter is non- null then an exception willbe thrown if the element read doesn't have the same name. The text read from the element.
throws:
  XMLStreamException - If an error occurs reading the stream, or ifthe read element doesn't match the provided QName.



requireElement
final public static void requireElement(XMLStreamReader reader, QName name) throws XMLStreamException(Code)
Static utility method that throws an exception if the supplied reader's cursor doesn't point to a START_ELEMENT with the given name.
Parameters:
  reader - The reader to test.
Parameters:
  name - The name of the element to require.
throws:
  XMLStreamException - If the reader state is an element with thespecified name.



requireStartElement
final public static void requireStartElement(XMLEventReader reader, QName qname) throws XMLStreamException(Code)
Utility method that throws an exception if the provided reader is not positioned before a StartElement event with the specified tag name.
Parameters:
  reader - The reader to test.
Parameters:
  qname - The required name of the start-tag. If null,any start tag is accepted.
throws:
  XMLStreamException - If an error occurs reading from the stream.



skipElement
final public static void skipElement(XMLEventReader reader) throws XMLStreamException(Code)
Skips all events within a single element, including its start and end tags. The provided reader must be positioned directly in front of a StartElement event or it will have no effect. After this method completes, the reader will be positioned before the event following the end tag (the end tag will have been read).
Parameters:
  reader - The event stream to read.
throws:
  XMLStreamException - If an error occurs reading events.



skipElement
final public static void skipElement(XMLStreamReader reader) throws XMLStreamException(Code)
Skips the complete content of the element at the specified reader's cursor. The reader's current event type must be START_ELEMENT, otherwise this method will have no effect. Upon completion, the reader's cursor will be at the END_ELEMENT event for the skipped element.
Parameters:
  reader - An XML stream reader currently in the START_ELEMENT event.



skipElementContent
final public static void skipElementContent(XMLEventReader reader) throws XMLStreamException(Code)
Skips all events within a StartElement until the matching EndElement is reached. This method assumes that the reader is positioned after the StartElement event, and when the method completes, the stream will be positioned before the EndElement event, but it will not consume the end tag.
Parameters:
  reader - The event stream to read, positioned after theStartElement
throws:
  XMLStreamException - If an error occurs reading events.



skipElementContent
final public static void skipElementContent(XMLStreamReader reader) throws XMLStreamException(Code)
Skips an element's complete content. This method assumes that the START_ELEMENT has already be passed, and when it terminates, the stream will be positioned at the END_ELEMENT.
Parameters:
  reader - The stream reader to read.
throws:
  XMLStreamException - If an error occurs reading the stream.



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.