Package io.guise.framework.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
,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
Fields Modifier and Type Field Description static java.lang.String
INVALID_VALUE_MESSAGE_PROPERTY
The invalid value message bound property.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.
-
-
-
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 isnull
.- 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 isnull
. - 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 isnull
. - 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, elsefalse
.
-
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.
-
-