|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.sdedit.ui.components.configuration.Bean<T>
T - the interface type of the data objectpublic class Bean<T extends DataObject>
A Bean provides a single instance of a "data object" that implements the T interface which should only define get-, set-, and is-methods like a Java bean. The instance is returned by getDataObject(). For all manipulations of the data object's state (invocations of set-methods) the Bean immediately sends notifications to all interested PropertyChangeListeners. The state of the data object can be loaded and stored, using XML documents (see load(Document, String), store(Document, String, String)). The values of the data object can also be accessed by passing their corresponding properties as arguments (see setValue(PropertyDescriptor, Object), getValue(String)).
The values returned by the data object managed by a Bean are always, provided the bean has been set up/loaded properly, not null (this can be enforced by the permitNullValues property set to false), and legal, i. e. string properties for which there is a set of alternative values are always assigned to a legal value.
| Constructor Summary | |
|---|---|
Bean(Class<T> dataClass,
StringSelectionProvider ssp)
Creates a new bean that provides a single data object. |
|
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener that is notified when a property is modified via setValue(PropertyDescriptor, Object). |
Bean<T> |
copy()
Returns a shallow copy of this bean. |
boolean |
equals(Object o)
Returns true if and only if o is a reference to a bean with the same properties that have the same values as this bean's properties. |
T |
getDataObject()
Returns the synthetic data object implementing the data interface belonging to this Bean. |
Collection<PropertyDescriptor> |
getProperties()
Returns the properties of this Bean that are annotated with an Adjustable annotation. |
PropertyDescriptor |
getProperty(String name)
Returns the PropertyDescriptor for the property with the given name. |
Set<String> |
getStringsForProperty(PropertyDescriptor property)
Returns a set of strings representing all alternative values for the given String property. |
Object |
getValue(PropertyDescriptor pd)
|
Object |
getValue(String property)
Returns the current value of the given property, represented by its name. |
int |
hashCode()
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
|
boolean |
isPermitNullValues()
Returns a flag denoting if null values can be used as parameters of the data object's set methods. |
void |
load(Document document,
String pathToElement)
Changes this bean's properties' values such that they reflect the values found in the given document. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener. |
void |
setPermitNullValues(boolean permitNullValues)
Sets a flag denoting if null values can be used as parameters of the data object's set methods. |
void |
setValue(PropertyDescriptor property,
Object value)
Sets a new value for a property and informs all PropertyChangeListeners about that. |
void |
store(Document document,
String pathToParent,
String elementName)
Stores all properties' current values in a newly created subtree of the given document. |
void |
takeValuesFrom(Bean<T> bean)
Changes this bean's properties' values such that they are equal to the given bean's properties' values. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Bean(Class<T> dataClass,
StringSelectionProvider ssp)
dataClass - the interface type of the data objectssp - a StringSelectionProvider that provides an array of
strings for methods of the data object which are annotated
Adjustable.stringSelectionProvided()| Method Detail |
|---|
public T getDataObject()
public final Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
invoke in interface InvocationHandlerThrowableInvocationHandler.invoke(java.lang.Object,
java.lang.reflect.Method, java.lang.Object[])public Collection<PropertyDescriptor> getProperties()
public PropertyDescriptor getProperty(String name)
name - the name of a property
public void addPropertyChangeListener(PropertyChangeListener listener)
listener - a listener that is notified when a property is modified via
setValue(PropertyDescriptor, Object)public void removePropertyChangeListener(PropertyChangeListener listener)
listener - the listener to be removedpublic void takeValuesFrom(Bean<T> bean)
bean - another beanpublic Bean<T> copy()
public final Object getValue(String property)
property - the name of a property
public final Object getValue(PropertyDescriptor pd)
public void load(Document document,
String pathToElement)
throws DocUtil.XMLException
document - a documentpathToElement - XPath to the subtree where the properties' values are
described
DocUtil.XMLException
public void store(Document document,
String pathToParent,
String elementName)
throws DocUtil.XMLException
document - the documentpathToParent - XPath to the parent of the root of the subtreeelementName - the name of the root of the subtree
DocUtil.XMLException
public final void setValue(PropertyDescriptor property,
Object value)
property - the descriptor of the propertyvalue - the new value of the propertypublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class ObjectObject.hashCode()public Set<String> getStringsForProperty(PropertyDescriptor property)
property - a String property
public String toString()
toString in class Objectpublic boolean isPermitNullValues()
public void setPermitNullValues(boolean permitNullValues)
permitNullValues - a flag denoting if null values can be used as
parameters of the data object's set methods
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||