org.eclipse.actf.model
Class AbstractModel

java.lang.Object
  extended by org.eclipse.actf.model.AbstractModel
All Implemented Interfaces:
IModel
Direct Known Subclasses:
AbstractRenderableModel, DomModel

public abstract class AbstractModel
extends Object
implements IModel

provides basic services for any model instance. Note that the IRenderableModel interface must be implemented as well by clients that wish to validate structures via validation documents using the ACTF Engine.

Author:
Mike Squillace
See Also:
IRenderableModel

Field Summary
protected  String baseType
           
protected  IConfiguration configuration
           
protected  INodeLocator locator
           
protected  Properties nodeToTypeNameMap
           
protected  IRuntimeContext runtimeContext
           
protected  ITreeNodeWalker treeNodeWalker
           
 
Constructor Summary
AbstractModel(String type)
          create a new model
 
Method Summary
 void addModelChangeListener(IModelChangeListener listener)
          adds a listener to receive notifications when this model's structure or properties of its nodes are changed
protected  void fireModelChangeEvent(ModelChangeEvent mce)
          fire a ModelChangeEvent notification for this model
 String getBaseType()
           
 String getDefaultAliasPrefix()
          returns the default alias prefix.
 String getName()
          return the type of the model.
 String getNodeId(Object element)
          default implementation returns the hexadecimal representation of System.identityHashCode of the given element.
 INodeLocator getNodeLocator()
          retrieves a locator for finding and identifying nodes in the model.
 String getNodeName(Object element)
          return the short name of this element. returns the qualified class name (i.e. without the package name) of the given element
 INodeWalker getNodeWalker()
          retrieve the NodeWalker for traversing elements in this model
 int getOrder(Object head)
          get the order of the graph-based model starting at the given head.
 String getTypeName(String nodeName)
          returns the type name associated with this nodeName. returns the original class name from which this node name was derived or, if unsuccessful, tries to form the correct class based on the package names associated with this implementation
 void removeModelChangeListener(IModelChangeListener listener)
          remove the given listener from the list of listeners to be notified when this model is updated
protected  void setFilters()
           
protected  void setModelType(String type)
           
 void setNodeID(Object comp, String id)
          set the id for a component in the model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.actf.model.IModel
getPackageNames
 

Field Detail

configuration

protected IConfiguration configuration

runtimeContext

protected IRuntimeContext runtimeContext

locator

protected INodeLocator locator

treeNodeWalker

protected ITreeNodeWalker treeNodeWalker

baseType

protected String baseType

nodeToTypeNameMap

protected Properties nodeToTypeNameMap
Constructor Detail

AbstractModel

public AbstractModel(String type)
create a new model

Parameters:
type - - type of model
Method Detail

getName

public String getName()
return the type of the model. This may be one of the pre-defined constants in org.eclipse.actf.core.config.Configuration.

Specified by:
getName in interface IModel
Returns:
name of model implemented by this model class
See Also:
IConfiguration

setModelType

protected void setModelType(String type)

setNodeID

public void setNodeID(Object comp,
                      String id)
set the id for a component in the model

Specified by:
setNodeID in interface IModel
Parameters:
comp - - component for which id is to be set
id - - id for component

getNodeId

public String getNodeId(Object element)
default implementation returns the hexadecimal representation of System.identityHashCode of the given element.

Specified by:
getNodeId in interface IModel
Parameters:
element - - element for which id is desired
Returns:
unique id of element
See Also:
System.identityHashCode(Object)

getNodeName

public String getNodeName(Object element)
return the short name of this element. The id for an element is model-specific. For example, it may be the tag name of an element of a model representing a structure that conforms to W3the C DOM specification or the simple class name of the object. returns the qualified class name (i.e. without the package name) of the given element

Specified by:
getNodeName in interface IModel
Parameters:
element - - element for which name is desired
Returns:
name of element or null if not available

getTypeName

public String getTypeName(String nodeName)
returns the type name associated with this nodeName. The nodeName parameter is most frequently formed by calling getNodeName. The name returned identifies the type that is represented by this node name in the graph.

If the specified nodeName was not obtained from getNodeName, then implementers should make a rough guess regarding the underlying type on the basis of the package names associated with this model via getPackageNames.

returns the original class name from which this node name was derived or, if unsuccessful, tries to form the correct class based on the package names associated with this implementation

Specified by:
getTypeName in interface IModel
Parameters:
nodeName - - as returned by getNodeName
Returns:
type name for the node name specified
See Also:
#getNodeName(Object)Object), IModel.getPackageNames()

getDefaultAliasPrefix

public String getDefaultAliasPrefix()
returns the default alias prefix. The default alias prefix (usually a package name) is used when a fully-qualified name is not used in the 'value' attribute of an <alias> tag

Specified by:
getDefaultAliasPrefix in interface IModel
Returns:
alias prefix (not including trailing '.')

getNodeWalker

public INodeWalker getNodeWalker()
retrieve the NodeWalker for traversing elements in this model

Specified by:
getNodeWalker in interface IModel
Returns:
walker for traversing nodes in this model or null if no walker is available

getNodeLocator

public INodeLocator getNodeLocator()
retrieves a locator for finding and identifying nodes in the model. The locator can provide an XPath expression that describes a node in the model or, given a valid XPath expression, find an object in the model.

Specified by:
getNodeLocator in interface IModel
Returns:
node locator

addModelChangeListener

public void addModelChangeListener(IModelChangeListener listener)
adds a listener to receive notifications when this model's structure or properties of its nodes are changed

Specified by:
addModelChangeListener in interface IModel
Parameters:
listener - - listener to be notified of updates to the model

removeModelChangeListener

public void removeModelChangeListener(IModelChangeListener listener)
remove the given listener from the list of listeners to be notified when this model is updated

Specified by:
removeModelChangeListener in interface IModel
Parameters:
listener - - listener to be removed

fireModelChangeEvent

protected void fireModelChangeEvent(ModelChangeEvent mce)
fire a ModelChangeEvent notification for this model

Parameters:
mce - the ModelChangeEvent The method triggered will vary depending on the event type: NODE_INSERTED, NODE_REMOVED, NODE_MODIFIED

setFilters

protected void setFilters()

getBaseType

public String getBaseType()
Specified by:
getBaseType in interface IModel

getOrder

public int getOrder(Object head)
Description copied from interface: IModel
get the order of the graph-based model starting at the given head. The order of a graph is the number of verticies or nodes that comprise it.

Specified by:
getOrder in interface IModel
Returns:
order of the subgraph