org.jdesktop.binding.metadata
Class NumberMetaData

java.lang.Object
  extended by org.jdesktop.binding.metadata.MetaData
      extended by org.jdesktop.binding.metadata.NumberMetaData

public class NumberMetaData
extends MetaData

Class for representing meta-data for a numerical data field which is one of the following types:

This meta-data class defines additional properties and edit constraints which are applicable to numerical values, such as minimum, maximum, whether or not the value is a currency, etc. Example usage:

     NumberMetaData metaData = new NumberMetaData("interestrate",
                                                  Float.class, "Interest Rate");
     metaData.setMinimum(new Float(4.5));
     metaData.setMaximum(new Float(6.8));
 
Setting a minimum and/or maximum constraint will implicitly cause a range validator to be added to the meta-data object.

Version:
1.0
Author:
Amy Fowler

Field Summary
protected  boolean currency
           
protected  java.lang.Number maximum
           
protected  java.lang.Number minimum
           
 
Fields inherited from class org.jdesktop.binding.metadata.MetaData
converter, customProps, decodeFormat, displayWidth, encodeFormat, klass, label, maxValueCount, minValueCount, name, pcs, readOnly, validators
 
Constructor Summary
NumberMetaData()
          Instantiates a meta-data object with a default name "numbervalue" and a default field class equal to java.lang.Integer.
NumberMetaData(java.lang.String name)
          Instantiates a meta-data object with the specified name and a default field class equal to java.lang.Integer.
NumberMetaData(java.lang.String name, java.lang.Class klass)
          Instantiates a meta-data object with the specified name and field class.
NumberMetaData(java.lang.String name, java.lang.Class klass, java.lang.String label)
          Instantiates a meta-data object with the specified name, field class, and label.
 
Method Summary
 java.lang.Number getMaximum()
          Gets the meta-data "maximum" property which indicates the maximum value of the associated data field.
 java.lang.Number getMinimum()
          Gets the meta-data "minimum" property which indicates the minimum value of the associated data field.
 boolean isCurrency()
          Gets the meta-data "currency" property which indicates whether this data field represents a currency value.
 void setCurrency(boolean currency)
          Sets the meta-data "currency" property.
 void setMaximum(java.lang.Number maximum)
          Sets the meta-data "maximum" property.
 void setMinimum(java.lang.Number minimum)
          Sets the meta-data "minimum" property.
 
Methods inherited from class org.jdesktop.binding.metadata.MetaData
addPropertyChangeListener, addValidator, firePropertyChange, firePropertyChange, firePropertyChange, getConverter, getCustomProperty, getCustomProperty, getCustomPropertyKeys, getDecodeFormat, getDisplayWidth, getElementClass, getEncodeFormat, getLabel, getMaxValueCount, getMinValueCount, getName, getPropertyChangeListeners, getValidators, isReadOnly, isRequired, removeCustomProperty, removePropertyChangeListener, removeValidator, setConverter, setCustomProperty, setDecodeFormat, setDisplayWidth, setElementClass, setEncodeFormat, setLabel, setMaxValueCount, setMinValueCount, setName, setReadOnly, setRequired
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minimum

protected java.lang.Number minimum

maximum

protected java.lang.Number maximum

currency

protected boolean currency
Constructor Detail

NumberMetaData

public NumberMetaData()
Instantiates a meta-data object with a default name "numbervalue" and a default field class equal to java.lang.Integer. This provides the no-argument constructor required for JavaBeans. It is recommended that the program explicitly set a meaningful "name" property.


NumberMetaData

public NumberMetaData(java.lang.String name)
Instantiates a meta-data object with the specified name and a default field class equal to java.lang.Integer.

Parameters:
name - String containing the name of the data field

NumberMetaData

public NumberMetaData(java.lang.String name,
                      java.lang.Class klass)
Instantiates a meta-data object with the specified name and field class.

Parameters:
name - String containing the name of the data field
klass - Class indicating type of data field

NumberMetaData

public NumberMetaData(java.lang.String name,
                      java.lang.Class klass,
                      java.lang.String label)
Instantiates a meta-data object with the specified name, field class, and label.

Parameters:
name - String containing the name of the data field
klass - Class indicating type of data field
label - String containing the user-displayable label for the data field
Method Detail

getMinimum

public java.lang.Number getMinimum()
Gets the meta-data "minimum" property which indicates the minimum value of the associated data field. The default is null, which indicates no minimum.

Returns:
Number containing the minimum value of the data field.
See Also:
setMinimum(java.lang.Number)

setMinimum

public void setMinimum(java.lang.Number minimum)
Sets the meta-data "minimum" property. Setting a minimum and/or maximum will cause an appropriate range validator object to be added to this meta-data object.

Parameters:
minimum - Number containing the minimum value of the data field.
Throws:
java.lang.IllegalArgumentException - if the minimum object's class does not equal the meta-data's field class
See Also:
getMinimum()

getMaximum

public java.lang.Number getMaximum()
Gets the meta-data "maximum" property which indicates the maximum value of the associated data field. The default is null, which indicates no maximum.

Returns:
Number containing the maximum value of the data field.
See Also:
setMaximum(java.lang.Number)

setMaximum

public void setMaximum(java.lang.Number maximum)
Sets the meta-data "maximum" property. Setting a minimum and/or maximum will cause an appropriate range validator object to be added to this meta-data object.

Parameters:
maximum - Number containing the maximum value of the data field.
Throws:
java.lang.IllegalArgumentException - if the maximum object's class does not equal the meta-data's field class
See Also:
getMaximum()

isCurrency

public boolean isCurrency()
Gets the meta-data "currency" property which indicates whether this data field represents a currency value. The default is false.

Returns:
boolean indicating whether the data field represents a currency
See Also:
setCurrency(boolean)

setCurrency

public void setCurrency(boolean currency)
Sets the meta-data "currency" property.

Parameters:
currency - boolean indicating whether the data field represents a currency
See Also:
isCurrency()


Copyright © 2005 Sun Microsystems All Rights Reserved.