org.beanfabrics.model
Class BigDecimalPM

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
                      extended by org.beanfabrics.model.BigDecimalPM
All Implemented Interfaces:
Bean, ContextOwner, HasComparable, IBigDecimalPM, ITextPM, IValuePM, PresentationModel, Supportable, Validatable
Direct Known Subclasses:
DecimalPM, IntegerPM, MoneyPM

public class BigDecimalPM
extends TextPM
implements IBigDecimalPM

The BigDecimalPM is a PresentationModel that contains a BigDecimal value.

This class is the base class for any other 'numeric' presentation models in Beanfabrics since it has the most generic validation rule (see BigDecimalPM.BigDecimalValidationRule) and content conversion methods.


Nested Class Summary
protected  class BigDecimalPM.BigDecimalComparable
          The BigDecimalPM.BigDecimalComparable delegates the comparison to the model's BigDecimal value if available, or otherwise falls back to the super.compareTo(...)
 class BigDecimalPM.BigDecimalValidationRule
          This rule evaluates to invalid if the PM's value can't be converted into a BigDecimal.
static class BigDecimalPM.Format
          The BigDecimalPM.Format is a IFormat for converting between BigDecimal and String.
 
Nested classes/interfaces inherited from class org.beanfabrics.model.TextPM
TextPM.DefaultOptionsValidationRule, TextPM.TextComparable
 
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
 
Fields inherited from class org.beanfabrics.model.TextPM
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
BigDecimalPM()
          Constructs a BigDecimalPM.
 
Method Summary
protected  IFormat<java.math.BigDecimal> createDefaultFormat()
          Creates the default format for this PM.
 java.math.BigDecimal getBigDecimal()
          Returns the value of this PM as a BigDecimal.
 java.math.BigInteger getBigInteger()
          Returns the value of this PM as a BigInteger.
 java.lang.Comparable<?> getComparable()
          Returns the comparable substitute.
protected static java.text.DecimalFormat getDecimalFormat(java.util.Locale locale)
          Factory method for creating a DecimalFormat for the specified Locale.
 IFormat<java.math.BigDecimal> getFormat()
          Returns the IFormat of this PM used for converting between BigDecimal and String values.
 void reformat()
          Reformats the text value by first parsing it and the formatting it using this PM's format.
 void setBigDecimal(java.math.BigDecimal value)
          Sets the value of this PM to the given BigDecimal value.
 void setBigInteger(java.math.BigInteger value)
          Sets the value of this PM to the giben BigInteger value.
 void setDefaultBigDecimal(java.math.BigDecimal value)
          Sets the default value of this PM to the given BigDecimal value.
 void setDefaultBigInteger(java.math.BigInteger value)
          Sets the default value of this PM to the given BigInteger value.
 void setFormat(IFormat<java.math.BigDecimal> newFormat)
          Sets the format of this PM and reformats the text value.
 
Methods inherited from class org.beanfabrics.model.TextPM
getDefaultText, getOptions, getText, getText, isEmpty, isModified, isRestrictedToOptions, preset, reset, setDefaultText, setOptions, setRestrictedToOptions, setText
 
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.ITextPM
getOptions, getText, isModified, preset, reset, setOptions, setText
 
Methods inherited from interface org.beanfabrics.model.IValuePM
getDescription, getTitle, isEditable, isEmpty, 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
 

Constructor Detail

BigDecimalPM

public BigDecimalPM()
Constructs a BigDecimalPM.

Method Detail

reformat

public void reformat()
Reformats the text value by first parsing it and the formatting it using this PM's format.

Specified by:
reformat in interface ITextPM
Overrides:
reformat in class TextPM
See Also:
#setFormat(DecimalFormat)

createDefaultFormat

protected IFormat<java.math.BigDecimal> createDefaultFormat()
Creates the default format for this PM. This method is called from the constructor and usually returns a BigDecimalPM.Format with the default DecimalFormat of the current Locale.

Returns:
the default format for this PM

getDecimalFormat

protected static java.text.DecimalFormat getDecimalFormat(java.util.Locale locale)
Factory method for creating a DecimalFormat for the specified Locale.

Parameters:
locale -
Returns:
the new DecimalFormat.

getFormat

public IFormat<java.math.BigDecimal> getFormat()
Returns the IFormat of this PM used for converting between BigDecimal and String values.

Returns:
the format

setFormat

public void setFormat(IFormat<java.math.BigDecimal> newFormat)
Sets the format of this PM and reformats the text value. The format is used for converting between BigDecimal and String values.

Parameters:
newFormat - the new format

setBigDecimal

public void setBigDecimal(java.math.BigDecimal value)
Sets the value of this PM to the given BigDecimal value.

Specified by:
setBigDecimal in interface IBigDecimalPM
See Also:
ITextPM.setText(String)

getBigDecimal

public java.math.BigDecimal getBigDecimal()
                                   throws ConversionException
Returns the value of this PM as a BigDecimal.

Specified by:
getBigDecimal in interface IBigDecimalPM
Returns:
the value of this PM as a BigDecimal
Throws:
ConversionException - if the text value can't be converted into a valid BigDecimal

setDefaultBigDecimal

public void setDefaultBigDecimal(java.math.BigDecimal value)
Sets the default value of this PM to the given BigDecimal value.

Parameters:
value -
See Also:
TextPM.setDefaultText(String)

setBigInteger

public void setBigInteger(java.math.BigInteger value)
Sets the value of this PM to the giben BigInteger value.

Parameters:
value -
See Also:
TextPM.setText(String)

getBigInteger

public java.math.BigInteger getBigInteger()
                                   throws ConversionException
Returns the value of this PM as a BigInteger.

Returns:
the value of this PM as a BigInteger
Throws:
ConversionException - if the text value can't be converted into a valid BigInteger

setDefaultBigInteger

public void setDefaultBigInteger(java.math.BigInteger value)
Sets the default value of this PM to the given BigInteger value.

Parameters:
value -
See Also:
TextPM.setDefaultText(String)

getComparable

public java.lang.Comparable<?> getComparable()
Description copied from class: TextPM
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 TextPM
Returns:
the comparable substitute