org.jvnet.staxex
Interface XMLStreamReaderEx

All Superinterfaces:
javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamReader

public interface XMLStreamReaderEx
extends javax.xml.stream.XMLStreamReader

XMLStreamReader extended for reading binary data.

Some producer of infoset (in particular, such as FastInfoset, XOP deecoder), usees a native format that enables efficient treatment of binary data. For ordinary infoset consumer (that just uses XMLStreamReader, those binary data will just look like base64-encoded string, but this interface allows consumers of such infoset to access this raw binary data. Such infoset producer may choose to implement this additoinal interface, to expose this functionality.

Consumers that are capable of using this interface can query XMLStreamReader if it supports this by simply downcasting it to this interface like this:

 XMLStreamReader reader = ...;
 if( reader instanceof XMLStreamReaderEx ) {
   // this reader supports binary data exchange
   ...
 } else {
   // noop
   ...
 }
 

Also note that it is also allowed for the infoset producer to implement this interface in such a way that getPCDATA() always delegate to XMLStreamReader.getText(), although it's not desirable.

This interface is a private contract between such producers and consumers to allow them to exchange binary data without converting it to base64.

Author:
Kohsuke Kawaguchi, Paul Sandoz
See Also:
XMLStreamWriterEx

Field Summary
 
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
 
Method Summary
 java.lang.String getElementTextTrim()
          Works like XMLStreamReader.getElementText() but trims the leading and trailing whitespace.
 NamespaceContextEx getNamespaceContext()
          
 java.lang.CharSequence getPCDATA()
          Works like XMLStreamReader.getText() but hides the actual data representation.
 
Methods inherited from interface javax.xml.stream.XMLStreamReader
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getElementText, getEncoding, getEventType, getLocalName, getLocation, getName, getNamespaceCount, getNamespacePrefix, getNamespaceURI, getNamespaceURI, getNamespaceURI, getPIData, getPITarget, getPrefix, getProperty, getText, getTextCharacters, getTextCharacters, getTextLength, getTextStart, getVersion, hasName, hasNext, hasText, isAttributeSpecified, isCharacters, isEndElement, isStandalone, isStartElement, isWhiteSpace, next, nextTag, require, standaloneSet
 

Method Detail

getPCDATA

java.lang.CharSequence getPCDATA()
                                 throws javax.xml.stream.XMLStreamException
Works like XMLStreamReader.getText() but hides the actual data representation.

Returns:
The CharSequence that represents the character infoset items at the current position.

The CharSequence is normally a String, but can be any other CharSequence implementation. For binary data, however, use of Base64Data is recommended (so that the consumer interested in seeing it as binary data may take advantage of mor efficient data representation.)

The object returned from this method belongs to the parser, and its content is guaranteed to be the same only until the XMLStreamReader.next() method is invoked.

Throws:
java.lang.IllegalStateException - if the parser is not pointing at characters infoset item. TODO: fix the dependency to JAXB internal class.
javax.xml.stream.XMLStreamException

getNamespaceContext

NamespaceContextEx getNamespaceContext()

Specified by:
getNamespaceContext in interface javax.xml.stream.XMLStreamReader

getElementTextTrim

java.lang.String getElementTextTrim()
                                    throws javax.xml.stream.XMLStreamException
Works like XMLStreamReader.getElementText() but trims the leading and trailing whitespace.

The parser can often do this more efficiently than getElementText().trim().

Throws:
javax.xml.stream.XMLStreamException
See Also:
XMLStreamReader.getElementText()


Copyright © 2006-2010. All Rights Reserved.