com.guiseframework.converter
Interface Converter<V,L>

Type Parameters:
V - The value type this converter supports.
L - The literal type of the lexical form of the value.
All Superinterfaces:
com.globalmentor.beans.PropertyBindable
All Known Subinterfaces:
NumberStringLiteralConverter<V>
All Known Implementing Classes:
AbstractConverter, AbstractDateStringLiteralConverter, AbstractNumberStringLiteralConverter, AbstractStringLiteralConverter, AbstractURIStringLiteralConverter, BaseURIStringLiteralConverter, BooleanStringLiteralConverter, CalendarStringLiteralConverter, CharArrayStringLiteralConverter, DateStringLiteralConverter, DefaultStringLiteralConverter, DefaultURIStringLiteralConverter, DoubleStringLiteralConverter, EmailAddressStringLiteralConverter, FloatStringLiteralConverter, IntegerStringLiteralConverter, LocaleStringLiteralConverter, LongStringLiteralConverter, PathURIStringLiteralConverter, PlainIntegerStringLiteralConverter, PlainLongStringLiteralConverter, RDFURIStringLiteralConverter, StringStringLiteralConverter, TelephoneNumberStringLiteralConverter

public interface Converter<V,L>
extends com.globalmentor.beans.PropertyBindable

Indicates an object that can convert a value from and to its lexical form.

Author:
Garret Wilson
See Also:
Resources#CONVERTER_INVALID_VALUE_MESSAGE_RESOURCE_REFERENCE

Field Summary
static java.lang.String INVALID_VALUE_MESSAGE_PROPERTY
          The invalid value message bound property.
 
Method Summary
 V convertLiteral(L literal)
          Converts a literal representation of a value from the lexical space into a value in the value space.
 L convertValue(V value)
          Converts a value from the value space to a literal value in the lexical space.
 java.lang.String getInvalidValueMessage()
           
 GuiseSession getSession()
           
 boolean isEquivalent(V value, L literal)
          Determines if the given literal in the lexical space is a valid representation of the given value in the value space.
 boolean isValidLiteral(L literal)
          Determines whether a given literal value in the lexical space can be converted to a value in the value space.
 void setInvalidValueMessage(java.lang.String newInvalidValueMessage)
          Sets the text of the invalid value message.
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

INVALID_VALUE_MESSAGE_PROPERTY

static final java.lang.String INVALID_VALUE_MESSAGE_PROPERTY
The invalid value message bound property.

Method Detail

getInvalidValueMessage

java.lang.String getInvalidValueMessage()
Returns:
The invalid value message text, which may include a resource reference.

setInvalidValueMessage

void setInvalidValueMessage(java.lang.String newInvalidValueMessage)
Sets the text of the invalid value message. This is a bound property.

Parameters:
newInvalidValueMessage - The new text of the invalid value message, which may include a resource reference.
Throws:
java.lang.NullPointerException - if the given message is null.
See Also:
INVALID_VALUE_MESSAGE_PROPERTY

getSession

GuiseSession getSession()
Returns:
The Guise session that owns this converter.

convertLiteral

V convertLiteral(L literal)
                 throws ConversionException
Converts a literal representation of a value from the lexical space into a value in the value space.

Parameters:
literal - The literal value in the lexical space to convert.
Returns:
The converted value in the value space, or null if the given literal is null.
Throws:
ConversionException - if the literal value cannot be converted.

convertValue

L convertValue(V value)
               throws ConversionException
Converts a value from the value space to a literal value in the lexical space.

Parameters:
value - The value in the value space to convert.
Returns:
The converted value in the lexical space, or null if the given literal is null.
Throws:
ConversionException - if the value cannot be converted.

isValidLiteral

boolean isValidLiteral(L literal)
Determines whether a given literal value in the lexical space can be converted to a value in the value space.

Parameters:
literal - The literal value to validate.
Returns:
true if the literal is valid, else false.

isEquivalent

boolean isEquivalent(V value,
                     L literal)
Determines if the given literal in the lexical space is a valid representation of the given value in the value space.

Parameters:
value - The value to compare.
literal - The literal value in the lexical space to compare with the value after conversion.
Returns:
true if the given literal in the lexical space is a valid representation of the given value in the value space.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.