|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.binding.metadata.MetaData
public class MetaData
Class for representing the meta-data for an field in a data model. A "field" may map to a column on a RowSet, a property on a JavaBean, or some other discrete data element on a data model. The meta-data describes aspects of a data field such as it's name, type, and edit constraints. This class may be used when such information isn't encapsulated in the data model object itself and thus must be represented in an external object. Meta-data is intended only for holding state about a data model element and is not intended for implementing application semantics.
A meta-data object should be initialized at a minimum with a name, class,
and label. Additional meta-data properties can be set as necessary.
For example:
MetaData metaData = new MetaData("firstname", String.class,
"First Name");
metaData.setRequired(true);
If the associated data model field requires application-specific validation
logic to verify the correctness of a potential value, one or more Validator
instances can be added to the meta-data object. Example:
MetaData metaData = new MetaData("creditcard", String.class,
"Credit Card Number"
metaData.setRequired(true);
metaData.addValidator(new MyCreditCardValidator());
Field Summary | |
---|---|
protected Converter |
converter
|
protected java.util.Map |
customProps
|
protected java.lang.Object |
decodeFormat
|
protected int |
displayWidth
|
protected java.lang.Object |
encodeFormat
|
protected java.lang.Class |
klass
|
protected java.lang.String |
label
|
protected int |
maxValueCount
|
protected int |
minValueCount
|
protected java.lang.String |
name
|
protected java.beans.PropertyChangeSupport |
pcs
|
protected boolean |
readOnly
|
protected java.util.ArrayList |
validators
|
Constructor Summary | |
---|---|
MetaData()
Instantiates a meta-data object with a default name "value" and a default field class equal to java.lang.String . |
|
MetaData(java.lang.String name)
Instantiates a meta-data object with the specified name and a default field class equal to java.lang.String . |
|
MetaData(java.lang.String name,
java.lang.Class klass)
Instantiates a meta-data object with the specified name and field class. |
|
MetaData(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 | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds the specified property change listener to this meta-data object. |
void |
addValidator(Validator validator)
Adds the specified validator for this meta-data. |
protected void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
|
protected void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
|
Converter |
getConverter()
Gets the meta-data's converter, which performs conversions between string values and objects of the associated data field's type. |
java.lang.Object |
getCustomProperty(java.lang.String propertyName)
|
java.lang.Object |
getCustomProperty(java.lang.String propertyName,
java.lang.Object defaultValue)
|
java.lang.String[] |
getCustomPropertyKeys()
|
java.lang.Object |
getDecodeFormat()
Gets the meta-data's decode format which is used when converting values from a string representation. |
int |
getDisplayWidth()
|
java.lang.Class |
getElementClass()
Gets the meta-data's "elementClass" property which indicates the type of the associated data field. |
java.lang.Object |
getEncodeFormat()
Gets the meta-data's encode format which is used when converting values to a string representation. |
java.lang.String |
getLabel()
Gets the meta-data's "label" property, which provides a label for the associated data field. |
int |
getMaxValueCount()
Gets the meta-data's "maxValueCount" property, which indicates the maximum number of values permitted for the data field. |
int |
getMinValueCount()
Gets the meta-data's "minValueCount" property, which indicates the minimum number of values required for the data field. |
java.lang.String |
getName()
Gets the meta-data "name" property which indicates the logical name of the associated data field. |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
|
Validator[] |
getValidators()
|
boolean |
isReadOnly()
Gets the meta-data's "readOnly" property which indicates whether or not the associated data field's value cannot be modified. |
boolean |
isRequired()
Convenience method for calculating whether the "minValueCount" property is greater than 0. |
void |
removeCustomProperty(java.lang.String propertyName)
Removes the custom property from the custom properties map. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes the specified property change listener from this meta-data object. |
void |
removeValidator(Validator validator)
Removes the specified validator for this meta-data. |
void |
setConverter(Converter converter)
Sets the meta-data's converter. |
void |
setCustomProperty(java.lang.String propertyName,
java.lang.Object value)
Places a custom property into this meta-data's custom properties map. |
void |
setDecodeFormat(java.lang.Object format)
Sets the meta-data's decode format which is used when converting values from a string representation. |
void |
setDisplayWidth(int displayWidth)
Sets the meta-data's "displayWidth" property which provides a hint as to the number of characters typically required to display the value. |
void |
setElementClass(java.lang.Class klass)
Sets the meta-data's "elementClass" property. |
void |
setEncodeFormat(java.lang.Object format)
Sets the meta-data's encode format which is used when converting values to a string representation. |
void |
setLabel(java.lang.String label)
Sets the meta-data's "label" property. |
void |
setMaxValueCount(int maxValueCount)
Sets the meta-data's "maxValueCount" property. |
void |
setMinValueCount(int minValueCount)
Sets the meta-data's "minValueCount" property. |
void |
setName(java.lang.String name)
Sets the meta-data "name" property. |
void |
setReadOnly(boolean readOnly)
Sets the meta-data's "readOnly" property. |
void |
setRequired(boolean required)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected java.lang.Class klass
protected java.lang.String label
protected Converter converter
protected java.lang.Object decodeFormat
protected java.lang.Object encodeFormat
protected boolean readOnly
protected int minValueCount
protected int maxValueCount
protected int displayWidth
protected java.util.ArrayList validators
protected java.util.Map customProps
protected java.beans.PropertyChangeSupport pcs
Constructor Detail |
---|
public MetaData()
java.lang.String
.
This provides the no-argument constructor required for JavaBeans.
It is recommended that the program explicitly set a meaningful
"name" property.
public MetaData(java.lang.String name)
java.lang.String
.
name
- String containing the name of the data fieldpublic MetaData(java.lang.String name, java.lang.Class klass)
name
- String containing the name of the data fieldklass
- Class indicating type of data fieldpublic MetaData(java.lang.String name, java.lang.Class klass, java.lang.String label)
name
- String containing the name of the data fieldklass
- Class indicating type of data fieldlabel
- String containing the user-displayable label for the
data fieldMethod Detail |
---|
public java.lang.String getName()
setName(java.lang.String)
public void setName(java.lang.String name)
name
- String containing the name of the data fieldgetName()
public java.lang.Class getElementClass()
java.lang.String
.
setElementClass(java.lang.Class)
public void setElementClass(java.lang.Class klass)
set
method is provided for meta-data bean initialization
only; the field class is not intended to be modified after initialization,
since other aspects of a meta-data object may depend on this type setting.
klass
- Class indicating type of data fieldgetElementClass()
public java.lang.String getLabel()
setLabel(java.lang.String)
public void setLabel(java.lang.String label)
label
- String containing the user-displable label for the
data fieldgetLabel()
public Converter getConverter()
null
.
Converters.get(java.lang.Class)
,
setConverter(org.jdesktop.binding.metadata.Converter)
,
getElementClass()
public void setConverter(Converter converter)
converter
- Converter used to perform conversions between string values
and objects of this field's typegetConverter()
public java.lang.Object getDecodeFormat()
null
.
setDecodeFormat(java.lang.Object)
public void setDecodeFormat(java.lang.Object format)
format
- object used to describe format for string-to-object conversiongetDecodeFormat()
,
DateFormat
public java.lang.Object getEncodeFormat()
null
.
setEncodeFormat(java.lang.Object)
public void setEncodeFormat(java.lang.Object format)
format
- object used to describe format for object-to-string conversiongetEncodeFormat()
,
DateFormat
public int getDisplayWidth()
public void setDisplayWidth(int displayWidth)
displayWidth
- integer containing the number of characters required to
display the value
java.lang.IllegalArgumentException
- if displayWidth < 0getDisplayWidth()
public boolean isReadOnly()
false
.
setReadOnly(boolean)
public void setReadOnly(boolean readOnly)
readOnly
- boolean indicating whether the data field is read-onlyisReadOnly()
public int getMinValueCount()
setMinValueCount(int)
public void setMinValueCount(int minValueCount)
minValueCount
- integer indicating the minimum number of values required for
the data fieldpublic boolean isRequired()
public void setRequired(boolean required)
public int getMaxValueCount()
List
collection.
List
,
setMaxValueCount(int)
public void setMaxValueCount(int maxValueCount)
maxValueCount
- integer indicating the maximum number of values permitted for
the data fieldpublic void setCustomProperty(java.lang.String propertyName, java.lang.Object value)
propertyName
- A non-null string of the form
com.mydomain.packagename.PropertyNamevalue
- The value for the named propertypublic java.lang.Object getCustomProperty(java.lang.String propertyName)
propertyName
- A non-null string of the form
com.mydomain.packagename.PropertyName
public java.lang.Object getCustomProperty(java.lang.String propertyName, java.lang.Object defaultValue)
propertyName
- A non-null string of the form com.mydomain.packagename.PropertyNamedefaultValue
- The default value to return if the custom properties map
does not contain they specified propertyName
public void removeCustomProperty(java.lang.String propertyName)
propertyName
- A non-null string of the form com.mydomain.packagename.PropertyNamepublic java.lang.String[] getCustomPropertyKeys()
public void addValidator(Validator validator)
validator
- Validator object which performs validation checks on
values being set on the associated data fieldremoveValidator(org.jdesktop.binding.metadata.Validator)
,
getValidators()
public void removeValidator(Validator validator)
validator
- Validator object which performs validation checks on
values being set on the associated data fieldaddValidator(org.jdesktop.binding.metadata.Validator)
public Validator[] getValidators()
addValidator(org.jdesktop.binding.metadata.Validator)
public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
pcl
- PropertyChangeListener object to receive events when meta-data
properties changepublic void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
pcl
- PropertyChangeListener object to receive events when meta-data
properties changepublic java.beans.PropertyChangeListener[] getPropertyChangeListeners()
protected void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
protected void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |