IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.patterns.framework
Class AbstractPatternDefinition

java.lang.Object
  extended bycom.ibm.xtools.patterns.framework.AbstractPatternElement
      extended bycom.ibm.xtools.patterns.framework.AbstractPatternDefinition
All Implemented Interfaces:
Comparable, IPatternDescriptor, ITransformationDescriptor, ITransformationItem, Visitable
Direct Known Subclasses:
AbstractPatternDefinition

public abstract class AbstractPatternDefinition
extends com.ibm.xtools.patterns.framework.AbstractPatternElement
implements IPatternDescriptor, Visitable

This is the base abstract pattern definition class. A pattern definition represents a pattern and provides an abstraction in the framework that can be used to determine information about a pattern. If a pattern is statically-defined is will have a descriptor found in the pattern library's plugin.xml file that conforms to the pattern providers XML schema. Whether a pattern is statically-defined or dynamically-defined the abstract pattern definition class will behave and look the same to the client. Client in this context means anything that holds on to an abstract pattern definition type. The actual pattern descriptor instance as defined by the pattern service is referenced by this class as an instance variable. For patterns that are statically-defined, the descriptor is served-up by the pattern service implementation and the pattern definition specializing class need only use the superclass constructor with the minimal parameters needed to associate the implementation with the descriptor. For patterns that are dyanamically-defined, the descriptor is created using the information supplied to the abstract pattern definition in its constructor by subclasses. There are currently two strategies for implementing pattern descriptors, one strategy is implemented by the pattern service and the other strategy is implemented within the framework, within this class's descriptor member class. The intent of this class is to provide a base class for concrete pattern definitions to extend. There are also other classes that extend from this class that might provide more appropriate base classes for defining concrete pattern definitions. For example, there is an abstract pattern definition class that is UML2-specific that is part of the framework and there might be other classes that extend from this class specializing the base pattern definition for another specific metamodel or purpose. The typical scenario would be that a pattern implementation would subclass this class or another closely-related subclass of this class and then implement the proper constructor which invokes the superclass constructor appropriately depending on whether the pattern definition is statically or dynamically-defined. One optional hot-spot that can be overridden in this class is the factory method for creating pattern instances for this particular pattern definition. By default, a general pattern instance class is used to create a pattern instance for this pattern definition. This general pattern instance implementation is most appropriate for pattern definitions that define pattern parameters since the pattern's execution behavior is primarily directed by its parameters in this case. Another optional hot-spot that can be overridden in this class is the is valid method that determines if a pattern instantiation of this pattern definition type can occur given a certain context.

See Also:
createPatternInstance(Object, AbstractPatternResult, MultiStatus), reconstitutePatternInstance(AbstractPatternDefinition, Object), isValid(org.eclipse.emf.ecore.EObject), AbstractPatternInstance, AbstractPatternDefinition, IPatternDescriptor

Field Summary
 
Fields inherited from interface com.ibm.xtools.patterns.core.IPatternDescriptor
DIAGRAM, DIAGRAM_DELIMITERS, DOCUMENTATION, MANIFEST, MODEL, OVERVIEW_DIAGRAM, PLUGIN_NAME, PLUGIN_URL, TARGET_TYPE, TARGET_TYPE_DELIMITERS, TEMPLATE, TYPE
 
Fields inherited from interface com.ibm.xtools.transform.core.ITransformationDescriptor
AUTHOR, DESCRIPTION, DOCUMENT, EXTENSIBLE, GROUP_PATH, GROUP_PATH_DELIMITERS, ICON, ID, KEYWORDS, KEYWORDS_DELIMITERS, NAME, PROFILES, PROFILES_DELIMITERS, PROVIDER, PUBLIC, SOURCE_MODEL_TYPE, SOURCE_MODEL_TYPE_DELIMITERS, TARGET_MODEL_TYPE, TARGET_MODEL_TYPE_DELIMITERS, TRANSFORM_GUI, VERSION
 
Constructor Summary
protected AbstractPatternDefinition(PatternIdentity identity)
          Constructs an abstract pattern definition given only a pattern identity.
 
Method Summary
 void accept(Visitor visitor)
          Enable visitation of this entity.
 int compareTo(Object object)
           
protected  AbstractPatternInstance createPatternInstance(Object targetObject, AbstractPatternResult results, MultiStatus status)
          A method that is called when a new pattern instance is requested to be created.
 boolean equals(Object object)
           
 IAdaptable getAdaptableProperty(String propertyId)
          Returns the property with the given property id that is implemented as an adaptable object.
 String[] getAssignedGroups()
          Returns the string paths of groups to which the pattern represented by this pattern descriptor is assigned.
 IPatternMetatype[] getContainerTypes()
          Returns the types of elements that are valid containers for an instance of the pattern represented by this pattern descriptor.
 String getDescription()
          Retrieve the localized description of the transformation item.
 String getId()
          Retrieve the unique id of the transformation item.
 IPatternIdentity getIdentity()
          Returns the composite identity of the pattern represented by this pattern descriptor.
 String[] getKeywords()
          Returns the keywords associated with the pattern represented by this pattern descriptor.
 String getName()
          Retrieve the localized name of the transformation item.
 IParameterDescriptor[] getParameters()
          Returns the parameters for the pattern represented by this pattern descriptor.
 ITransformationProperty[] getProperties()
          Return all defined properties associated with this transformation.
 ITransformationProperty getProperty(String propertyId)
          Return the specified property associated with this transformation.
 String[] getPropertyIds()
          List the identifers of properties associated with this transformation.
 IPatternMetatype[] getTargetTypes()
          Returns the types of elements that are valid targets for an instance of the pattern represented by this pattern descriptor.
 IPatternMetatype getType()
          Returns the type of element to which an instance of the pattern represented by this pattern descriptor will be bound.
 String getVersion()
          Returns the version of the pattern represented by this pattern descriptor.
 int hashCode()
           
protected  void initialize()
          A hot-spot method that supportspattern definition specific initialization.
 void initializeInstance(AbstractPatternInstance instance)
          A hot-spot method that supports pattern definition specific initialization of pattern instances.
 boolean isGroupMember(String groupPathString)
          Determines whether the pattern represented by this pattern descriptor is assigned to the group designated by the given group path string.
 boolean isPublic()
          Return true if the transformation is public (visible in UI).
protected  boolean isValid(EObject targetElement)
          Determines if a given target element can be used as the context for instantiating a new pattern instance.
 boolean isValidInstanceTarget(Object targetObject)
          This method determines if a given target object or context is valid for the instantiation of this pattern definition.
protected  AbstractPatternInstance reconstitutePatternInstance(AbstractPatternDefinition owingPatternDefinition, Object representation)
          Reconstitute a pattern instance given a context and a return status object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPatternDefinition

protected AbstractPatternDefinition(PatternIdentity identity)
Constructs an abstract pattern definition given only a pattern identity. The pattern identity will be used to hook up the pattern descriptor with this abstract pattern definition. This constructor is used for statically described patterns rather than dynamically described patterns. Dynamically described patterns would use the constructor that takes the additional information that describes that particular pattern.

Parameters:
identity - the identity of the pattern, used to associate descriptor with this instance of a pattern definition
Method Detail

accept

public void accept(Visitor visitor)
Enable visitation of this entity.

Specified by:
accept in interface Visitable

compareTo

public int compareTo(Object object)
Specified by:
compareTo in interface Comparable

createPatternInstance

protected AbstractPatternInstance createPatternInstance(Object targetObject,
                                                        AbstractPatternResult results,
                                                        MultiStatus status)
A method that is called when a new pattern instance is requested to be created. This is a factory method and can be overridden in subclasses, the default behavior is to create a default instance.

Parameters:
targetObject - the target object or context of the instantiation
results - any additional model elements that are created are returned here, this is an out parameter
Returns:
the new abstract pattern instance is returned

equals

public boolean equals(Object object)

getAdaptableProperty

public IAdaptable getAdaptableProperty(String propertyId)
Description copied from interface: IPatternDescriptor
Returns the property with the given property id that is implemented as an adaptable object.

Specified by:
getAdaptableProperty in interface IPatternDescriptor
Returns:
Returns the adaptable object with the given property id associated with the pattern.

getAssignedGroups

public String[] getAssignedGroups()
Description copied from interface: IPatternDescriptor
Returns the string paths of groups to which the pattern represented by this pattern descriptor is assigned.

Specified by:
getAssignedGroups in interface IPatternDescriptor
Returns:
Returns the string paths of the groups to which the pattern is assigned.

getContainerTypes

public IPatternMetatype[] getContainerTypes()
Description copied from interface: IPatternDescriptor
Returns the types of elements that are valid containers for an instance of the pattern represented by this pattern descriptor.

Specified by:
getContainerTypes in interface IPatternDescriptor
Returns:
Returns the types of elements that are the containers for an instance of the pattern.

getDescription

public String getDescription()
Description copied from interface: ITransformationItem
Retrieve the localized description of the transformation item.

Specified by:
getDescription in interface ITransformationItem
Returns:
String - the localized description for the transformation item.

getId

public String getId()
Description copied from interface: ITransformationItem
Retrieve the unique id of the transformation item.

Specified by:
getId in interface ITransformationItem
Returns:
String - the unique identifier for the transformation item

getIdentity

public IPatternIdentity getIdentity()
Description copied from interface: IPatternDescriptor
Returns the composite identity of the pattern represented by this pattern descriptor.

Specified by:
getIdentity in interface IPatternDescriptor
Returns:
Returns the identity of the pattern.

getKeywords

public String[] getKeywords()
Description copied from interface: IPatternDescriptor
Returns the keywords associated with the pattern represented by this pattern descriptor.

Specified by:
getKeywords in interface IPatternDescriptor
Returns:
Returns the keywords associated with the pattern.

getName

public String getName()
Description copied from interface: ITransformationItem
Retrieve the localized name of the transformation item.

Specified by:
getName in interface ITransformationItem
Returns:
String - the localized name for the transformation item.

getParameters

public IParameterDescriptor[] getParameters()
Description copied from interface: IPatternDescriptor
Returns the parameters for the pattern represented by this pattern descriptor.

Specified by:
getParameters in interface IPatternDescriptor
Returns:
Returns the parameters for the pattern.

getProperties

public ITransformationProperty[] getProperties()
Description copied from interface: ITransformationDescriptor
Return all defined properties associated with this transformation. This method returns all of the static properties defined for this transformation, including readonly properties. Properties defined in a transform context (@link ITransformContext) are not returned by this method. Each associated property defines the default value, which cannot be changed. However the values for non-readonly properties can be overridden in the transform context.

Specified by:
getProperties in interface ITransformationDescriptor
Returns:
TransformationProperty[] - an array of defined properties

getProperty

public ITransformationProperty getProperty(String propertyId)
Description copied from interface: ITransformationDescriptor
Return the specified property associated with this transformation. If the property is not defeind for this transformation, null is returned.

Specified by:
getProperty in interface ITransformationDescriptor
Parameters:
propertyId - the identifier of the property
Returns:
ITransformationProperty - the property, if defined

getPropertyIds

public String[] getPropertyIds()
Description copied from interface: ITransformationDescriptor
List the identifers of properties associated with this transformation. This list contains only those properties that have been defined and does not include any new properties defined in a transform context (@link ITransformContext).

Specified by:
getPropertyIds in interface ITransformationDescriptor
Returns:
String[] - the identifiers of associated properties

getTargetTypes

public IPatternMetatype[] getTargetTypes()
Description copied from interface: IPatternDescriptor
Returns the types of elements that are valid targets for an instance of the pattern represented by this pattern descriptor.

Specified by:
getTargetTypes in interface IPatternDescriptor
Returns:
Returns the types of elements that are targets for an instance of the pattern.

getType

public IPatternMetatype getType()
Description copied from interface: IPatternDescriptor
Returns the type of element to which an instance of the pattern represented by this pattern descriptor will be bound.

Specified by:
getType in interface IPatternDescriptor
Returns:
Returns the type to which an instance the pattern will be bound.

getVersion

public String getVersion()
Description copied from interface: IPatternDescriptor
Returns the version of the pattern represented by this pattern descriptor.

Specified by:
getVersion in interface IPatternDescriptor
Returns:
Returns the version of the pattern.

hashCode

public int hashCode()

initialize

protected void initialize()
A hot-spot method that supportspattern definition specific initialization. The default implementation is empty. It is recommended that all custom pattern definition constructor code be put in the pattern definition initialize method rather than in the constructor. This method will be invoked after a pattern library has been initialized.


initializeInstance

public void initializeInstance(AbstractPatternInstance instance)
A hot-spot method that supports pattern definition specific initialization of pattern instances. This method is invoked from the constructor of a pattern instance. The default implementation is to invoke the initialize() method of the instance.


isGroupMember

public boolean isGroupMember(String groupPathString)
Description copied from interface: IPatternDescriptor
Determines whether the pattern represented by this pattern descriptor is assigned to the group designated by the given group path string.

Specified by:
isGroupMember in interface IPatternDescriptor
Parameters:
groupPathString - The string for the group path designating a group for which the pattern represented by this pattern descriptor will be tested for membership.
Returns:
Returns true if the pattern is a member of the group designated by the given group path string; otherwise, it returns false.

isPublic

public boolean isPublic()
Description copied from interface: ITransformationDescriptor
Return true if the transformation is public (visible in UI).

This is a convenience method for returning the value of the PUBLIC property.

Specified by:
isPublic in interface ITransformationDescriptor
Returns:
boolean - true for public transformations

isValid

protected boolean isValid(EObject targetElement)
Determines if a given target element can be used as the context for instantiating a new pattern instance. This method is invoked if the target element first passes the type checks as implemented by the is valid instance target method in this class. This method is a hot-spot that can be overridden by implementing pattern definitions. If any additional validation is needed on the target element before an a pattern instantiation is allowed to commence, this is the method to add the code.

Parameters:
targetElement - the target element to be checked for validity
Returns:
indicates whether this instance can be created using the given target element as the context
See Also:
isValid(EObject)

isValidInstanceTarget

public final boolean isValidInstanceTarget(Object targetObject)
This method determines if a given target object or context is valid for the instantiation of this pattern definition. Currently this involves checking the types stored in the target metatypes instance variable array. For example, a pattern might specify that it is legal for UML2 classes and UML2 packages to be the target object or context in a pattern instance creation.

Parameters:
targetObject - the target object to be checked, this must be an EObject
Returns:
indicates whether the target object is valid for an instantiation of this pattern
See Also:
isValid(EObject)

reconstitutePatternInstance

protected AbstractPatternInstance reconstitutePatternInstance(AbstractPatternDefinition owingPatternDefinition,
                                                              Object representation)
Reconstitute a pattern instance given a context and a return status object.

Parameters:
owingPatternDefinition - the governing pattern definition for this instance
representation - the persistent store representation of the pattern instance within the persistent store
Returns:
the framework core pattern instance that has been reconstituted

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.