com.fasterxml.jackson.xml.deser
Class FromXmlParser

java.lang.Object
  extended by org.codehaus.jackson.JsonParser
      extended by org.codehaus.jackson.impl.JsonParserMinimalBase
          extended by com.fasterxml.jackson.xml.deser.FromXmlParser
All Implemented Interfaces:
Closeable, org.codehaus.jackson.Versioned

public class FromXmlParser
extends org.codehaus.jackson.impl.JsonParserMinimalBase

JsonParser implementation that exposes XML structure as set of JSON events that can be used for data binding.

Since:
1.6

Nested Class Summary
static class FromXmlParser.Feature
          Enumeration that defines all togglable features for XML parsers
 
Nested classes/interfaces inherited from class org.codehaus.jackson.JsonParser
org.codehaus.jackson.JsonParser.NumberType
 
Field Summary
protected  byte[] _binaryValue
          We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue(org.codehaus.jackson.Base64Variant) will not need to decode data more than once.
protected  org.codehaus.jackson.util.ByteArrayBuilder _byteArrayBuilder
          ByteArrayBuilder is needed if 'getBinaryValue' is called.
protected  boolean _closed
          Flag that indicates whether parser is closed or not.
protected  String _currText
           
protected  org.codehaus.jackson.io.IOContext _ioContext
           
protected  boolean _mayBeLeaf
          We need special handling to keep track of whether a value may be exposed as simple leaf value.
protected  org.codehaus.jackson.JsonToken _nextToken
           
protected  org.codehaus.jackson.ObjectCodec _objectCodec
           
protected  org.codehaus.jackson.impl.JsonReadContext _parsingContext
          Information about parser context, context in which the next token is to be parsed (root, array, object).
protected  int _xmlFeatures
          Bit flag composed of bits that indicate which FromXmlParser.Features are enabled.
protected  XmlTokenStream _xmlTokens
           
protected static String UNNAMED_TEXT_PROPERTY
          In cases where a start element has both attributes and non-empty textual value, we have to create a bogus property; we will use this as the property name.
 
Fields inherited from class org.codehaus.jackson.impl.JsonParserMinimalBase
INT_APOSTROPHE, INT_ASTERISK, INT_b, INT_BACKSLASH, INT_COLON, INT_COMMA, INT_CR, INT_f, INT_LBRACKET, INT_LCURLY, INT_LF, INT_n, INT_QUOTE, INT_r, INT_RBRACKET, INT_RCURLY, INT_SLASH, INT_SPACE, INT_t, INT_TAB, INT_u
 
Fields inherited from class org.codehaus.jackson.JsonParser
_currToken, _features, _lastClearedToken
 
Constructor Summary
FromXmlParser(org.codehaus.jackson.io.IOContext ctxt, int genericParserFeatures, int xmlFeatures, org.codehaus.jackson.ObjectCodec codec, XMLStreamReader xmlReader)
           
 
Method Summary
protected  byte[] _decodeBase64(org.codehaus.jackson.Base64Variant b64variant)
           
protected  org.codehaus.jackson.util.ByteArrayBuilder _getByteArrayBuilder()
           
protected  void _handleEOF()
          Method called when an EOF is encountered between tokens.
protected  void _releaseBuffers()
          Method called to release internal buffers owned by the base parser.
protected  void _reportBase64EOF()
           
protected  void _reportInvalidBase64(org.codehaus.jackson.Base64Variant b64variant, char ch, int bindex, String msg)
           
 void close()
           
 FromXmlParser configure(FromXmlParser.Feature f, boolean state)
           
 FromXmlParser disable(FromXmlParser.Feature f)
           
 FromXmlParser enable(FromXmlParser.Feature f)
           
 BigInteger getBigIntegerValue()
           
 byte[] getBinaryValue(org.codehaus.jackson.Base64Variant b64variant)
           
 org.codehaus.jackson.ObjectCodec getCodec()
           
 org.codehaus.jackson.JsonLocation getCurrentLocation()
          Method that returns location of the last processed character; usually for error reporting purposes
 String getCurrentName()
          Method that can be called to get the name associated with the current event.
 BigDecimal getDecimalValue()
           
 double getDoubleValue()
           
 float getFloatValue()
           
 int getIntValue()
           
 long getLongValue()
           
 org.codehaus.jackson.JsonParser.NumberType getNumberType()
           
 Number getNumberValue()
           
 org.codehaus.jackson.impl.JsonReadContext getParsingContext()
           
 XMLStreamReader getStaxReader()
          Method that allows application direct access to underlying Stax XMLStreamWriter.
 String getText()
           
 char[] getTextCharacters()
           
 int getTextLength()
           
 int getTextOffset()
           
 org.codehaus.jackson.JsonLocation getTokenLocation()
          Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.
 boolean hasTextCharacters()
          XML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.
 boolean isClosed()
           
 boolean isEnabled(FromXmlParser.Feature f)
           
 boolean isExpectedStartArrayToken()
          Since xml representation can not really distinguish between array and object starts (both are represented with elements), this method is overridden and taken to mean that expecation is that the current start element is to mean 'start array', instead of default of 'start object'.
 org.codehaus.jackson.JsonToken nextToken()
           
 void setCodec(org.codehaus.jackson.ObjectCodec c)
           
 
Methods inherited from class org.codehaus.jackson.impl.JsonParserMinimalBase
_constructError, _getCharDesc, _handleUnrecognizedCharacterEscape, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportUnexpectedChar, _throwInternal, _throwInvalidSpace, _throwUnquotedSpace, _wrapError, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsLong, skipChildren
 
Methods inherited from class org.codehaus.jackson.JsonParser
_constructError, clearCurrentToken, configure, disable, disableFeature, enable, enableFeature, getBinaryValue, getBooleanValue, getByteValue, getCurrentToken, getEmbeddedObject, getLastClearedToken, getShortValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsLong, hasCurrentToken, isEnabled, isFeatureEnabled, nextValue, readValueAs, readValueAs, readValueAsTree, releaseBuffered, releaseBuffered, setFeature, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNNAMED_TEXT_PROPERTY

protected static final String UNNAMED_TEXT_PROPERTY
In cases where a start element has both attributes and non-empty textual value, we have to create a bogus property; we will use this as the property name.

See Also:
Constant Field Values

_xmlFeatures

protected int _xmlFeatures
Bit flag composed of bits that indicate which FromXmlParser.Features are enabled.


_objectCodec

protected org.codehaus.jackson.ObjectCodec _objectCodec

_closed

protected boolean _closed
Flag that indicates whether parser is closed or not. Gets set when parser is either closed by explicit call (close()) or when end-of-input is reached.


_ioContext

protected final org.codehaus.jackson.io.IOContext _ioContext

_parsingContext

protected org.codehaus.jackson.impl.JsonReadContext _parsingContext
Information about parser context, context in which the next token is to be parsed (root, array, object).


_xmlTokens

protected final XmlTokenStream _xmlTokens

_mayBeLeaf

protected boolean _mayBeLeaf
We need special handling to keep track of whether a value may be exposed as simple leaf value.


_nextToken

protected org.codehaus.jackson.JsonToken _nextToken

_currText

protected String _currText

_byteArrayBuilder

protected org.codehaus.jackson.util.ByteArrayBuilder _byteArrayBuilder
ByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content.


_binaryValue

protected byte[] _binaryValue
We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue(org.codehaus.jackson.Base64Variant) will not need to decode data more than once.

Constructor Detail

FromXmlParser

public FromXmlParser(org.codehaus.jackson.io.IOContext ctxt,
                     int genericParserFeatures,
                     int xmlFeatures,
                     org.codehaus.jackson.ObjectCodec codec,
                     XMLStreamReader xmlReader)
Method Detail

getCodec

public org.codehaus.jackson.ObjectCodec getCodec()
Specified by:
getCodec in class org.codehaus.jackson.JsonParser

setCodec

public void setCodec(org.codehaus.jackson.ObjectCodec c)
Specified by:
setCodec in class org.codehaus.jackson.JsonParser

enable

public FromXmlParser enable(FromXmlParser.Feature f)

disable

public FromXmlParser disable(FromXmlParser.Feature f)

isEnabled

public final boolean isEnabled(FromXmlParser.Feature f)

configure

public FromXmlParser configure(FromXmlParser.Feature f,
                               boolean state)

getStaxReader

public XMLStreamReader getStaxReader()
Method that allows application direct access to underlying Stax XMLStreamWriter. Note that use of writer is discouraged, and may interfere with processing of this writer; however, occasionally it may be necessary.

Note: writer instance will always be of type XMLStreamWriter2 (including Typed Access API) so upcasts are safe.

Since:
1.7

getCurrentName

public String getCurrentName()
                      throws IOException,
                             org.codehaus.jackson.JsonParseException
Method that can be called to get the name associated with the current event.

Specified by:
getCurrentName in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException

isClosed

public boolean isClosed()
Specified by:
isClosed in class org.codehaus.jackson.impl.JsonParserMinimalBase

getParsingContext

public org.codehaus.jackson.impl.JsonReadContext getParsingContext()
Specified by:
getParsingContext in class org.codehaus.jackson.impl.JsonParserMinimalBase

getTokenLocation

public org.codehaus.jackson.JsonLocation getTokenLocation()
Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.

Specified by:
getTokenLocation in class org.codehaus.jackson.JsonParser

getCurrentLocation

public org.codehaus.jackson.JsonLocation getCurrentLocation()
Method that returns location of the last processed character; usually for error reporting purposes

Specified by:
getCurrentLocation in class org.codehaus.jackson.JsonParser

isExpectedStartArrayToken

public boolean isExpectedStartArrayToken()
Since xml representation can not really distinguish between array and object starts (both are represented with elements), this method is overridden and taken to mean that expecation is that the current start element is to mean 'start array', instead of default of 'start object'.

Overrides:
isExpectedStartArrayToken in class org.codehaus.jackson.JsonParser

nextToken

public org.codehaus.jackson.JsonToken nextToken()
                                         throws IOException,
                                                org.codehaus.jackson.JsonParseException
Specified by:
nextToken in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

getText

public String getText()
               throws IOException,
                      org.codehaus.jackson.JsonParseException
Specified by:
getText in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

getTextCharacters

public char[] getTextCharacters()
                         throws IOException,
                                org.codehaus.jackson.JsonParseException
Specified by:
getTextCharacters in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

getTextLength

public int getTextLength()
                  throws IOException,
                         org.codehaus.jackson.JsonParseException
Specified by:
getTextLength in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

getTextOffset

public int getTextOffset()
                  throws IOException,
                         org.codehaus.jackson.JsonParseException
Specified by:
getTextOffset in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

hasTextCharacters

public boolean hasTextCharacters()
XML input actually would offer access to character arrays; but since we must coalesce things it cannot really be exposed.

Specified by:
hasTextCharacters in class org.codehaus.jackson.impl.JsonParserMinimalBase

getBinaryValue

public byte[] getBinaryValue(org.codehaus.jackson.Base64Variant b64variant)
                      throws IOException,
                             org.codehaus.jackson.JsonParseException
Specified by:
getBinaryValue in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
IOException
org.codehaus.jackson.JsonParseException

_decodeBase64

protected byte[] _decodeBase64(org.codehaus.jackson.Base64Variant b64variant)
                        throws IOException,
                               org.codehaus.jackson.JsonParseException
Throws:
IOException
org.codehaus.jackson.JsonParseException

_reportInvalidBase64

protected void _reportInvalidBase64(org.codehaus.jackson.Base64Variant b64variant,
                                    char ch,
                                    int bindex,
                                    String msg)
                             throws org.codehaus.jackson.JsonParseException
Parameters:
bindex - Relative index within base64 character unit; between 0 and 3 (as unit has exactly 4 characters)
Throws:
org.codehaus.jackson.JsonParseException

_reportBase64EOF

protected void _reportBase64EOF()
                         throws org.codehaus.jackson.JsonParseException
Throws:
org.codehaus.jackson.JsonParseException

getBigIntegerValue

public BigInteger getBigIntegerValue()
                              throws IOException,
                                     org.codehaus.jackson.JsonParseException
Specified by:
getBigIntegerValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getDecimalValue

public BigDecimal getDecimalValue()
                           throws IOException,
                                  org.codehaus.jackson.JsonParseException
Specified by:
getDecimalValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getDoubleValue

public double getDoubleValue()
                      throws IOException,
                             org.codehaus.jackson.JsonParseException
Specified by:
getDoubleValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getFloatValue

public float getFloatValue()
                    throws IOException,
                           org.codehaus.jackson.JsonParseException
Specified by:
getFloatValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getIntValue

public int getIntValue()
                throws IOException,
                       org.codehaus.jackson.JsonParseException
Specified by:
getIntValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getLongValue

public long getLongValue()
                  throws IOException,
                         org.codehaus.jackson.JsonParseException
Specified by:
getLongValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getNumberType

public org.codehaus.jackson.JsonParser.NumberType getNumberType()
                                                         throws IOException,
                                                                org.codehaus.jackson.JsonParseException
Specified by:
getNumberType in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

getNumberValue

public Number getNumberValue()
                      throws IOException,
                             org.codehaus.jackson.JsonParseException
Specified by:
getNumberValue in class org.codehaus.jackson.JsonParser
Throws:
IOException
org.codehaus.jackson.JsonParseException

_handleEOF

protected void _handleEOF()
                   throws org.codehaus.jackson.JsonParseException
Method called when an EOF is encountered between tokens. If so, it may be a legitimate EOF, but only iff there is no open non-root context.

Specified by:
_handleEOF in class org.codehaus.jackson.impl.JsonParserMinimalBase
Throws:
org.codehaus.jackson.JsonParseException

_releaseBuffers

protected void _releaseBuffers()
                        throws IOException
Method called to release internal buffers owned by the base parser.

Throws:
IOException

_getByteArrayBuilder

protected org.codehaus.jackson.util.ByteArrayBuilder _getByteArrayBuilder()


Copyright © 2011 fasterxml.com. All Rights Reserved.