ilog.views.sdm.model
Class IlvBasicSDMModel

java.lang.Object
  extended by ilog.views.sdm.model.IlvBasicSDMModel
All Implemented Interfaces:
IlvSDMModel, Serializable
Direct Known Subclasses:
IlvAbstractSDMModel, IlvFilterSDMModel, IlvJavaBeanSDMModel, IlvMultipleSDMModel

public abstract class IlvBasicSDMModel
extends Object
implements IlvSDMModel, Serializable

This class is a basic implementation of the 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:

Since:
JViews 4.0
See Also:
Serialized Form

Constructor Summary
IlvBasicSDMModel()
          Creates a new basic SDM model.
 
Method Summary
 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 prefixn.
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ilog.views.sdm.IlvSDMModel
clear, getObjectProperty, getObjectPropertyNames, getObjects, getTag
 

Constructor Detail

IlvBasicSDMModel

public IlvBasicSDMModel()
Creates a new basic SDM model.

Method Detail

getChildren

public Enumeration getChildren(Object parent)
This method returns null.

Specified by:
getChildren in interface IlvSDMModel
Parameters:
parent - The parent object.
Returns:
null.

getParent

public Object getParent(Object object)
This method returns null.

Specified by:
getParent in interface IlvSDMModel
Parameters:
object - The child object.
Returns:
null.

isLink

public boolean isLink(Object obj)
This method returns false.

Specified by:
isLink in interface IlvSDMModel
Parameters:
obj - The object whose type is queried.
Returns:
false.

getFrom

public Object getFrom(Object link)
This method returns null.

Specified by:
getFrom in interface IlvSDMModel
Parameters:
link - The link whose source node is queried.
Returns:
null.

getTo

public Object getTo(Object link)
This method returns null.

Specified by:
getTo in interface IlvSDMModel
Parameters:
link - The link whose destination node is queried.
Returns:
null.

getObject

public Object getObject(String id)
Returns the object of the model whose identifier is 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.

Specified by:
getObject in interface IlvSDMModel
Parameters:
id - The identifier of the requested object.
Returns:
The object whose identifier is id.

getID

public String getID(Object obj)
Returns the identifier of the object.

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.

Specified by:
getID in interface IlvSDMModel
Parameters:
obj - The object whose identifier is requested.
Returns:
A String that identifies the object in a unique way.

getIDImpl

protected String getIDImpl(Object obj)
This method must be overridden by subclasses to actually get the ID of an object.

Parameters:
obj - The object whose identifier is requested.
See Also:
getID(java.lang.Object)

setID

public void setID(Object obj,
                  String id)
Sets the identifier of an object.

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.

Specified by:
setID in interface IlvSDMModel
Parameters:
obj - The object whose identifier is to be changed.
id - The new identifier.

setIDImpl

protected void setIDImpl(Object obj,
                         String id)
This method must be overridden by subclasses to actually set the ID of an object.

Parameters:
obj - The object whose identifier is to be set.
id - The new identifier.
See Also:
setID(java.lang.Object, java.lang.String)

allocID

public String allocID(String prefix)
Allocates a new, unused ID of the form prefixn.

Parameters:
prefix - A String used as a prefix for creating the new ID.

isEditable

public boolean isEditable()
Returns false to indicate that this model cannot be edited.

Specified by:
isEditable in interface IlvSDMModel

addObject

public 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.

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.

Specified by:
addObject in interface IlvSDMModel
Parameters:
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.

addObjectImpl

protected void addObjectImpl(Object object,
                             Object parent,
                             Object before)
This method does nothing since this model is not editable.

Parameters:
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.

removeObject

public void removeObject(Object object)
This method does nothing since this model is not editable.

Specified by:
removeObject in interface IlvSDMModel
Parameters:
object - The object to remove.

setObjectProperty

public void setObjectProperty(Object object,
                              String property,
                              Object value)
This method does nothing since this model is not editable.

Specified by:
setObjectProperty in interface IlvSDMModel
Parameters:
object - The object whose property is to be set.
property - The name of the property to set.
value - The new value of the property.

createNode

public Object createNode(String tag)
This method returns null since this model is not editable.

Specified by:
createNode in interface IlvSDMModel
Parameters:
tag - The tag of the new node.

createLink

public Object createLink(String tag)
This method returns null since this model is not editable.

Specified by:
createLink in interface IlvSDMModel
Parameters:
tag - The tag of the new link.

setFrom

public void setFrom(Object link,
                    Object node)
This method returns null since this model is not editable.

Specified by:
setFrom in interface IlvSDMModel
Parameters:
link - The link whose source node must be set.
node - The new source node of the link.

setTo

public void setTo(Object link,
                  Object node)
This method returns null since this model is not editable.

Specified by:
setTo in interface IlvSDMModel
Parameters:
link - The link whose destination node must be set.
node - The new destination node of the link.

addSDMModelListener

public void addSDMModelListener(SDMModelListener listener)
Adds a listener to this SDM model. The listener is stored in a list.

Specified by:
addSDMModelListener in interface IlvSDMModel
Parameters:
listener - The listener to add.

removeSDMModelListener

public void removeSDMModelListener(SDMModelListener listener)
Removes a listener from this SDM model. The listener is stored in a list.

Specified by:
removeSDMModelListener in interface IlvSDMModel
Parameters:
listener - The listener to remove.

addSDMPropertyChangeListener

public void addSDMPropertyChangeListener(SDMPropertyChangeListener listener)
Adds a property change listener to this SDM model. The listener is stored in a list.

Specified by:
addSDMPropertyChangeListener in interface IlvSDMModel
Parameters:
listener - The listener to add.

removeSDMPropertyChangeListener

public void removeSDMPropertyChangeListener(SDMPropertyChangeListener listener)
Removes a property change listener from this SDM model. The listener is stored in a list.

Specified by:
removeSDMPropertyChangeListener in interface IlvSDMModel
Parameters:
listener - The listener to remove.

setAdjusting

public void setAdjusting(boolean adjusting)
This method sets the flag indicating that subsequent calls to the editing methods should be treated as a single modification.

Specified by:
setAdjusting in interface IlvSDMModel
Parameters:
adjusting - The value of the flag.

isAdjusting

public boolean isAdjusting()
Returns the last value passed to setAdjusting(boolean).

Specified by:
isAdjusting in interface IlvSDMModel

fireObjectAdded

public void fireObjectAdded(Object object)
This method calls the objectAdded method of all the model listeners.

Parameters:
object - The application object that has been added.

fireObjectRemoved

public void fireObjectRemoved(Object object)
This method calls the objectRemoved method of all the model listeners.

Parameters:
object - The object that has been removed.

fireLinkSourceChanged

public void fireLinkSourceChanged(Object object)
This method calls the linkSourceChanged method of all the model listeners.

Parameters:
object - The link whose source node has been changed.

fireLinkDestinationChanged

public void fireLinkDestinationChanged(Object object)
This method calls the linkDestinationChanged method of all the model listeners.

Parameters:
object - The link whose destination node has been changed.

fireDataChanged

public void fireDataChanged(Object root)
This method calls the dataChanged method of all the model listeners.

Parameters:
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.

fireAdjustmentFinished

public void fireAdjustmentFinished()
This method calls the adjustmentFinished method of all the model listeners.


firePropertyChanged

public void firePropertyChanged(Object object,
                                String propertyName,
                                Object oldValue,
                                Object newValue)
This method calls the propertyChanged method of all the property change listeners.

Parameters:
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.

fireIDChanged

public 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.

Parameters:
object - The object whose ID has been modified.
oldValue - The old ID of the object.
newValue - The new ID of the object.

contains

public 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).

Parameters:
object - The object that is tested.
Returns:
true if the object is contained in this model, false otherwise.
Since:
JViews 6.0


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.