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, ITextPM, IValuePM, PresentationModel, Supportable, Validatable
Direct Known Subclasses:
BigDecimalPM, BooleanPM, DatePM, IconTextPM

public class TextPM
extends AbstractValuePM
implements ITextPM

The TextPM is a presentation model for a text value.

The default value is a empty string.

Author:
Michael Karneim

Nested Class Summary
 class TextPM.DefaultOptionsValidationRule
           
protected  class TextPM.TextComparable
           
 
Nested classes/interfaces inherited from class org.beanfabrics.model.AbstractValuePM
AbstractValuePM.DefaultValidationRule
 
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
           
 
Constructor Summary
TextPM()
          Constructs a new TextPM.
TextPM(java.lang.String initialText)
          Constructs a new TextPM.
 
Method Summary
 java.lang.Comparable getComparable()
           
protected  java.lang.String getDefaultText()
          Get the default text value of this model.
 Options getOptions()
           
 java.lang.String getText()
          Returns the text value of this model.
 java.lang.String getText(boolean convertWhitespaceStringToNull)
           
 boolean isEmpty()
          Return true if the content of this model is interpreted as empty.
 boolean isModified()
          Returns if this object was modified (means: if the text value equals the default text).
 boolean isRestrictedToOptions()
           
 void preset()
          Sets the text value as default text.
 void reformat()
          Parses the content and formats it.
 void reset()
          Sets the default text as text value.
protected  void setDefaultText(java.lang.String aText)
          Sets the default text value of this model.
 void setOptions(Options newOptions)
           
 void setRestrictedToOptions(boolean restrictedToOptions)
          If set to true this TextPM is only valid if it's text content is contained in it's options.
 void setText(java.lang.String aText)
          Set the text to be stored in this model.
 java.lang.String toString()
           
 
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
createPropertiesValidationRule, 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, 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 model.

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 text to be stored in this model. If the argument is null, it will be changed into the empty string "".

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

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.

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 it's text content is contained in it's options.

Parameters:
restrictedToOptions -

isEmpty

public boolean isEmpty()
Return true if the content of this model is interpreted as empty.

Specified by:
isEmpty in interface IValuePM
Returns:
true if content is empty, else false

isModified

public boolean isModified()
Returns if this object was modified (means: if the text value equals the default text).

Specified by:
isModified in interface ITextPM

reset

public void reset()
Sets the default text as text value.

Specified by:
reset in interface ITextPM

preset

public void preset()
Sets the text value as default text.

Specified by:
preset in interface ITextPM

reformat

public void reformat()
Parses the content and formats it.

Specified by:
reformat in interface ITextPM

getOptions

public Options getOptions()
Specified by:
getOptions in interface ITextPM

setOptions

public void setOptions(Options newOptions)
Specified by:
setOptions in interface ITextPM

getComparable

public java.lang.Comparable getComparable()
Specified by:
getComparable in interface IValuePM

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


© 2010 by Michael Karneim, http://www.beanfabrics.org