Nonvalidating Strongly Typed Wrapper Over JSR173 Parser

A wrapper over JSR173 XMLStreamReader which will provide ways of getting strongly typed java values (like int, double, Date, QName) from text and attributes. This will primarily be used in the fast unmarshaler. Please send comments to cezar.andrei at bea.com or xmlbeans-dev at xml.apache.org.

Assumptions

Interface

{{{ public int getIntValue();

Methods and implied built-in schema types

{{{ /** Returns the value as a {@link String}. */

for xsd:string and derivates

{{{ /** Returns the value as a boolean. */

for xsd:boolean

{{{ /** Returns the value as a byte. */

for xsd:byte

{{{ /** Returns the value as a short. */

for xsd:short and derivates

{{{ /** Returns the value as an int. */

for xsd:int and derivates

{{{ /** Returns the value as a long. */

for xsd:long and derivates

{{{ /** Returns the value as a {@link java.math.BigInteger}. */

for xsd:integer and derivates

{{{ /** Returns the value as a {@link java.math.BigDecimal}. */

for xsd:decimal and derivates

{{{ /** Returns the value as a float. */

for xsd:float

{{{ /** Returns the value as a double. */

for xsd:double

{{{ /** Returns the decoded hexbinary value as an InputStream. */

for xsd:hexBinary

{{{ /** Returns the decoded base64 value as anInputStream. */

for xsd:base64Binary

{{{ /** Returns the value as a {@link java.util.Calendar}. */

for all data related schema types: dateTime, time, date, gYearMonth, gYear, gMonth, gDay (for some of them defaults are used, same as GDateSpecification.getCalendar() ) Should this method return XmlCalendar which extends GregorianCalendar?

{{{ /** Returns the value as a {@link java.util.Date}. */

for all data related schema types: dateTime, time, date, gYearMonth, gYear, gMonth, gDay (for some of them defaults are used, same as GDateSpecification.getDate() )

{{{ /** Returns the value as a {@link org.apache.xmlbeans.GDate}. */

for all data related schema types: dateTime, time, date, gYearMonth, gYear, gMonth, gDay {{{ /** Returns the value as a {@link org.apache.xmlbeans.GDuration}. */

for xsd:duration

{{{ /** Returns the value as a {@link javax.xml.namespace.QName}. */

for:xsd:QName

Attributes

Because of the way XMLStreamReader is designed the stream can be positioned on attributes only when a substream represents the content of an element and attributes don't have an element to hang on. For this kind of attributes the above methods should work.

For attributes in an usual document, the interface is providing two more sets of methods, in the same manner of XMLStreamReader's getAttributeValue(int index) and getAttribute(String uri, String local)

{{{ public int getAttributeIntValue(int index) throws XMLStreamException;

same pattern for the rest of the types.

White space

For easier access to extended or xsd:list values getString*Value() has one more form where one can pass in the white space style to be applied.

The three white space styles coresponding to XMLSchema whitespace facet: WS_PRESERVE, WS_REPLACE and WS_COLLAPSE.

{{{ public String getStringValue(int wsStyle) throws XMLStreamException;

Notes

NonvalidatingStronglyTypedWrapperOverJSR173Parser (last edited 2009-09-20 23:33:18 by localhost)