dsto.dfc.databeans.io
Class TextDefaultCodec

java.lang.Object
  extended by dsto.dfc.databeans.io.TextDefaultCodec
All Implemented Interfaces:
TextDecoder, TextEncoder

public class TextDefaultCodec
extends Object
implements TextEncoder, TextDecoder

Generic text encoder/decoder that uses toString () to encode and the single String argument constructor to decode.

Version:
$Revision$
Author:
mpp

Constructor Summary
TextDefaultCodec()
           
 
Method Summary
 boolean canEncode(XmlEncodeContext context, Object value)
          Test if this codec can encode a given object.
 Object decode(Class type, String text)
          Decode a text value.
 String encode(Object value)
          Encode a value into text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextDefaultCodec

public TextDefaultCodec()
Method Detail

canEncode

public boolean canEncode(XmlEncodeContext context,
                         Object value)
Description copied from interface: TextEncoder
Test if this codec can encode a given object.

Specified by:
canEncode in interface TextEncoder
Parameters:
context - The current encode context.
value - The value. May be null.
Returns:
True if this encoder should be used for value.

encode

public String encode(Object value)
              throws IllegalArgumentException
Description copied from interface: TextEncoder
Encode a value into text.

Specified by:
encode in interface TextEncoder
Parameters:
value - The value to encode.
Returns:
String The encoded value.
Throws:
IllegalArgumentException - if the value cannot be encoded.

decode

public Object decode(Class type,
                     String text)
              throws IllegalArgumentException
Description copied from interface: TextDecoder
Decode a text value.

Specified by:
decode in interface TextDecoder
Parameters:
type - The type of value expected.
text - The text form of the value.
Returns:
Object The decoded value.
Throws:
IllegalArgumentException - if the value cannot be decoded.


Copyright © 2008 Commonwealth of Australia