| Java API Reference | Class Hierarchy | All Classes | All Fields and Methods |
com.ibm.xtools.patterns.framework
+-- AbstractPatternElement +-- AbstractPatternParameter
abstract public Class AbstractPatternParameter
extends AbstractPatternElement
Represents the common implementation for a pattern parameter.
This class typically is 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.
The AbstractPatternparameter class stores and manages dependencies from this parameter to another parameter. The class 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 design of the framework because it allows the run-time execution or expansion behavior to be separated 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 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 aconsumer class for entities that consume abstract pattern parameters.
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 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.
| Constructor summary |
|---|
| AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity) Constructs a pattern parameter given only the parameter identity. |
| AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity, String oclExpression) Constructs a pattern parameter given only the parameter identity. |
| Method summary | |
|---|---|
| void | accept(Visitor visitor) Enables visitation of this entity. |
| int | compareTo(IParameterDescriptor parameterDescriptor) Compares parameter descriptors. |
| Object | createArgumentsUsingPairs(AbstractPatternInstance instance, IPatternMetatype metatype, Pair pairs) This method must just create values; the eventual adding of the values to the pattern instance are handled by the framework. |
| boolean | equals(Object object) Compares for equality through the default implementation of java.lang.Object.equals(Object). |
| IPatternMetatype | getAlternateTypes() Retrieves the array of pattern type objects. |
| String | getDescription() Retrieves the pattern description. |
| AbstractParameterArgument | getFirstArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status) Retrieves the first argument candidates for the parameter. |
| String | getId() Retrieves the Id of the object. |
| IMultiplicity | getMultiplicity() Retrieves the multiplicity of the object. |
| String | getName() Retrieves the name of the object. |
| int | getOrdinal() Retrieves the ordinal value. |
| AbstractPatternDefinition | getOwningDefinition() Returns the owning definition for this parameter. |
| IPatternIdentity | getPatternIdentity() Returns the pattern identity value. |
| ITransformationProperty | getProperties() Retrieves the pattern properties. |
| ITransformationProperty | getProperty(String propertyId) Retrieves the pattern property. |
| String | getPropertyIds() Retrieves the Ids of the pattern properties. |
| AbstractParameterArgument | getSecondArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status) Retrieves the second argument candidates. |
| AbstractParameterArgument | getSecondArgumentCandidatesForFirstValue(AbstractPatternInstance instance, IPatternMetatype metatype, AbstractParameterArgument firstValue, MultiStatus status) Retrieves the second argument candidates for the first value of the parameter. |
| IPatternMetatype | getType() Retrieves the type of the pattern. |
| Object | getValue(AbstractPatternInstance instance) Returns the value of the parameter for a given instance. |
| Object | getValues(AbstractPatternInstance instance) Returns the values of this parameter for a given instance. |
| int | hashCode() Retrieves the parameter hash code value. |
| boolean | hasValue(AbstractPatternInstance instance) Determines if the parameter has a value for a given instance. |
| boolean | hasValues(AbstractPatternInstance instance) Determines if the parameter has values for a given instance. |
| boolean | isBindable() Retrieves whether the object is bindable. |
| boolean | isPublic() Retrieves whether the object is public. |
| boolean | isValid(AbstractPatternInstance instance, Object value) Determines if a parameter value is valid given a pattern instance. |
| boolean | isValidParameterTarget(Object targetObject) Indicates whether this target object is a valid parameter value for this parameter to bind to. |
| IStatus | usesPairsToCreateArguments(AbstractPatternInstance instance, IPatternMetatype metatype) Indicates whether this parameter uses a pair of other parameter's arguments to create default arguments. |
Constructor detail
public AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity)
Constructs a pattern parameter given only the parameter identity.
The parameter descriptor offered by the associated static pattern provider is attached to this parameter as the concrete descriptor state in this class.
Parameters:
| owningDefinition | - The owning definition for this parameter. |
| parameterIdentity | - The identity of the parameter. Typically this value is the fully qualified class name of the concrete abstract pattern parameter implemented by the author. |
public AbstractPatternParameter(AbstractPatternDefinition owningDefinition, PatternParameterIdentity parameterIdentity, String oclExpression)
Constructs a pattern parameter given only the parameter identity.
The parameter descriptor offered by the associated static pattern provider is attached to this parameter as the concrete descriptor state in this class.
Parameters:
| owningDefinition | - The owning definition for this parameter. |
| parameterIdentity | - The identity of the parameter. Typically this is the fully qualified class name of the concrete abstract pattern parameter implemented by the author. |
| oclExpression | - A valid OCL expression used for constraining the values allowable to be bound to this parameter. |
Method detail
public void accept(Visitor visitor)
Enables visitation of this entity.
Parameters:
| visitor | - The visitor of the entity. |
public int compareTo(IParameterDescriptor parameterDescriptor)
Compares parameter descriptors.
Parameters:
| parameterDescriptor | - The descriptor of the parameter. |
Returns:
An integer representing the compared values. |
public Object createArgumentsUsingPairs(AbstractPatternInstance instance, IPatternMetatype metatype, Pair pairs)
This method must just create values; the eventual adding of the values to the pattern instance are handled by the framework.
If this parameter supports the creation of the prototypical instances then this method is implemented. It is determined whether or not a parameter supports prototypical instance creation by implementing the is creatable method so it returns a value of true .This is a hot-spot method that is used in conjunction with the is creatable method.
Parameters:
| instance | - The instance that defines the context for creating new prototypical instances of suggested arguments of this parameter. |
| metatype | - The proposed metatype for the new prototypical arguments of this parameter; if the metatype is null then the parameter may choose an appropriate metatype. |
| pairs | - The pairs of clients and suppliers that must be used to create the new element. |
Returns:
An object array that holds all new values that were created. The types of the returned objects need to conform with the is valid checks defined by this parameter. Before the new values are added, a validation is performed by invoking the is valid proposed value method variant. |
public boolean equals(Object object)
Compares for equality through the default implementation of java.lang.Object.equals(Object).
Parameters:
| object | - The object to be compared. |
Returns:
A boolean value of true if the object is equal. Otherwise, it returns a value of false. |
public IPatternMetatype getAlternateTypes()
Retrieves the array of pattern type objects.
Returns:
An array of IPatternMetatype objects representing the alternate type values. |
final public String getDescription()
Retrieves the pattern description.
Returns:
A string representing the description value. |
public AbstractParameterArgument getFirstArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status)
Retrieves the first argument candidates for the parameter.
Parameters:
| instance | - The pattern instance. |
| metatype | - The metatype of the argument. |
| status | - The status of the operation. |
Returns:
An array of AbstractParameterArgument objects. |
final public String getId()
Retrieves the Id of the object.
Returns:
The Id of the object. |
final public IMultiplicity getMultiplicity()
Retrieves the multiplicity of the object.
Returns:
An IMultiplicity object representing the multiplicity value. |
final public String getName()
Retrieves the name of the object.
Returns:
A string representing the name value. |
final public int getOrdinal()
Retrieves the ordinal value.
Returns:
An integer representing the ordinal value. |
final public AbstractPatternDefinition getOwningDefinition()
Returns the owning definition for this parameter.
Returns:
The definition that owns this parameter. |
final public IPatternIdentity getPatternIdentity()
Returns the pattern identity value.
Returns:
An IPatternIdentity object representing the pattern identity value. |
final public ITransformationProperty getProperties()
Retrieves the pattern properties.
Returns:
An array of ITransformationProperty objects representing the properties value. |
final public ITransformationProperty getProperty(String propertyId)
Retrieves the pattern property.
Parameters:
| propertyId | - The Id of the property. |
Returns:
An ITransformationProperty object. |
final public String getPropertyIds()
Retrieves the Ids of the pattern properties.
Returns:
An array of strings representing the property Ids values. |
public AbstractParameterArgument getSecondArgumentCandidates(AbstractPatternInstance instance, IPatternMetatype metatype, MultiStatus status)
Retrieves the second argument candidates.
Parameters:
| instance | - The instance of the parameter. |
| metatype | - The metatype of the argument. |
| status | - The status of the operation. |
Returns:
An array of AbstractParameterArgument objects. |
public AbstractParameterArgument getSecondArgumentCandidatesForFirstValue(AbstractPatternInstance instance, IPatternMetatype metatype, AbstractParameterArgument firstValue, MultiStatus status)
Retrieves the second argument candidates for the first value of the parameter.
Parameters:
| instance | - The instance of the parameter. |
| metatype | - The metatype of the argument. |
| firstValue | - The value of the argument. |
| status | - The status of the operation. |
Returns:
An array of AbstractParameterArgument objects. |
public IPatternMetatype getType()
Retrieves the type of the pattern.
Returns:
An IPatternMetatype object representing the type value. |
final public Object getValue(AbstractPatternInstance instance)
Returns the value of the parameter for a given instance.
Parameters:
| instance | - The instance associated with the value. |
Returns:
The value of the pattern parameter for the given pattern instance. |
final public Object getValues(AbstractPatternInstance instance)
Returns the values of this parameter for a given instance.
This method works for any multiplicity of the parameter. If a parameter has zero values bound then this method does not a value of null ,but to return an array of length zero instead.
Parameters:
| instance | - The instance associated with the values. |
Returns:
The value of the pattern parameter for the given pattern instance. |
public int hashCode()
Retrieves the parameter hash code value.
Returns:
An integer representing the value. |
final public boolean hasValue(AbstractPatternInstance instance)
Determines if the parameter has a value for a given instance.
Parameters:
| instance | - The instance associated with the value. |
Returns:
A boolean value of true if this parameter has a value for the given pattern instance. Otherwise, it returns a value of false. |
final public boolean hasValues(AbstractPatternInstance instance)
Determines if the parameter has values for a given instance.
Parameters:
| instance | - The instance associated with the value. |
Returns:
A boolean value of true if this parameter has values for the given pattern instance. Otherwise, it returns a value of false. |
final public boolean isBindable()
Retrieves whether the object is bindable.
Returns:
A boolean value of true if the object is bindable. Otherwise, it returns a value of false. |
final public boolean isPublic()
Retrieves whether the object is public.
Returns:
A boolean value of true if the object is public. Otherwise, it returns a value of false. |
public boolean isValid(AbstractPatternInstance instance, Object value)
Determines if a parameter value is valid given a pattern instance.
Parameters:
| instance | - The pattern instance of interest. |
| value | - The value for which to determine validity. |
Returns:
A boolean value of true if the proposed value is valid. Otherwise, it returns a value of false. |
final public boolean isValidParameterTarget(Object targetObject)
Indicates whether this target object is a valid parameter value for this parameter to bind to.
The value validation behavior is used to determine the return value.
In the implementation of this method, the is valid forwarding call should pass in a void pattern instance object instead of null. For now, a value of null is passed in. Until the null is changed to a void pattern instance object any implementer of the is valid proposed method should not access the owning pattern instance (or at least check for null first).
Parameters:
| targetObject | - The object attempting to be bound. |
Returns:
A boolean value of true if the target object is a valid parameter target. Otherwise, it returns a value of false. |
public IStatus usesPairsToCreateArguments(AbstractPatternInstance instance, IPatternMetatype metatype)
Indicates whether this parameter uses a pair of other parameter's arguments to create default arguments.
Parameters:
| instance | - The pattern instance. |
| metatype | - The metatype of the arguments wanting creation. |
Returns:
A status indicating true if using pairs to create default arguments is valid for this parameter, instance and metatype combination. |