public abstract class IlvAbstractSDMModel extends IlvBasicSDMModel
IlvAbstractSDMModel
implements an SDM model whose nodes and links
are instances of the IlvSDMNode
and IlvSDMLink
interfaces.
This class is abstract because it does not define
the storage of the nodes and links. You can use
the default implementation IlvDefaultSDMModel
that simply stores the nodes and links in memory. Alternatively,
you can write your own subclass if your application
already defines the storage of the objects, or if the
objects are obtained from an external data source such as
a database. If you write your
own subclass, you must define the following methods:
IlvSDMModel.addObject(java.lang.Object, java.lang.Object, java.lang.Object)
,
IlvSDMModel.getObjects()
,
IlvSDMModel.getObject(java.lang.String)
,
IlvSDMModel.clear()
,
The objects contained in the model must implement the
IlvSDMNode
or IlvSDMLink
interface. You can use the default implementations
IlvDefaultSDMNode
or IlvDefaultSDMLink
,
or you can write your own classes that implement IlvSDMNode
and
IlvSDMLink
to wrap your application objects
into the model.
The application must build the SDM
by calling the model's addObject
method
for each data object.
By default, when the model's content is read from an XML file,
the nodes and links will be new instances of
IlvDefaultSDMNode
and IlvDefaultSDMLink
.
Note that, if you want to read your own node and link classes
from an XML file, you must implement the "mutable" versions
of the node and link interfaces
(IlvMutableSDMNode
and
IlvMutableSDMLink
).
IlvSDMNode
,
IlvSDMLink
,
IlvMutableSDMNode
,
IlvMutableSDMLink
,
IlvDefaultSDMNode
,
IlvDefaultSDMLink
,
Serialized FormConstructor and Description |
---|
IlvAbstractSDMModel()
Creates a new, empty SDM model.
|
Modifier and Type | Method and Description |
---|---|
Object |
createLink(String tag)
Creates a new instance of
IlvDefaultSDMLink . |
Object |
createNode(String tag)
Creates a new instance of
IlvDefaultSDMNode . |
Enumeration |
getChildren(Object parent)
Returns the children of the specified data object.
|
Object |
getFrom(Object link)
Returns the node that is the source
of the specified link.
|
protected String |
getIDImpl(Object obj)
Returns the identifier of the object.
|
Object |
getObjectProperty(Object object,
String property)
Returns a property of an object.
|
String[] |
getObjectPropertyNames(Object obj)
Returns the names of all the properties of an object.
|
Object |
getParent(Object obj)
Returns the parent of an object, or
null
if the object has no parent. |
String |
getTag(Object obj)
Returns the symbolic type (the "tag") of an object.
|
Object |
getTo(Object link)
Returns the node that is the destination
of the specified link.
|
boolean |
isEditable()
Returns the property that indicates whether this
model can be edited.
|
boolean |
isLink(Object obj)
Returns
true if the specified data object
is a link, that is, if it is an instance of
a class that implements the IlvSDMLink
interface. |
void |
setEditable(boolean editable)
Sets the property that indicates whether this
model can be edited.
|
void |
setFrom(Object link,
Object node)
Sets the source node of the specified link.
|
protected void |
setIDImpl(Object obj,
String id)
Sets the identifier of an object.
|
void |
setObjectProperty(Object object,
String property,
Object value)
Sets a property of an object and fires a
propertyChanged event. |
void |
setTo(Object link,
Object node)
Sets the destination node of the specified link.
|
addObject, addObjectImpl, addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, firePropertyChanged, getID, getObject, isAdjusting, removeObject, removeSDMModelListener, removeSDMPropertyChangeListener, setAdjusting, setID
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, getObjects
public IlvAbstractSDMModel()
addObject
method.public Enumeration getChildren(Object parent)
getChildren
in interface IlvSDMModel
getChildren
in class IlvBasicSDMModel
parent
- The parent of the children in the specified data object.IlvSDMNode
s.public Object getParent(Object obj)
null
if the object has no parent.
getParent
in interface IlvSDMModel
getParent
in class IlvBasicSDMModel
obj
- The object whose parent is queried.null
.public boolean isLink(Object obj)
true
if the specified data object
is a link, that is, if it is an instance of
a class that implements the IlvSDMLink
interface.isLink
in interface IlvSDMModel
isLink
in class IlvBasicSDMModel
obj
- The object whose type is queried.false
.public Object getFrom(Object link)
getFrom
in interface IlvSDMModel
getFrom
in class IlvBasicSDMModel
link
- The link whose source node is queried.null
.public Object getTo(Object link)
getTo
in interface IlvSDMModel
getTo
in class IlvBasicSDMModel
link
- The link whose destination node is queried.null
.protected String getIDImpl(Object obj)
getIDImpl
in class IlvBasicSDMModel
obj
- The object whose identifier is requested.String
that identifies the object in a unique way.IlvBasicSDMModel.getID(java.lang.Object)
protected void setIDImpl(Object obj, String id)
setIDImpl
in class IlvBasicSDMModel
obj
- The object whose identifier is to be changed.id
- The new identifier.IlvBasicSDMModel.setID(java.lang.Object, java.lang.String)
public String getTag(Object obj)
obj
- The object whose tag is requested.String
that identifies the symbolic type of the object.public Object getObjectProperty(Object object, String property)
object
- The object whose property is to be set.property
- The property name.Object
representing the
value of the specified property, or null
if the property has not been set.public void setObjectProperty(Object object, String property, Object value)
propertyChanged
event.setObjectProperty
in interface IlvSDMModel
setObjectProperty
in class IlvBasicSDMModel
object
- The object whose property is to be set.property
- The property name.value
- The new property value.public String[] getObjectPropertyNames(Object obj)
obj
- The object whose property names are queried.public Object createNode(String tag)
IlvDefaultSDMNode
.createNode
in interface IlvSDMModel
createNode
in class IlvBasicSDMModel
tag
- The tag of the new node.public Object createLink(String tag)
IlvDefaultSDMLink
.createLink
in interface IlvSDMModel
createLink
in class IlvBasicSDMModel
tag
- The tag of the new link.public void setFrom(Object link, Object node)
setFrom
in interface IlvSDMModel
setFrom
in class IlvBasicSDMModel
link
- The link whose source node is to be set.node
- The new source node of the link.public void setTo(Object link, Object node)
setTo
in interface IlvSDMModel
setTo
in class IlvBasicSDMModel
link
- The link whose destination node is to be set.node
- The new destination node of the link.public boolean isEditable()
isEditable
in interface IlvSDMModel
isEditable
in class IlvBasicSDMModel
setEditable(boolean)
public void setEditable(boolean editable)
editable
- The new value of the "editable" property.isEditable()
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.