com.guiseframework.converter
Class AbstractConverter<V,L>

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.event.GuiseBoundPropertyObject
          extended by com.guiseframework.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 com.guiseframework.converter.Converter
INVALID_VALUE_MESSAGE_PROPERTY
 
Constructor Summary
AbstractConverter()
           
 
Method Summary
 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 com.guiseframework.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 com.guiseframework.converter.Converter
convertLiteral, convertValue, getSession
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

AbstractConverter

public AbstractConverter()
Method Detail

getInvalidValueMessage

public java.lang.String getInvalidValueMessage()
Specified by:
getInvalidValueMessage in interface Converter<V,L>
Returns:
The invalid value message text, which may include a resource reference.

setInvalidValueMessage

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

Specified by:
setInvalidValueMessage in interface Converter<V,L>
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:
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 interface Converter<V,L>
Parameters:
literal - The literal value to validate.
Returns:
true if the literal is valid, else false.

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 using Object.equals(Object).

Specified by:
isEquivalent in interface Converter<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.


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