public class GTTools
extends java.lang.Object
Constructor and Description |
---|
GTTools() |
Modifier and Type | Method and Description |
---|---|
static void |
checkContainerClass(Attribute attribute,
NamedObj container,
java.lang.Class<? extends CompositeEntity> containerClass,
boolean deep)
Check the class of the container in which the attribute is to be placed.
|
static void |
checkUniqueness(Attribute attribute,
NamedObj container)
Check whether the attribute is unique in the given container.
|
static NamedObj |
cleanupModel(NamedObj model)
Create a copy of the given model in a new workspace that is cleaned up
with no execution state left in it.
|
static NamedObj |
cleanupModel(NamedObj model,
MoMLParser parser)
Create a copy of the given model with the given parser that is cleaned
up with no execution state left in it.
|
static NamedObj |
cleanupModel(NamedObj model,
Workspace workspace)
Create a copy of the given model in the given workspace that is cleaned
up with no execution state left in it.
|
static void |
deepAddAttributes(NamedObj container,
java.lang.Class<? extends Attribute> attributeClass)
Add an attribute to the given container and each of its children
including ports, entities and relations, but not including attributes.
|
static void |
deepRemoveAttributes(NamedObj container,
java.lang.Class<? extends Attribute> attributeClass)
Remove all the attributes in the given class from the given container
and all of its children including ports, entities and relations, but not
including attributes.
|
static Attribute |
findMatchingAttribute(java.lang.Object object,
java.lang.Class<? extends Attribute> attributeClass,
boolean searchContainers)
Find an attribute in the object or its container (if searchContainers is
true) in the given class.
|
static NamedObj |
getChild(NamedObj object,
java.lang.String name,
boolean allowAttribute,
boolean allowPort,
boolean allowEntity,
boolean allowRelation)
Get the child of the given object with the given name.
|
static java.util.Collection<NamedObj> |
getChildren(NamedObj object,
boolean includeAttributes,
boolean includePorts,
boolean includeEntities,
boolean includeRelations)
Get the children of the given object.
|
static java.lang.String |
getCodeFromObject(NamedObj object,
NamedObj topContainer)
Get the unique string description containing the type and name of the\
object within the given container.
|
static CompositeActorMatcher |
getContainingPatternOrReplacement(NamedObj object)
Get the pattern or replacement of a transformation rule that contains
the given object.
|
static NamedObj |
getCorrespondingPatternObject(NamedObj replacementObject)
Given an object in the replacement, return the corresponding object in
the pattern if any, or null otherwise.
|
static MoMLChangeRequest |
getDeletionChangeRequest(java.lang.Object originator,
NamedObj object)
Return the change request to delete the given object.
|
static NamedObj |
getObjectFromCode(java.lang.String code,
NamedObj topContainer)
Get the object within the given container whose type and name
correspond to the code.
|
static java.lang.String |
getObjectTypeAbbreviation(NamedObj object)
Get the abbreviation of the object's type.
|
static PatternObjectAttribute |
getPatternObjectAttribute(NamedObj object,
boolean createNew)
Get the
PatternObjectAttribute associated with the object, and
if it is not found, either return null if createNew is false, or create
a new one and return it. |
static boolean |
isCreated(java.lang.Object object)
Return whether the object in the pattern is to be created.
|
static boolean |
isIgnored(java.lang.Object object)
Return whether the object in the pattern is to be ignored.
|
static boolean |
isInPattern(NamedObj object)
Return whether the object is in a pattern.
|
static boolean |
isInReplacement(NamedObj object)
Return whether the object is in a replacement.
|
static boolean |
isNegated(java.lang.Object object)
Return whether the object in the pattern is to be negated.
|
static boolean |
isOptional(java.lang.Object object)
Return whether the object in the pattern is to be optional.
|
static boolean |
isPreserved(java.lang.Object object)
Return whether the object in the pattern is to be preserved.
|
static void |
restoreValues(ComponentEntity root,
java.util.Hashtable<ValueIterator,Token> records)
Restore the values of the parameters that implement the
ValueIterator interface within the root entity using the values
recorded in the given table previously. |
static void |
saveValues(ComponentEntity root,
java.util.Hashtable<ValueIterator,Token> records)
Save the values of parameters that implement the
ValueIterator
interface in the given records table, starting from the root entity. |
static void |
setIconDescription(NamedObj object,
java.lang.String iconDescription)
Execute a MoMLChangeRequest to set the icon description of the
attribute.
|
public static void checkContainerClass(Attribute attribute, NamedObj container, java.lang.Class<? extends CompositeEntity> containerClass, boolean deep) throws IllegalActionException
attribute
- The attribute to check.container
- The container.containerClass
- The intended class of container.deep
- Whether containers of the container should be checked
instead, if the container does not qualify.IllegalActionException
- If this attribute cannot be used with
the given container.public static void checkUniqueness(Attribute attribute, NamedObj container) throws IllegalActionException
attribute
- The attribute to check.container
- The container.IllegalActionException
- If the container already has an
attribute in the same class.public static NamedObj cleanupModel(NamedObj model) throws IllegalActionException
model
- The model to be copied.IllegalActionException
- If the model cannot be copied.public static NamedObj cleanupModel(NamedObj model, MoMLParser parser) throws IllegalActionException
model
- The model to be copied.parser
- The parser.IllegalActionException
- If the model cannot be copied.public static NamedObj cleanupModel(NamedObj model, Workspace workspace) throws IllegalActionException
model
- The model to be copied.workspace
- The workspace.IllegalActionException
- If the model cannot be copied.public static void deepAddAttributes(NamedObj container, java.lang.Class<? extends Attribute> attributeClass) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
container
- The container.attributeClass
- The attribute class.java.lang.InstantiationException
- If an attribute cannot be
instantiated.java.lang.IllegalAccessException
- If the constructor of the attribute
class is not accessible.java.lang.reflect.InvocationTargetException
- If the arguments to constructor is
not valid.public static void deepRemoveAttributes(NamedObj container, java.lang.Class<? extends Attribute> attributeClass) throws IllegalActionException
container
- The container.attributeClass
- The attribute class.IllegalActionException
- If an attribute cannot be removed.public static Attribute findMatchingAttribute(java.lang.Object object, java.lang.Class<? extends Attribute> attributeClass, boolean searchContainers)
object
- The object to which the attribute longs.attributeClass
- The attribute class.searchContainers
- Whether containers of the object are searched.public static NamedObj getChild(NamedObj object, java.lang.String name, boolean allowAttribute, boolean allowPort, boolean allowEntity, boolean allowRelation)
object
- The object.name
- The name of the child.allowAttribute
- Whether the child can be an attribute.allowPort
- Whether the child can be a port.allowEntity
- Whether the child can be an entity.allowRelation
- Whether the child can be a relation.public static java.util.Collection<NamedObj> getChildren(NamedObj object, boolean includeAttributes, boolean includePorts, boolean includeEntities, boolean includeRelations)
object
- The object.includeAttributes
- Whether the children can be attributes.includePorts
- Whether the children can be ports.includeEntities
- Whether the children can be entities.includeRelations
- Whether the children can be relations.public static java.lang.String getCodeFromObject(NamedObj object, NamedObj topContainer)
object
- The object.topContainer
- The container used as the top level.getObjectFromCode(String, NamedObj)
public static CompositeActorMatcher getContainingPatternOrReplacement(NamedObj object)
object
- The object.Pattern
) or replacement (of type
Replacement
.public static NamedObj getCorrespondingPatternObject(NamedObj replacementObject)
replacementObject
- The object in the replacement.public static MoMLChangeRequest getDeletionChangeRequest(java.lang.Object originator, NamedObj object)
originator
- The originator of the change request.object
- The object to be deleted.public static NamedObj getObjectFromCode(java.lang.String code, NamedObj topContainer)
code
- The code.topContainer
- The container used as the top level.getCodeFromObject(NamedObj, NamedObj)
public static java.lang.String getObjectTypeAbbreviation(NamedObj object)
object
- The object.public static PatternObjectAttribute getPatternObjectAttribute(NamedObj object, boolean createNew) throws IllegalActionException, NameDuplicationException
PatternObjectAttribute
associated with the object, and
if it is not found, either return null if createNew is false, or create
a new one and return it.object
- The object.createNew
- Whether a new attribute should be created if it is not
found.IllegalActionException
- If the attribute is not of an
acceptable class for the container, or if the name contains a period.NameDuplicationException
- If the name coincides with
an attribute already in the container.public static boolean isCreated(java.lang.Object object)
object
- The object in the pattern.public static boolean isIgnored(java.lang.Object object)
object
- The object in the pattern.public static boolean isInPattern(NamedObj object)
object
- The object.isInReplacement(NamedObj)
public static boolean isInReplacement(NamedObj object)
object
- The object.isInPattern(NamedObj)
public static boolean isNegated(java.lang.Object object)
object
- The object in the pattern.public static boolean isOptional(java.lang.Object object)
object
- The object in the pattern.public static boolean isPreserved(java.lang.Object object)
object
- The object in the pattern.public static void restoreValues(ComponentEntity root, java.util.Hashtable<ValueIterator,Token> records) throws IllegalActionException
ValueIterator
interface within the root entity using the values
recorded in the given table previously. The values are restored
bottom-up.root
- The root.records
- The table with the previously stored values.IllegalActionException
- If the values of those parameters cannot
be set.public static void saveValues(ComponentEntity root, java.util.Hashtable<ValueIterator,Token> records) throws IllegalActionException
ValueIterator
interface in the given records table, starting from the root entity.root
- The root.records
- The table to store the values.IllegalActionException
- If the values of those parameters cannot
be obtained.public static void setIconDescription(NamedObj object, java.lang.String iconDescription)
object
- The attribute.iconDescription
- The icon description.