ilog.views.sdm.model
Class IlvAbstractSDMModel

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

public abstract class IlvAbstractSDMModel
extends IlvBasicSDMModel

The class 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:

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

Since:
JViews 4.0
See Also:
IlvSDMNode, IlvSDMLink, IlvMutableSDMNode, IlvMutableSDMLink, IlvDefaultSDMNode, IlvDefaultSDMLink, Serialized Form

Constructor Summary
IlvAbstractSDMModel()
          Creates a new, empty SDM model.
 
Method Summary
 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.
 
Methods inherited from class ilog.views.sdm.model.IlvBasicSDMModel
addObject, addObjectImpl, addSDMModelListener, addSDMPropertyChangeListener, allocID, contains, fireAdjustmentFinished, fireDataChanged, fireIDChanged, fireLinkDestinationChanged, fireLinkSourceChanged, fireObjectAdded, fireObjectRemoved, firePropertyChanged, getID, getObject, isAdjusting, removeObject, removeSDMModelListener, removeSDMPropertyChangeListener, setAdjusting, setID
 
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, getObjects
 

Constructor Detail

IlvAbstractSDMModel

public IlvAbstractSDMModel()
Creates a new, empty SDM model. The SDM must be populated by calling the addObject method.

Method Detail

getChildren

public Enumeration getChildren(Object parent)
Returns the children of the specified data object.

Specified by:
getChildren in interface IlvSDMModel
Overrides:
getChildren in class IlvBasicSDMModel
Parameters:
parent - The parent of the children in the specified data object.
Returns:
An enumeration of IlvSDMNodes.

getParent

public Object getParent(Object obj)
Returns the parent of an object, or null if the object has no parent.

Specified by:
getParent in interface IlvSDMModel
Overrides:
getParent in class IlvBasicSDMModel
Parameters:
obj - The object whose parent is queried.
Returns:
null.

isLink

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

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

getFrom

public Object getFrom(Object link)
Returns the node that is the source of the specified link.

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

getTo

public Object getTo(Object link)
Returns the node that is the destination of the specified link.

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

getIDImpl

protected String getIDImpl(Object obj)
Returns the identifier of the object.

Overrides:
getIDImpl in class IlvBasicSDMModel
Parameters:
obj - The object whose identifier is requested.
Returns:
A String that identifies the object in a unique way.
See Also:
IlvBasicSDMModel.getID(java.lang.Object)

setIDImpl

protected void setIDImpl(Object obj,
                         String id)
Sets the identifier of an object.

Overrides:
setIDImpl in class IlvBasicSDMModel
Parameters:
obj - The object whose identifier is to be changed.
id - The new identifier.
See Also:
IlvBasicSDMModel.setID(java.lang.Object, java.lang.String)

getTag

public String getTag(Object obj)
Returns the symbolic type (the "tag") of an object.

Parameters:
obj - The object whose tag is requested.
Returns:
A String that identifies the symbolic type of the object.

getObjectProperty

public Object getObjectProperty(Object object,
                                String property)
Returns a property of an object.

Parameters:
object - The object whose property is to be set.
property - The property name.
Returns:
An Object representing the value of the specified property, or null if the property has not been set.

setObjectProperty

public void setObjectProperty(Object object,
                              String property,
                              Object value)
Sets a property of an object and fires a propertyChanged event.

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

getObjectPropertyNames

public String[] getObjectPropertyNames(Object obj)
Returns the names of all the properties of an object.

Parameters:
obj - The object whose property names are queried.

createNode

public Object createNode(String tag)
Creates a new instance of IlvDefaultSDMNode.

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

createLink

public Object createLink(String tag)
Creates a new instance of IlvDefaultSDMLink.

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

setFrom

public void setFrom(Object link,
                    Object node)
Sets the source node of the specified link.

Specified by:
setFrom in interface IlvSDMModel
Overrides:
setFrom in class IlvBasicSDMModel
Parameters:
link - The link whose source node is to be set.
node - The new source node of the link.

setTo

public void setTo(Object link,
                  Object node)
Sets the destination node of the specified link.

Specified by:
setTo in interface IlvSDMModel
Overrides:
setTo in class IlvBasicSDMModel
Parameters:
link - The link whose destination node is to be set.
node - The new destination node of the link.

isEditable

public boolean isEditable()
Returns the property that indicates whether this model can be edited.

Specified by:
isEditable in interface IlvSDMModel
Overrides:
isEditable in class IlvBasicSDMModel
See Also:
setEditable(boolean)

setEditable

public void setEditable(boolean editable)
Sets the property that indicates whether this model can be edited.

Parameters:
editable - The new value of the "editable" property.
See Also:
isEditable()


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