public abstract class IlvJavaBeanSDMModel extends IlvBasicSDMModel
IlvJavaBeanSDMModel
is an SDM data model
that uses the Java introspection mechanism. Each object
contained in the model is considered as a Java bean, and
its properties are read and written using introspection.
This class can be used as a convenient base class to implement simple custom SDM data models that return existing Java objects created by an application.
This class is abstract because it does not define how the
objects are stored in the model. At the very least, subclasses
must implement the IlvSDMModel.getObjects()
and IlvSDMModel.clear()
methods.
Constructor and Description |
---|
IlvJavaBeanSDMModel()
Creates a new JavaBean model.
|
Modifier and Type | Method and Description |
---|---|
Object |
createLink(String tag)
This method returns a new instance of the Java class
of name
tag . |
Object |
createNode(String tag)
This method returns a new instance of the Java class
of name
tag . |
Object |
getFrom(Object link)
This method returns the value of the JavaBean property
specified by
setFromProperty(java.lang.String) . |
String |
getFromProperty()
Returns the name of the JavaBean property holding a reference
to the source node of a link.
|
protected String |
getIDImpl(Object obj)
This method returns the value of the Java bean property
specified by
setIDProperty(java.lang.String) . |
String |
getIDProperty()
Returns the name of the JavaBean property holding the
ID of an object.
|
Object |
getObjectProperty(Object obj,
String property)
This method retrieves the value of the specified
property using bean introspection.
|
String[] |
getObjectPropertyNames(Object obj)
This method uses bean introspection to determine
the names of the properties that can
be retrieved for an object.
|
String |
getTag(Object obj)
Returns the symbolic type (the "tag") of an object.
|
Object |
getTo(Object link)
This method returns the value of the JavaBean property
specified by
setToProperty(java.lang.String) . |
String |
getToProperty()
Returns the name of the JavaBean property holding a reference
to the destination node of a link.
|
boolean |
isEditable()
Returns
true to indicate that this
model can be edited. |
boolean |
isLink(Object obj)
This method returns
true if and only if
getFrom(obj) and getTo(obj)
return a non-null value. |
void |
setFrom(Object link,
Object from)
This method sets the value of the JavaBean property
specified by
setFromProperty(java.lang.String) . |
void |
setFromProperty(String property)
Sets the name of the JavaBean property holding a reference
to the source node of a link.
|
protected void |
setIDImpl(Object obj,
String id)
This method sets the value of the JavaBean property
specified by
setIDProperty(java.lang.String) . |
void |
setIDProperty(String property)
Sets the name of the JavaBean property holding the
ID of an object.
|
void |
setObjectProperty(Object object,
String property,
Object value)
This method sets the value of the specified
property using bean introspection.
|
void |
setTo(Object link,
Object to)
This method sets the value of the Java bean property
specified by
setToProperty(java.lang.String) . |
void |
setToProperty(String property)
Sets the name of the JavaBean property holding a reference
to the destination node of a link.
|
addObject, addObjectImpl, addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, firePropertyChanged, getChildren, getID, getObject, getParent, isAdjusting, removeObject, removeSDMModelListener, removeSDMPropertyChangeListener, setAdjusting, setID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, getObjects
public void setIDProperty(String property)
null
,
object IDs are allocated automatically. The property
is initially null
.property
- The JavaBean property.public String getIDProperty()
public void setFromProperty(String property)
null
,
the model will not consider any object as a link. The property
is initially null
.property
- The new JavaBean property.public String getFromProperty()
public void setToProperty(String property)
null
,
the model will not consider any object as a link. The property
is initially null
.property
- The new JavaBean property.public String getToProperty()
public boolean isLink(Object obj)
true
if and only if
getFrom(obj)
and getTo(obj)
return a non-null
value.isLink
in interface IlvSDMModel
isLink
in class IlvBasicSDMModel
obj
- The object whose type is queried.false
.public Object getFrom(Object link)
setFromProperty(java.lang.String)
. If no property
was specified, this method returns null
.getFrom
in interface IlvSDMModel
getFrom
in class IlvBasicSDMModel
link
- The link whose source node is queried.null
.public Object getTo(Object link)
setToProperty(java.lang.String)
. If no property
was specified, this method returns null
.getTo
in interface IlvSDMModel
getTo
in class IlvBasicSDMModel
link
- The link whose destination node is queried.null
.public void setFrom(Object link, Object from)
setFromProperty(java.lang.String)
. If no property
was specified, this method does nothing.setFrom
in interface IlvSDMModel
setFrom
in class IlvBasicSDMModel
link
- The link whose source node is to be set.from
- The new source of the link.public void setTo(Object link, Object to)
setToProperty(java.lang.String)
. If no property
was specified, this method does nothing.setTo
in interface IlvSDMModel
setTo
in class IlvBasicSDMModel
link
- The link whose destination node is to be set.to
- The new destination of the link.protected String getIDImpl(Object obj)
setIDProperty(java.lang.String)
. If no property
was specified, this method returns null
.getIDImpl
in class IlvBasicSDMModel
obj
- The object whose identifier is requested.IlvBasicSDMModel.getID(java.lang.Object)
protected void setIDImpl(Object obj, String id)
setIDProperty(java.lang.String)
. If no property
was specified, this method does nothing.setIDImpl
in class IlvBasicSDMModel
obj
- The object whose identifier is to be set.id
- The new identifier of the object.IlvBasicSDMModel.setID(java.lang.Object, java.lang.String)
public String getTag(Object obj)
This implementation returns the name of the Java class of the object.
obj
- The object whose tag is requested.String
that identifies the symbolic type of the object.public Object getObjectProperty(Object obj, String property)
obj
- The object whose property is queried.property
- The name of the property.Object
representing the
value of the specified property, or null
if the object does not have or support the specified
property.public void setObjectProperty(Object object, String property, Object value)
setObjectProperty
in interface IlvSDMModel
setObjectProperty
in class IlvBasicSDMModel
object
- The object whose property must be set.property
- The name of the property to set.value
- The new value of the property.public String[] getObjectPropertyNames(Object obj)
obj
- The object whose property names are queried.public boolean isEditable()
true
to indicate that this
model can be edited.isEditable
in interface IlvSDMModel
isEditable
in class IlvBasicSDMModel
public Object createNode(String tag)
tag
.createNode
in interface IlvSDMModel
createNode
in class IlvBasicSDMModel
tag
- The class name of the new node.public Object createLink(String tag)
tag
.createLink
in interface IlvSDMModel
createLink
in class IlvBasicSDMModel
tag
- The class name of the new link.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.