Package io.guise.framework.converter
Class AbstractConverter<V,L>
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.event.GuiseBoundPropertyObject
-
- io.guise.framework.converter.AbstractConverter<V,L>
-
- Type Parameters:
V
- The value type this converter supports.L
- The literal type of the lexical form of the value.
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,Converter<V,L>
- Direct Known Subclasses:
AbstractDateStringLiteralConverter
,AbstractNumberStringLiteralConverter
,AbstractStringLiteralConverter
,LocaleStringLiteralConverter
public abstract class AbstractConverter<V,L> extends GuiseBoundPropertyObject implements Converter<V,L>
An abstract implementation an object that can convert a value from and to its lexical form.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
-
Fields inherited from interface io.guise.framework.converter.Converter
INVALID_VALUE_MESSAGE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getInvalidValueMessage()
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 class io.guise.framework.event.GuiseBoundPropertyObject
getSession
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.guise.framework.converter.Converter
convertLiteral, convertValue, getSession
-
-
-
-
Method Detail
-
getInvalidValueMessage
public java.lang.String getInvalidValueMessage()
- Specified by:
getInvalidValueMessage
in interfaceConverter<V,L>
- Returns:
- The invalid value message text, which may include a resource reference.
-
setInvalidValueMessage
public void setInvalidValueMessage(java.lang.String newInvalidValueMessage)
Description copied from interface:Converter
Sets the text of the invalid value message. This is a bound property.- Specified by:
setInvalidValueMessage
in interfaceConverter<V,L>
- Parameters:
newInvalidValueMessage
- The new text of the invalid value message, which may include a resource reference.- See Also:
Converter.INVALID_VALUE_MESSAGE_PROPERTY
-
isValidLiteral
public boolean isValidLiteral(L literal)
Determines whether a given literal value in the lexical space can be converted to a value in the value space.This implementation attempts to convert the literal value and returns
false
if conversion is unsuccessful.- Specified by:
isValidLiteral
in interfaceConverter<V,L>
- Parameters:
literal
- The literal value to validate.- Returns:
true
if the literal is valid, elsefalse
.
-
isEquivalent
public 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.This implementation assumes that non-
null
values can correctly be compared usingObject.equals(Object)
.- Specified by:
isEquivalent
in interfaceConverter<V,L>
- 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.
-
-