|
IBM Rational Software Modeler Release 6.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.xtools.patterns.framework.AbstractPatternElement
com.ibm.xtools.patterns.framework.AbstractPatternParameter
This class is the common implementation for a pattern parameter and will typically be used indirectly through another subclass that further specializes this class. Everything that specifies a pattern parameter is encapsulated in this class. This class is abstract because it is meant to be extended with the run-time expansion methods being implemented. This class stores and manages dependencies from this parameter to another parameter. It also stores an OCL expression that can optionally be used to constrain the validity of a parameter value. The ordinal position of the parameter is also stored. By default, the order in which the parameters are instantiated determine the ordinal positions of the pattern parameters. The abstract pattern parameter is an important abstraction in the framework's design because it allows the run-time execution or expansion behavior be broken apart and encapsulated within the parameter performing the behavior. Instead of implementing all the pattern execution logic in the pattern definition or pattern instance, the responsibility for expansion is instead spread across the parameters that encapsulate how to behave appropriately. The parameter abstraction also allows concepts like parameter dependencies and parameter delegates to manifest cleanly in the design since these abstractions build on and collaborate with an abstract pattern parameter. The abstract pattern parameter also contains some member classes such as two strategies for validating pattern parameter values, a descriptor implementation for dynamically-defined patterns and an observerable adapter that allows this class to be observable even though the single superclass slot is already occupied. The strategy pattern is used for parameter value validation and the strategy is also used for descriptor-switching between statically-defined and dynamically-defined patterns (just like the abstract pattern definition class). The internal iteration idiom is used by supplying a consumer class for entities that consume abstract pattern parameters. A good amount of the differing code between patterns is on or around the abstract pattern parameter abstraction. The abstract pattern parameter is the primary abstraction at run-time forming the backbone for an expansion to take place through parameters, parameter dependencies and delegates. There are a handful of hot-spots that can be overridden within this class. It is expected that most pattern implementations will implement some or most of these hot-spots by overriding the hot-spot methods. The most frequently implemented hot-spots would be the expand and is valid methods. Hot-spot methods are available for resolving alternatively specified parameter values and determining validity of these alternatively specified parameter values.
initialize()
,
expand(PatternParameterValue)
,
expand(PatternParameterValue.Added)
,
expand(PatternParameterValue.Maintained)
,
expand(PatternParameterValue.Removed)
,
isValid(PatternParameterValue.Proposed)
,
isValid(PatternParameterValue.Unresolved)
,
isValid(PatternParameterValue.Unresolved,
PatternParameterValue.Unresolved.Directive)
,
validToAddArgument(PatternParameterValue.Proposed)
,
validToAddArgument(PatternParameterValue.Unresolved)
,
validToReplaceArgument(PatternParameterValue.Proposed)
,
validToReplaceArgument(PatternParameterValue.Unresolved)
,
resolve(PatternParameterValue.Unresolved)
,
resolve(PatternParameterValue.Unresolved,
PatternParameterValue.Unresolved.Directive)
,
validToCreateArguments(AbstractPatternInstance, IPatternMetatype)
,
create(AbstractPatternInstance, IPatternMetatype)
,
isScopeDerivable()
,
getDerivedScope(AbstractPatternInstance)
,
isRetrievable()
,
retrieve(AbstractPatternInstance, String)
,
isTypeSubstitutable()
,
getSubstituteType()
,
AbstractPatternDefinition
Field Summary |
Fields inherited from interface com.ibm.xtools.patterns.core.IParameterDescriptor |
BINDABLE |
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 | |
AbstractPatternParameter(AbstractPatternDefinition owningDefinition,
PatternParameterIdentity parameterIdentity)
Constructs a pattern parameter given only the parameter identity; the parameter descriptor offered by associated static pattern provider will then be attached to this parameter as the concrete descriptor state in this class. |
|
AbstractPatternParameter(AbstractPatternDefinition owningDefinition,
PatternParameterIdentity parameterIdentity,
String oclExpression)
Constructs a patterm parameter given only the parameter identity; the parameter descriptor offered by associated static pattern provider will then be attached to this parameter as the concrete descriptor state in this class. |
Method Summary | |
void |
accept(Visitor visitor)
Enable visitation of this entity. |
int |
compareTo(Object object)
|
protected abstract Object[] |
create(AbstractPatternInstance instance,
IPatternMetatype metatype)
If this parameter supports creation of prototypical instances then this method will be implemented. |
protected abstract Object[] |
create(AbstractPatternInstance instance,
IPatternMetatype metatype,
String scopeQualifiedName)
If this parameter supports creation of prototypical instances then this method will be implemented. |
Object[] |
createArgumentsUsingPairs(AbstractPatternInstance instance,
IPatternMetatype metatype,
AbstractParameterArgument.Pair[] pairs)
If this parameter supports creation of prototypical instances then this method will be implemented. |
boolean |
equals(Object object)
|
protected boolean |
expand(PatternParameterValue.Added value)
A hot-spot method that can be overridden in parameter subclasses. |
protected boolean |
expand(PatternParameterValue.Maintained value)
A hot-spot method that can be overridden in parameter subclasses. |
protected boolean |
expand(PatternParameterValue.Removed value)
A hot-spot method that can be overridden in parameter subclasses. |
protected boolean |
expand(PatternParameterValue.Replaced value)
A hot-spot method that can be overridden in parameter subclasses. |
protected boolean |
expand(PatternParameterValue value)
A hot-spot method that can be overridden in parameter subclasses. |
IPatternMetatype[] |
getAlternateTypes()
Retrieves the alternate types that are accepted for the arguments of the parameter represented by this descriptor. |
protected Object |
getDerivedScope(AbstractPatternInstance instance)
Retrieves the derived scope which in turn can be used to resolve parameter values and create parameter values within. |
String |
getDescription()
Retrieve the localized description of the transformation item. |
AbstractParameterArgument[] |
getFirstArgumentCandidates(AbstractPatternInstance instance,
IPatternMetatype metatype,
MultiStatus status)
|
String |
getId()
Retrieve the unique id of the transformation item. |
IMultiplicity |
getMultiplicity()
Retrieves the multiplicity of the parameter represented by this descriptor. |
String |
getName()
Retrieve the localized name of the transformation item. |
int |
getOrdinal()
Retrieves the ordinal of the parameter in the list of parameters for the pattern. |
AbstractPatternDefinition |
getOwningDefinition()
Returns the owning definition for this parameter. |
IPatternIdentity |
getPatternIdentity()
Retrieves the composite identity of the pattern that has the parameter represented by this 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. |
AbstractParameterArgument[] |
getSecondArgumentCandidates(AbstractPatternInstance instance,
IPatternMetatype metatype,
MultiStatus status)
|
AbstractParameterArgument[] |
getSecondArgumentCandidatesForFirstValue(AbstractPatternInstance instance,
IPatternMetatype metatype,
AbstractParameterArgument firstValue,
MultiStatus status)
|
protected EClass |
getSubstituteType()
This method takes the current type of this parameter and then potentially changes the type to a more concrete type if possible (if not concrete already). |
IPatternMetatype |
getType()
Retrieves the type of the parameter represented by this descriptor. |
Object |
getValue(AbstractPatternInstance instance)
For a given instance, return this value of this parameter, it assumes there is only one parameter value, this would be used as a convenience for parameters with a multiplicity of one. |
Object[] |
getValues(AbstractPatternInstance instance)
For a given instance, return the values of this parameter, this method works fine for parameter's of any multiplicity. |
int |
hashCode()
|
boolean |
hasValue(AbstractPatternInstance instance)
For a given instance, determine if the parameter has a value or values. |
boolean |
hasValues(AbstractPatternInstance instance)
For a given instance, determine if the parameter has a value or values bound. |
protected void |
initialize()
A hot-spot method that is defaulted with no implementation. |
boolean |
isBindable()
Retrieves whether the parameter represented by this descriptor is available for binding with an argument or arguments. |
boolean |
isPublic()
Return true if the transformation is public (visible in UI). |
protected boolean |
isRetrievable()
A hot-spot method that indicates if a parameter value, given a name within a scope, can be retrieved. |
protected boolean |
isScopeDerivable()
Determines if this parameter has a scope that can be derived, also known as a default context or namespace for resolving elements and/or creating new parameter values. |
protected boolean |
isTypeSubstitutable()
Indicates if the type of this parameter can be made more concrete and subtituted for various operations that requires a concrete type in lieu of an abstract type. |
boolean |
isValid(AbstractPatternInstance instance,
Object value)
Determines if a parameter value is valid given a pattern instance. |
protected boolean |
isValid(PatternParameterValue.Maintained maintained)
Determines if the maintained value is valid. |
protected boolean |
isValid(PatternParameterValue.Proposed proposed)
Determines if the proposed value is valid. |
protected boolean |
isValid(PatternParameterValue.Unresolved unresolved)
Determines if the unresolved value is valid. |
protected boolean |
isValid(PatternParameterValue.Unresolved unresolved,
PatternParameterValue.Unresolved.Directive directive)
Determines if the unresolved value is valid. |
boolean |
isValidParameterTarget(Object targetObject)
Indicates whether this target object is a valid parameter value for this parameter to bind to. |
protected Object |
resolve(PatternParameterValue.Unresolved unresolved)
The resolve method is called if an unresolved value is attempting to be bound to this parameter. |
protected Object |
resolve(PatternParameterValue.Unresolved unresolved,
PatternParameterValue.Unresolved.Directive directive)
The resolve method extends upon the resolve method that does not take a directive. |
protected Object |
retrieve(AbstractPatternInstance instance,
String valueName)
A hot-spot method that retrieves a parameter value, given a name |
IStatus |
usesPairsToCreateArguments(AbstractPatternInstance instance,
IPatternMetatype metatype)
Indicates whether this parameter uses a pair of other parameter's arguments to create default arguments |
protected IStatus |
validToAddArgument(PatternParameterValue.Proposed proposed)
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. |
protected IStatus |
validToAddArgument(PatternParameterValue.Unresolved unresolved)
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. |
protected IStatus |
validToCreateArguments(AbstractPatternInstance instance,
IPatternMetatype metatype)
This is a hotspot method used in conjunction with the create method. |
protected IStatus |
validToReplaceArgument(PatternParameterValue.Proposed proposed)
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. |
protected IStatus |
validToReplaceArgument(PatternParameterValue.Unresolved unresolved)
This method is a hotspot that is overridden to add custom pattern specific argument validation logic. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.ibm.xtools.patterns.core.IParameterDescriptor |
isValidArgumentType |
Constructor Detail |
public AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity)
owningDefinition
- the owning definition for this parameterparameterIdentity
- the identity of the parameter, typically this would be the
fully qualified class name of the concrete abstract pattern
parameter implemented by the authorpublic AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity, String oclExpression)
owningDefinition
- the owning definition for this parameterparameterIdentity
- the identity of the parameter, typically this would be the
fully qualified class name of the concrete abstract pattern
parameter implemented by the authoroclExpression
- a valid OCL expression used for constraining the values
allowable to be bound to this parameterMethod Detail |
public void accept(Visitor visitor)
accept
in interface Visitable
public int compareTo(Object object)
compareTo
in interface Comparable
protected abstract Object[] create(AbstractPatternInstance instance, IPatternMetatype metatype)
instance
- the instance that defines context for creating new
prototypical instances of suggested arguments of this
parametermetatype
- the proposed metatype for the new prototypical arguments of
this parameter; if the metatype is null
then
the parameter may choose an appropriate metatype
protected abstract Object[] create(AbstractPatternInstance instance, IPatternMetatype metatype, String scopeQualifiedName)
instance
- the instance that defines context for creating new
prototypical instances of suggested arguments of this
parametermetatype
- the proposed metatype for the new prototypical arguments of
this parameter; if the metatype is null
then
the parameter may choose an appropriate metatypescopeQualifiedName
- the qualified name that specifies the scope.
public Object[] createArgumentsUsingPairs(AbstractPatternInstance instance, IPatternMetatype metatype, AbstractParameterArgument.Pair[] pairs)
instance
- the instance that defines context for creating new
prototypical instances of suggested arguments of this
parametermetatype
- the proposed metatype for the new prototypical arguments of
this parameter; if the metatype is null
then
the parameter may choose an appropriate metatypepairs
- -
pairs of clients and suppliers which should be used to create
the new element
public boolean equals(Object object)
protected boolean expand(PatternParameterValue value)
value
- the value used in the expansion
protected boolean expand(PatternParameterValue.Added value)
value
- the value used in the expansion
expand(PatternParameterValue)
protected boolean expand(PatternParameterValue.Maintained value)
value
- the value used in the expansion
protected boolean expand(PatternParameterValue.Removed value)
value
- the value used in the expansion
protected boolean expand(PatternParameterValue.Replaced value)
value
- the value used in the expansion
public IPatternMetatype[] getAlternateTypes()
IParameterDescriptor
Retrieves the alternate types that are accepted for the arguments of the parameter represented by this descriptor.
getAlternateTypes
in interface IParameterDescriptor
protected Object getDerivedScope(AbstractPatternInstance instance)
instance
- the pattern instance of interest for determining if a default
scope is available
public final String getDescription()
ITransformationItem
getDescription
in interface ITransformationItem
public AbstractParameterArgument[] getFirstArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status)
public final String getId()
ITransformationItem
getId
in interface ITransformationItem
public final IMultiplicity getMultiplicity()
IParameterDescriptor
Retrieves the multiplicity of the parameter represented by this descriptor.
Multiplicity represents the range of the allowable cardinality values that a set can assume.
getMultiplicity
in interface IParameterDescriptor
public final String getName()
ITransformationItem
getName
in interface ITransformationItem
public final int getOrdinal()
IParameterDescriptor
Retrieves the ordinal of the parameter in the list of parameters for the pattern.
getOrdinal
in interface IParameterDescriptor
public final AbstractPatternDefinition getOwningDefinition()
public final IPatternIdentity getPatternIdentity()
IParameterDescriptor
Retrieves the composite identity of the pattern that has the parameter represented by this descriptor.
The composite unique identity of a pattern is represented by a pattern descriptor. The components of the identity are the id (getPatternId) and the version of the pattern (getPatternVersion).
getPatternIdentity
in interface IParameterDescriptor
public final ITransformationProperty[] getProperties()
ITransformationDescriptor
getProperties
in interface ITransformationDescriptor
public final ITransformationProperty getProperty(String propertyId)
ITransformationDescriptor
getProperty
in interface ITransformationDescriptor
propertyId
- the identifier of the property
public final String[] getPropertyIds()
ITransformationDescriptor
getPropertyIds
in interface ITransformationDescriptor
public AbstractParameterArgument[] getSecondArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status)
public AbstractParameterArgument[] getSecondArgumentCandidatesForFirstValue(AbstractPatternInstance instance, IPatternMetatype metatype, AbstractParameterArgument firstValue, MultiStatus status)
protected EClass getSubstituteType()
public IPatternMetatype getType()
IParameterDescriptor
Retrieves the type of the parameter represented by this descriptor.
Use the Pair method to retrieve the argument pairs used as parameter arguments. Use the isValidArgumentType method to retrieve whether the object of a specific metatype is accepted as an argument of the parameter. Use the getAlternateTypes method to retrieve the types accepted for parameter arguments.
getType
in interface IParameterDescriptor
public final Object getValue(AbstractPatternInstance instance)
instance
- associated with value
public final Object[] getValues(AbstractPatternInstance instance)
instance
- associated with values
public int hashCode()
public final boolean hasValue(AbstractPatternInstance instance)
instance
- associated with value
public final boolean hasValues(AbstractPatternInstance instance)
instance
- associated with value
protected void initialize()
public final boolean isBindable()
IParameterDescriptor
Retrieves whether the parameter represented by this descriptor is available for binding with an argument or arguments.
A binding is a relationship connection between a template and a model element generated from the template. It provides the collection of the arguments that instantiate the template parameters. A binding is associated with one template. Each binding generates one model element. The generated model element must be fully specified by the arguments supplied to the binding.
Note: In general, if a parameter is not bindable, it should not be exposed to a user.
isBindable
in interface IParameterDescriptor
public final boolean isPublic()
ITransformationDescriptor
This is a convenience method for returning the value of the PUBLIC property.
isPublic
in interface ITransformationDescriptor
protected boolean isRetrievable()
protected boolean isScopeDerivable()
getDerivedScope(AbstractPatternInstance)
,
create(AbstractPatternInstance, IPatternMetatype)
protected boolean isTypeSubstitutable()
public boolean isValid(AbstractPatternInstance instance, Object value)
instance
- the pattern instance of interestvalue
- the value to determine validity of
protected boolean isValid(PatternParameterValue.Proposed proposed)
proposed
- the proposed vlaue
protected boolean isValid(PatternParameterValue.Maintained maintained)
maintained
- the maintained vlaue
protected boolean isValid(PatternParameterValue.Unresolved unresolved)
unresolved
- the unresolved value
protected boolean isValid(PatternParameterValue.Unresolved unresolved, PatternParameterValue.Unresolved.Directive directive)
unresolved
- the unresolved valuedirective
- the additional directive to alter the validity logic
public final boolean isValidParameterTarget(Object targetObject)
targetObject
- the object attempting to be bound
protected Object resolve(PatternParameterValue.Unresolved unresolved)
resolve
and
isValid(Unresolved)
methods for a parameter would either
be overridden or not overridden.
unresolved
- the value that is in the unresolved state
protected Object resolve(PatternParameterValue.Unresolved unresolved, PatternParameterValue.Unresolved.Directive directive)
unresolved
- the value that is in the unresolved statedirective
- an additional directive that modifies behavior
resolve(PatternParameterValue.Unresolved)
protected Object retrieve(AbstractPatternInstance instance, String valueName)
instance
- the instance that gives context to the retrievalvalueName
- the name of the parameter value to retrieve
public IStatus usesPairsToCreateArguments(AbstractPatternInstance instance, IPatternMetatype metatype)
instance
- the pattern instancemetatype
- the metatype of the arguments wanting creation
protected IStatus validToAddArgument(PatternParameterValue.Proposed proposed)
proposed
- the proposed value to validate
protected IStatus validToAddArgument(PatternParameterValue.Unresolved unresolved)
unresolved
- the unresolved value to determine if resolution into a valid
argument is possible
protected IStatus validToCreateArguments(AbstractPatternInstance instance, IPatternMetatype metatype)
instance
- the pattern instance of interestmetatype
- the metatype corresponding to the arguments to create
protected IStatus validToReplaceArgument(PatternParameterValue.Proposed proposed)
proposed
- the proposed value to validate
protected IStatus validToReplaceArgument(PatternParameterValue.Unresolved unresolved)
unresolved
- the unresolved value to determine if resolution into a valid
argument is possible
|
IBM Rational Software Modeler Release 6.0 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2004. All rights reserved.