org.milyn.javabean
Interface DataDecoder

All Superinterfaces:
ContentHandler
All Known Implementing Classes:
BigDecimalDecoder, BigIntegerDecoder, BooleanDecoder, ByteDecoder, CalendarDecoder, CharacterDecoder, CharsetDecoder, CSVDecoder, DateDecoder, DoubleDecoder, FloatDecoder, FreeMarkerTemplateDecoder, IntegerDecoder, LongDecoder, MappingDecoder, MVELExpressionEvaluatorDecoder, ShortDecoder, SqlDateDecoder, SqlTimeDecoder, StringDecoder, URIDecoder, URLDecoder

public interface DataDecoder
extends ContentHandler

Data decoder.

A data decoder converts data (encoded in a String) to an Object of some form, determined by the decoder implementation.

There are a number of pre-installed decoders in the org.milyn.javabean.decoders package. Smooks will attempt to automatically load a data type decoder from the org.milyn.javabean.decoders package, but only after it has attempted to load the decoder from the context configuration, using a selector key of "decoder:type", where "type" is the type alias used on the property binding configuration (see the "OrderDateLong" definition in the sample in org.milyn.javabean.BeanPopulator in the Javabeans Cartridge.

If one of the decoders in org.milyn.javabean.decoders is not what's needed, simply implement a new decoder using this interface. If you want the decoder to be automatically picked up from the type alias specified on the binding configuration (e.g in the same way as the decoders for types "Long", "Integer" etc are picked up) simply package the new decoder in the org.milyn.javabean.decoders package and follow the class naming convention of "typeDecoder".

Some type decoders will however need to be configured as a Smooks resource because they will require configuration of one sort or another. For an example of this, look at the "OrderDateLong" decoder definition in the sample in org.milyn.javabean.BeanPopulator in the Javabeans Cartridge.

Author:
tom.fennelly@gmail.com

Nested Class Summary
static class DataDecoder.Factory
          Factory method for constructing decoders defined in the "decoders" package.
 
Method Summary
 Object decode(String data)
          Decode the supplied String data into a new Object data instance.
 

Method Detail

decode

Object decode(String data)
              throws DataDecodeException
Decode the supplied String data into a new Object data instance.

Parameters:
data - Data to be decoded.
Returns:
Decoded data Object.
Throws:
DataDecodeException - Error decoding data.


Copyright © 2008. All Rights Reserved.