org.codehaus.stax2.typed
Class TypedValueDecoder

java.lang.Object
  extended by org.codehaus.stax2.typed.TypedValueDecoder
Direct Known Subclasses:
ValueDecoderFactory.DecoderBase

public abstract class TypedValueDecoder
extends Object

Base class that defines generic typed value decoder API used by TypedXMLStreamReader to allow for efficient customized decoding of textual xml content into actual typed values. Set of concrete decoders is also included in the reference implementation of the Typed Access API.

Details of how value decoded is to be accessed is NOT defined as part of this interface: since decoders are explicitly passed by callers, they can (and need to) use more specific sub-classes with value access method or methods.

Note: to allow for optimal efficiency, there are multiple decode methods, one of which gets called during decoding process. This is necessary since the stream reader implementations may use different internal representations, either in general (an implementation might stored everyting as Strings; another as character arrays).

Since:
3.0
Author:
Tatu Saloranta

Constructor Summary
TypedValueDecoder()
           
 
Method Summary
abstract  void decode(char[] buffer, int start, int end)
          Method used to invoke decoding functionality, for decoding the value encoded in given portion of character array It is to try decoding value, and either store decoded value for later access (using method(s) caller knows about), or throw an exception to indicate problem encountered.
abstract  void decode(String input)
          Method used to invoke decoding functionality, for decoding the value encoded in given substring.
abstract  void handleEmptyValue()
          Method called in cases where value to decode would be empty, after trimming leading and trailing white space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedValueDecoder

public TypedValueDecoder()
Method Detail

decode

public abstract void decode(String input)
                     throws IllegalArgumentException
Method used to invoke decoding functionality, for decoding the value encoded in given substring. It is to try decoding value, and either store decoded value for later access (using method(s) caller knows about), or throw an exception to indicate problem encountered.

Note: method will get called with "trimmed" input, i.e. input will never have any leading or trailing white space. It will also never be called with empty content (handleEmptyValue() is called instead for such cases)

Throws:
IllegalArgumentException

decode

public abstract void decode(char[] buffer,
                            int start,
                            int end)
                     throws IllegalArgumentException
Method used to invoke decoding functionality, for decoding the value encoded in given portion of character array It is to try decoding value, and either store decoded value for later access (using method(s) caller knows about), or throw an exception to indicate problem encountered.

Note: method will get called with "trimmed" input, i.e. input will never have any leading or trailing white space. It will also never be called with empty content (handleEmptyValue() is called instead for such cases)

Throws:
IllegalArgumentException

handleEmptyValue

public abstract void handleEmptyValue()
                               throws IllegalArgumentException
Method called in cases where value to decode would be empty, after trimming leading and trailing white space. Decoder can then either change its state (to contain value to return) or throw appropriate exception

Throws:
IllegalArgumentException


Copyright © 2011 Codehaus. All Rights Reserved.