org.beanfabrics.model
Class TextPM

java.lang.Object
  extended by org.beanfabrics.AbstractBean
      extended by org.beanfabrics.ValidatableBean
          extended by org.beanfabrics.model.AbstractPM
              extended by org.beanfabrics.model.AbstractValuePM
                  extended by org.beanfabrics.model.TextPM
All Implemented Interfaces:
Bean, ContextOwner, HasComparable, ITextPM, IValuePM, PresentationModel, Supportable, Validatable
Direct Known Subclasses:
BigDecimalPM, BooleanPM, DatePM, HorizontalAlignmentPM, IconTextPM, ImageTextPM, PathPM, PhoneNumberPM, RegexPM

public class TextPM
extends AbstractValuePM
implements ITextPM

The TextPM is a presentation model for a text value.

The default value is an empty string.


Nested Class Summary
 class TextPM.DefaultOptionsValidationRule
           
protected  class TextPM.TextComparable
          The TextPM.TextComparable delegates the comparison to a CollationKey constructed from the PM's text using a Collator.
 
Nested classes/interfaces inherited from class org.beanfabrics.model.AbstractValuePM
AbstractValuePM.MandatoryValidationRule
 
Nested classes/interfaces inherited from class org.beanfabrics.model.AbstractPM
AbstractPM.PropertiesValidationRule
 
Field Summary
protected static java.lang.String KEY_MESSAGE_VALUE_NOT_AN_OPTION
           
 
Fields inherited from class org.beanfabrics.model.AbstractValuePM
KEY_MESSAGE_MANDATORY
 
Fields inherited from class org.beanfabrics.model.AbstractPM
KEY_MESSAGE_ONE_OR_MORE_INVALID
 
Constructor Summary
TextPM()
          Constructs a new TextPM.
TextPM(java.lang.String initialText)
          Constructs a new TextPM.
 
Method Summary
 java.lang.Comparable<?> getComparable()
          Returns the comparable substitute.
protected  java.lang.String getDefaultText()
          Get the default text value of this model.
 Options getOptions()
          Returns the options.
 java.lang.String getText()
          Returns the text value of this PM.
 java.lang.String getText(boolean convertWhitespaceStringToNull)
           
 boolean isEmpty()
          Returns whether the value of this PM is interpreted as an empty value.
 boolean isModified()
          Returns whether this PM is modified.
 boolean isRestrictedToOptions()
           
 void preset()
          Sets the default text of this PM to the text value of this PM.
 void reformat()
          Reformats the text value by first parsing it and the formatting it with an appropriate format.
 void reset()
          Sets the value of this PM to the value of the default text.
protected  void setDefaultText(java.lang.String aText)
          Sets the default text value of this model.
 void setOptions(Options newOptions)
          Sets the Options.
 void setRestrictedToOptions(boolean restrictedToOptions)
          If set to true this TextPM is only valid if its text content is contained in its options.
 void setText(java.lang.String aText)
          Set the value of this OPm to the given text.
 
Methods inherited from class org.beanfabrics.model.AbstractValuePM
getDescription, getTitle, isEditable, isMandatory, revalidate, setDescription, setEditable, setMandatory, setTitle
 
Methods inherited from class org.beanfabrics.model.AbstractPM
getContext, getSupportMap, revalidateProperties
 
Methods inherited from class org.beanfabrics.ValidatableBean
getValidationState, getValidator, isValid, setValidationState
 
Methods inherited from class org.beanfabrics.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, equals, getPropertyChangeSupport, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.beanfabrics.model.IValuePM
getDescription, getTitle, isEditable, isMandatory, setDescription, setEditable, setMandatory, setTitle
 
Methods inherited from interface org.beanfabrics.Bean
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeSupport, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface org.beanfabrics.validation.Validatable
getValidationState, getValidator, isValid, revalidate
 
Methods inherited from interface org.beanfabrics.support.Supportable
getSupportMap
 
Methods inherited from interface org.beanfabrics.context.ContextOwner
getContext
 

Field Detail

KEY_MESSAGE_VALUE_NOT_AN_OPTION

protected static final java.lang.String KEY_MESSAGE_VALUE_NOT_AN_OPTION
See Also:
Constant Field Values
Constructor Detail

TextPM

public TextPM(java.lang.String initialText)
Constructs a new TextPM.


TextPM

public TextPM()
Constructs a new TextPM.

Method Detail

getText

public java.lang.String getText()
Returns the text value of this PM.

Specified by:
getText in interface ITextPM
Returns:
the text value

getText

public java.lang.String getText(boolean convertWhitespaceStringToNull)

setText

public void setText(java.lang.String aText)
Set the value of this OPm to the given text. If the argument is null, it will be changed into the empty string "".

Specified by:
setText in interface ITextPM
Parameters:
aText - the text value

getDefaultText

protected java.lang.String getDefaultText()
Get the default text value of this model.

Returns:
the default text value

setDefaultText

protected void setDefaultText(java.lang.String aText)
Sets the default text value of this model.

Use reset() to set the model's value to it's default value or preset() to set the model's default value to it's current value.

Note: Setting this default value does does not necessarily mean that the actual value of this PM is changed to that value also.

Parameters:
aText - the text to set as default value

isRestrictedToOptions

public boolean isRestrictedToOptions()

setRestrictedToOptions

public void setRestrictedToOptions(boolean restrictedToOptions)
If set to true this TextPM is only valid if its text content is contained in its options.

Parameters:
restrictedToOptions -

isEmpty

public boolean isEmpty()
Returns whether the value of this PM is interpreted as an empty value.

Specified by:
isEmpty in interface IValuePM
Returns:
true if this PM contains an empty value

isModified

public boolean isModified()
Returns whether this PM is modified. This PM is modified if the text value isn't equal to the default text.

Specified by:
isModified in interface ITextPM
See Also:
ITextPM.getText(), ITextPM.preset()

reset

public void reset()
Sets the value of this PM to the value of the default text.

Specified by:
reset in interface ITextPM

preset

public void preset()
Sets the default text of this PM to the text value of this PM.

Specified by:
preset in interface ITextPM

reformat

public void reformat()
Reformats the text value by first parsing it and the formatting it with an appropriate format. It is not required that this method has any effect.

Specified by:
reformat in interface ITextPM

getOptions

public Options getOptions()
Description copied from interface: ITextPM
Returns the options.

Specified by:
getOptions in interface ITextPM
Returns:
the options
See Also:
ITextPM.setOptions(Options)

setOptions

public void setOptions(Options newOptions)
Description copied from interface: ITextPM
Sets the Options. This attribute is used by some view components to show possible text values that can be choosen.

Specified by:
setOptions in interface ITextPM

getComparable

public java.lang.Comparable<?> getComparable()
Returns the comparable substitute. This substitute can be used for comparison of this object with another.

Override this method to control how instances of this class are sorted by a Sorter.

The default implementation returns a TextPM.TextComparable or one of its subclasses.

Specified by:
getComparable in interface HasComparable
Overrides:
getComparable in class AbstractPM
Returns:
the comparable substitute