net.sourceforge.jeuclid.context.typewrapper
Interface TypeWrapper

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractSimpleTypeWrapper, BooleanTypeWrapper, ColorTypeWrapper, EnumTypeWrapper, NumberTypeWrapper, StringTypeWrapper, TLIListTypeWrapper

public interface TypeWrapper
extends Serializable

Encapsulates information about a parameter's value type and how values should be converted between strings and the appropriate object instances.

This allows elimination of an additional "evil" if-elseif...else" pattern.

Version:
$Revision: 03dc0884e86f $

Field Summary
static String FAILED_TO_CONVERT
          Error message for failed to convert 1/2.
static String TO
          Error message for failed to convert 2/2.
 
Method Summary
 Object fromString(String value)
          Attempts to convert a parameter value expressed as string into an instance of the appropriate (for this parameter) type.
 Class<?> getValueType()
           
 String toString(Object value)
          Attempts to convert a parameter value expressed as an object of the appropriate (for this parameter) type into a string representation.
 boolean valid(Object o)
          Checks if the object is of a valid type for this type info.
 

Field Detail

FAILED_TO_CONVERT

static final String FAILED_TO_CONVERT
Error message for failed to convert 1/2.

See Also:
Constant Field Values

TO

static final String TO
Error message for failed to convert 2/2.

See Also:
Constant Field Values
Method Detail

getValueType

Class<?> getValueType()
Returns:
the class instance being wrapped

valid

boolean valid(Object o)
Checks if the object is of a valid type for this type info.

Parameters:
o - the object to check
Returns:
true if the parameter can be set.

fromString

Object fromString(String value)
Attempts to convert a parameter value expressed as string into an instance of the appropriate (for this parameter) type.

Parameters:
value - parameter value as string
Returns:
parameter value as an instance of the proper type

toString

String toString(Object value)
Attempts to convert a parameter value expressed as an object of the appropriate (for this parameter) type into a string representation.

Parameters:
value - parameter value as object
Returns:
parameter value as string


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.