public abstract class IlvBasicSDMModel extends Object implements IlvSDMModel, Serializable
IlvSDMModel
interface. It
is to be used as a base class for real SDM
models, so that implementers do not need to define
all the methods of the interface.
This basic SDM model provides a simple implementation of some of the methods (such as the listener management methods).
The implementations of the getID(java.lang.Object)
, setID(java.lang.Object, java.lang.String)
,
and addObject(java.lang.Object, java.lang.Object, java.lang.Object)
methods automatically allocate unique identifiers to objects.
To ensure that this allocation works properly, subclasses of
IlvBasicSDMModel
should not redefine
these methods directly, but rather the methods getIDImpl(java.lang.Object)
,
setIDImpl(java.lang.Object, java.lang.String)
, and addObjectImpl(java.lang.Object, java.lang.Object, java.lang.Object)
.
If you derive this class directly, you need to define (at the very least) the methods:
Constructor and Description |
---|
IlvBasicSDMModel()
Creates a new basic SDM model.
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(Object object,
Object parent,
Object before)
This method verifies that the added object has a unique ID,
and calls
addObjectImpl(java.lang.Object, java.lang.Object, java.lang.Object) to actually add the object
to the model. |
protected void |
addObjectImpl(Object object,
Object parent,
Object before)
This method does nothing since this model is not editable.
|
void |
addSDMModelListener(SDMModelListener listener)
Adds a listener to this SDM model.
|
void |
addSDMPropertyChangeListener(SDMPropertyChangeListener listener)
Adds a property change listener to this SDM model.
|
String |
allocID(String prefix)
Allocates a new, unused ID of the form
prefix n. |
boolean |
contains(Object object)
Tests if the object is contained in this model, that is,
if it has been added to the model using
addObject(java.lang.Object, java.lang.Object, java.lang.Object) and
not been removed from the model using removeObject(java.lang.Object) . |
Object |
createLink(String tag)
This method returns
null since this model is not editable. |
Object |
createNode(String tag)
This method returns
null since this model is not editable. |
void |
fireAdjustmentFinished()
This method calls the
adjustmentFinished
method of all the model listeners. |
void |
fireDataChanged(Object root)
This method calls the
dataChanged
method of all the model listeners. |
void |
fireIDChanged(Object object,
String oldValue,
String newValue)
This method calls the
propertyChanged
method of all the property change listeners, with
the property name SDMPropertyChangeEvent.OBJECT_ID . |
void |
fireLinkDestinationChanged(Object object)
This method calls the
linkDestinationChanged
method of all the model listeners. |
void |
fireLinkSourceChanged(Object object)
This method calls the
linkSourceChanged
method of all the model listeners. |
void |
fireObjectAdded(Object object)
This method calls the
objectAdded
method of all the model listeners. |
void |
fireObjectRemoved(Object object)
This method calls the
objectRemoved
method of all the model listeners. |
void |
firePropertyChanged(Object object,
String[] propertyNames,
Object[] oldValues,
Object[] newValues)
This method calls the
propertyChanged
method of all the property change listeners. |
void |
firePropertyChanged(Object object,
String propertyName,
Object oldValue,
Object newValue)
This method calls the
propertyChanged
method of all the property change listeners. |
Enumeration |
getChildren(Object parent)
This method returns
null . |
Object |
getFrom(Object link)
This method returns
null . |
String |
getID(Object obj)
Returns the identifier of the object.
|
protected String |
getIDImpl(Object obj)
This method must be overridden by subclasses to actually
get the ID of an object.
|
Object |
getObject(String id)
Returns the object of the model whose identifier is
id . |
Object |
getParent(Object object)
This method returns
null . |
Object |
getTo(Object link)
This method returns
null . |
boolean |
isAdjusting()
Returns the last value passed to
setAdjusting(boolean) . |
boolean |
isEditable()
Returns
false to indicate that this
model cannot be edited. |
boolean |
isLink(Object obj)
This method returns
false . |
void |
removeObject(Object object)
This method does nothing since this model is not editable.
|
void |
removeSDMModelListener(SDMModelListener listener)
Removes a listener from this SDM model.
|
void |
removeSDMPropertyChangeListener(SDMPropertyChangeListener listener)
Removes a property change listener from this SDM model.
|
void |
setAdjusting(boolean adjusting)
This method sets the flag indicating
that subsequent calls to the editing methods should
be treated as a single modification.
|
void |
setFrom(Object link,
Object node)
This method returns
null since this model is not editable. |
void |
setID(Object obj,
String id)
Sets the identifier of an object.
|
protected void |
setIDImpl(Object obj,
String id)
This method must be overridden by subclasses to actually
set the ID of an object.
|
void |
setObjectProperty(Object object,
String property,
Object value)
This method does nothing since this model is not editable.
|
void |
setTo(Object link,
Object node)
This method returns
null since this model is not editable. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, getObjectProperty, getObjectPropertyNames, getObjects, getTag
public Enumeration getChildren(Object parent)
null
.getChildren
in interface IlvSDMModel
parent
- The parent object.null
.public Object getParent(Object object)
null
.getParent
in interface IlvSDMModel
object
- The child object.null
.public boolean isLink(Object obj)
false
.isLink
in interface IlvSDMModel
obj
- The object whose type is queried.false
.public Object getFrom(Object link)
null
.getFrom
in interface IlvSDMModel
link
- The link whose source node is queried.null
.public Object getTo(Object link)
null
.getTo
in interface IlvSDMModel
link
- The link whose destination node is queried.null
.public Object getObject(String id)
id
.
This basic implementation traverses the whole model and looks for the object with the specified ID. Subclasses can override this method to provide a faster implementation.
getObject
in interface IlvSDMModel
id
- The identifier of the requested object.id
.public String getID(Object obj)
This implementation calls the protected
method getIDImpl(java.lang.Object)
, which must be redefined
by subclasses to actually get the object ID.
If no ID has been assigned to the object yet,
this method allocates a new, unused ID by
calling allocID(java.lang.String)
, using the object tag
as prefix.
In general, subclasses should not redefine this method,
but rather the getIDImpl(java.lang.Object)
method, to ensure that
IDs are allocated to objects as needed.
getID
in interface IlvSDMModel
obj
- The object whose identifier is requested.String
that identifies the object in a unique way.protected String getIDImpl(Object obj)
obj
- The object whose identifier is requested.getID(java.lang.Object)
public void setID(Object obj, String id)
This implementation verifies that the identifier
is not already in use. If the identifier is in use, a new
identifier is automatically allocated. Finally,
the identifier is actually set by calling
the protected method getIDImpl(java.lang.Object)
.
In general, subclasses should not redefine this method,
but rather the setIDImpl(java.lang.Object, java.lang.String)
method, to ensure that
IDs are allocated to objects in a unique manner.
setID
in interface IlvSDMModel
obj
- The object whose identifier is to be changed.id
- The new identifier.protected void setIDImpl(Object obj, String id)
obj
- The object whose identifier is to be set.id
- The new identifier.setID(java.lang.Object, java.lang.String)
public String allocID(String prefix)
prefix
n.prefix
- A String
used as a prefix for creating
the new ID.public boolean isEditable()
false
to indicate that this
model cannot be edited.isEditable
in interface IlvSDMModel
public void addObject(Object object, Object parent, Object before)
addObjectImpl(java.lang.Object, java.lang.Object, java.lang.Object)
to actually add the object
to the model.
In general, subclasses should not redefine this method,
but rather the addObjectImpl(java.lang.Object, java.lang.Object, java.lang.Object)
method, to ensure that
IDs are allocated to objects in a unique manner.
addObject
in interface IlvSDMModel
object
- The new object to add to the model.parent
- The parent if the new object must be added
to a submodel, or null
if the new object
is a top-level object.before
- An existing object of the model before which
the new object must be inserted. You can pass null
to append the new object at the end of the model.protected void addObjectImpl(Object object, Object parent, Object before)
object
- The new object to add to the model.parent
- The parent if the new object must be added
to a submodel, or null
if the new object
is a top-level object.before
- An existing object of the model before which
the new object must be inserted. You can pass null
to append the new object at the end of the model.public void removeObject(Object object)
removeObject
in interface IlvSDMModel
object
- The object to remove.public void setObjectProperty(Object object, String property, Object value)
setObjectProperty
in interface IlvSDMModel
object
- The object whose property is to be set.property
- The name of the property to set.value
- The new value of the property.public Object createNode(String tag)
null
since this model is not editable.createNode
in interface IlvSDMModel
tag
- The tag of the new node.public Object createLink(String tag)
null
since this model is not editable.createLink
in interface IlvSDMModel
tag
- The tag of the new link.public void setFrom(Object link, Object node)
null
since this model is not editable.setFrom
in interface IlvSDMModel
link
- The link whose source node must be set.node
- The new source node of the link.public void setTo(Object link, Object node)
null
since this model is not editable.setTo
in interface IlvSDMModel
link
- The link whose destination node must be set.node
- The new destination node of the link.public void addSDMModelListener(SDMModelListener listener)
addSDMModelListener
in interface IlvSDMModel
listener
- The listener to add.public void removeSDMModelListener(SDMModelListener listener)
removeSDMModelListener
in interface IlvSDMModel
listener
- The listener to remove.public void addSDMPropertyChangeListener(SDMPropertyChangeListener listener)
addSDMPropertyChangeListener
in interface IlvSDMModel
listener
- The listener to add.public void removeSDMPropertyChangeListener(SDMPropertyChangeListener listener)
removeSDMPropertyChangeListener
in interface IlvSDMModel
listener
- The listener to remove.public void setAdjusting(boolean adjusting)
setAdjusting
in interface IlvSDMModel
adjusting
- The value of the flag.public boolean isAdjusting()
setAdjusting(boolean)
.isAdjusting
in interface IlvSDMModel
public void fireObjectAdded(Object object)
objectAdded
method of all the model listeners.object
- The application object
that has been added.public void fireObjectRemoved(Object object)
objectRemoved
method of all the model listeners.object
- The object
that has been removed.public void fireLinkSourceChanged(Object object)
linkSourceChanged
method of all the model listeners.object
- The link whose source node has been changed.public void fireLinkDestinationChanged(Object object)
linkDestinationChanged
method of all the model listeners.object
- The link whose destination node has been changed.public void fireDataChanged(Object root)
dataChanged
method of all the model listeners.root
- If the modified SDM model is a submodel,
this parameter is the root of the
submodel. If the
modified SDM model is not a submodel, this parameter is
null
.public void fireAdjustmentFinished()
adjustmentFinished
method of all the model listeners.public void firePropertyChanged(Object object, String propertyName, Object oldValue, Object newValue)
propertyChanged
method of all the property change listeners.object
- The object
that has been modified.propertyName
- The name of the property that has been modified.oldValue
- The old value of the property.newValue
- The new value of the property.public void firePropertyChanged(Object object, String[] propertyNames, Object[] oldValues, Object[] newValues)
propertyChanged
method of all the property change listeners.object
- The object
that has been modified.propertyNames
- The name of the properties that have been modified.oldValues
- The old values of the properties.newValues
- The new values of the properties.public void fireIDChanged(Object object, String oldValue, String newValue)
propertyChanged
method of all the property change listeners, with
the property name SDMPropertyChangeEvent.OBJECT_ID
.object
- The object whose ID has been modified.oldValue
- The old ID of the object.newValue
- The new ID of the object.public boolean contains(Object object)
addObject(java.lang.Object, java.lang.Object, java.lang.Object)
and
not been removed from the model using removeObject(java.lang.Object)
.object
- The object that is tested.true
if the object is contained in this model,
false
otherwise.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.