|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdesktop.swing.data.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 descrete 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 Object |
decodeFormat
|
protected Object |
encodeFormat
|
protected Class |
klass
|
protected String |
label
|
protected int |
maxValueCount
|
protected int |
minValueCount
|
protected String |
name
|
protected PropertyChangeSupport |
pcs
|
protected boolean |
readOnly
|
protected 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(String name)
Instantiates a meta-data object with the specified name and a default field class equal to java.lang.String. |
|
MetaData(String name,
Class klass)
Instantiates a meta-data object with the specified name and field class. |
|
MetaData(String name,
Class klass,
String label)
Instantiates a meta-data object with the specified name, field class, and label. |
|
| Method Summary | |
void |
addPropertyChangeListener(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. |
Converter |
getConverter()
Gets the meta-data's converter, which performs conversions between string values and objects of the associated data field's type. |
Object |
getDecodeFormat()
Gets the meta-data's decode format which is used when converting values from a string representation. |
Class |
getElementClass()
Gets the meta-data's "elementClass" property which indicates the type of the associated data field. |
Object |
getEncodeFormat()
Gets the meta-data's encode format which is used when converting values to a string representation. |
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. |
String |
getName()
Gets the meta-data "name" property which indicates the logical name of the associated data field. |
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 |
removePropertyChangeListener(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 |
setDecodeFormat(Object format)
Sets the meta-data's decode format which is used when converting values from a string representation. |
void |
setElementClass(Class klass)
Sets the meta-data's "elementClass" property. |
void |
setEncodeFormat(Object format)
Sets the meta-data's encode format which is used when converting values to a string representation. |
void |
setLabel(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(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 String name
protected Class klass
protected String label
protected Converter converter
protected Object decodeFormat
protected Object encodeFormat
protected boolean readOnly
protected int minValueCount
protected int maxValueCount
protected ArrayList validators
protected 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(String name)
java.lang.String.
name - String containing the name of the data field
public MetaData(String name,
Class klass)
name - String containing the name of the data fieldklass - Class indicating type of data field
public MetaData(String name,
Class klass,
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 field| Method Detail |
public String getName()
setName(java.lang.String)public void setName(String name)
name - String containing the name of the data fieldgetName()public Class getElementClass()
java.lang.String.
setElementClass(java.lang.Class)public void setElementClass(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 String getLabel()
setLabel(java.lang.String)public void setLabel(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.swing.data.Converter),
getElementClass()public void setConverter(Converter converter)
converter - Converter used to perform conversions between string values
and objects of this field's typegetConverter()public Object getDecodeFormat()
null.
setDecodeFormat(java.lang.Object)public void setDecodeFormat(Object format)
format - object used to describe format for string-to-object conversiongetDecodeFormat(),
DateFormatpublic Object getEncodeFormat()
null.
setEncodeFormat(java.lang.Object)public void setEncodeFormat(Object format)
format - object used to describe format for object-to-string conversiongetEncodeFormat(),
DateFormatpublic boolean isReadOnly()
false.
setReadOnly(boolean)public void setReadOnly(boolean readOnly)
readOnly - boolean indicating whether the data field is read-only#getReadOnlypublic 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 addValidator(Validator validator)
validator - Validator object which performs validation checks on
values being set on the associated data fieldremoveValidator(org.jdesktop.swing.data.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.swing.data.Validator)public Validator[] getValidators()
addValidator(org.jdesktop.swing.data.Validator)public void addPropertyChangeListener(PropertyChangeListener pcl)
pcl - PropertyChangeListener object to receive events when meta-data
properties changepublic void removePropertyChangeListener(PropertyChangeListener pcl)
pcl - PropertyChangeListener object to receive events when meta-data
properties changepublic PropertyChangeListener[] getPropertyChangeListeners()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||