org.eclipse.gmt.weaver.plugin.util
Class WeaverUtil

java.lang.Object
  extended by org.eclipse.gmt.weaver.plugin.util.WeaverUtil

public class WeaverUtil
extends java.lang.Object

This class contains convenient static methods for working with the weaver

Since:
1.0
Author:
- Marcos Didonet Del Fabro (LINA Labs, INRIA team)

Constructor Summary
WeaverUtil()
           
 
Method Summary
static int countElements(org.eclipse.emf.ecore.resource.Resource resource)
          returns the total number of elements of a given resource
static java.lang.Object get(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets object
static java.util.List getAllEClass(org.eclipse.emf.ecore.resource.Resource modelResource)
          returns all of the EClass for the resource
static java.util.Collection getAllMatchedEObjs(org.eclipse.emf.ecore.resource.Resource res, java.lang.String className, java.lang.String featureName, java.lang.Object featValue)
          returns the object (or objects if it is a reference) of a given resource that matches the feature name and value for an object
static java.util.List getAllPackages(org.eclipse.emf.ecore.resource.Resource modelResource)
          returns a list with all packages in a resource
static java.lang.String getAnnotationRefType(org.eclipse.emf.ecore.EClass eClass)
          returns the name of the class of welementref (saved as an annotation) (if it does not exists, returns ownedElementRef for the moment every model ref class must have an ownedelementrefannotation
static boolean getBoolean(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets boolean
static org.eclipse.emf.ecore.EClassifier getClassifier(java.lang.String name, org.eclipse.emf.ecore.resource.Resource resource)
          Returns classifier in the resource (for this name)
static org.eclipse.debug.core.ILaunchConfiguration getConfig(java.lang.String fName)
          returns a launch configuration of a transformation with the given launch configuration file name
static java.util.List getDerivedReferences(org.eclipse.emf.ecore.resource.Resource resource, java.lang.String eClass, java.lang.String sFeature)
          returns the derived values for the feature of a class
static java.lang.String getDescription(org.eclipse.emf.ecore.EObject object)
          Gets description
static org.eclipse.emf.ecore.EAttribute getEAttributeByName(org.eclipse.emf.ecore.resource.Resource modelResource, java.lang.String name)
          Returns attribute in resource
static org.eclipse.emf.ecore.EClass getEClassByName(org.eclipse.emf.ecore.resource.Resource modelResource, java.lang.String name)
          returns the first class in the resource with a given name
static java.util.List getElementsByType(java.lang.String type, org.eclipse.emf.ecore.resource.Resource resource)
          Gets a set of elements by type
static java.util.List getElementsByTypeHierarchy(java.lang.String type, org.eclipse.emf.ecore.resource.Resource resource)
          Gets a set of elements by type, and navigates in the hierarchy goes up trhough the hierarchy
static org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature(org.eclipse.emf.ecore.EObject eObj, java.lang.String name)
          returns a EStructural feature of the EObject based on its name
static IIdentifierAdapter getIdentifierAdapter(org.eclipse.emf.ecore.EObject eObj)
          returns the adapter capable of generating an ID for a given object
static IIdentifierAdapter getIdentifierAdapter(org.eclipse.emf.ecore.resource.Resource resource)
          returns the adapter capable of generating an ID for a resource
static int getInt(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets int
static java.util.List getMetamodelPackages(org.eclipse.emf.ecore.EObject eObj)
          returns the metamodel packages related with this eObj
static java.lang.String getName(org.eclipse.emf.ecore.EObject object)
          Gets name
static org.eclipse.emf.ecore.EPackage getPackage(org.eclipse.emf.ecore.resource.Resource modelResource, java.lang.String pkgName)
          returns the package of a given resource with a name equals to pkgName
static org.eclipse.core.runtime.IPath getPropertyFilePath(org.eclipse.core.resources.IFile file)
          gets the property file complete path
static java.lang.String getString(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets String
static java.util.List getSubTypeListOf(java.lang.String eClassName, org.eclipse.emf.ecore.resource.Resource resource)
          returns the list of subtype's name of eClassName in the resource
static java.util.List getWModelRefReferences(org.eclipse.emf.ecore.resource.Resource resource, java.lang.String className)
          returns all the references to WModelREf from o given class
static boolean isExtends(java.lang.String superClass, org.eclipse.emf.ecore.resource.Resource resource)
          returns true if subClass extends of superClass(String) in resource
static boolean isInstanceOf(org.eclipse.emf.ecore.EObject eObj, java.lang.String classifierName, java.util.List classifiers)
          returns true if this eObj is an instance of the classifier name
static boolean isInstanceOf(org.eclipse.emf.ecore.EObject eObj, java.lang.String classifierName, org.eclipse.emf.ecore.resource.Resource resource)
          returns true if this eObj is an instance of the classifier name
static boolean isSuperTypeOf(org.eclipse.emf.ecore.EClass someClass, java.lang.String superType, org.eclipse.emf.ecore.resource.Resource resource)
          returns true if someClass extends of superType(String) in resource
static void set(org.eclipse.emf.ecore.EObject object, java.lang.String name, boolean newValue)
          Set boolean
static void set(org.eclipse.emf.ecore.EObject object, java.lang.String name, int newValue)
          Sets int
static void set(org.eclipse.emf.ecore.EObject object, java.lang.String name, java.lang.Object newValue)
          Set object
static void setDescription(org.eclipse.emf.ecore.EObject object, java.lang.String description)
          Sets description
static void setName(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Sets string
static void setPropertyValue(org.eclipse.emf.ecore.EObject eObj, java.lang.Object objValue, java.lang.String propertyName, org.eclipse.emf.edit.domain.EditingDomain editingDomain)
          Sets a property value for a given EObject based on the metamodel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeaverUtil

public WeaverUtil()
Method Detail

getClassifier

public static org.eclipse.emf.ecore.EClassifier getClassifier(java.lang.String name,
                                                              org.eclipse.emf.ecore.resource.Resource resource)
Returns classifier in the resource (for this name)

Parameters:
name -
resource -
Returns:

getEClassByName

public static org.eclipse.emf.ecore.EClass getEClassByName(org.eclipse.emf.ecore.resource.Resource modelResource,
                                                           java.lang.String name)
returns the first class in the resource with a given name

Parameters:
modelResource -
name -
Returns:

getAllEClass

public static java.util.List getAllEClass(org.eclipse.emf.ecore.resource.Resource modelResource)
returns all of the EClass for the resource

Parameters:
modelResource -
name -
Returns:

getPackage

public static org.eclipse.emf.ecore.EPackage getPackage(org.eclipse.emf.ecore.resource.Resource modelResource,
                                                        java.lang.String pkgName)
returns the package of a given resource with a name equals to pkgName

Parameters:
modelResource -
Returns:

countElements

public static int countElements(org.eclipse.emf.ecore.resource.Resource resource)
returns the total number of elements of a given resource

Parameters:
resource -
Returns:

getAllPackages

public static java.util.List getAllPackages(org.eclipse.emf.ecore.resource.Resource modelResource)
returns a list with all packages in a resource

Parameters:
modelResource -
Returns:

getEStructuralFeature

public static org.eclipse.emf.ecore.EStructuralFeature getEStructuralFeature(org.eclipse.emf.ecore.EObject eObj,
                                                                             java.lang.String name)
returns a EStructural feature of the EObject based on its name

Parameters:
eObj -
name -
Returns:

getAllMatchedEObjs

public static java.util.Collection getAllMatchedEObjs(org.eclipse.emf.ecore.resource.Resource res,
                                                      java.lang.String className,
                                                      java.lang.String featureName,
                                                      java.lang.Object featValue)
returns the object (or objects if it is a reference) of a given resource that matches the feature name and value for an object

Parameters:
res - the resource
name - the object class name
featureName - the feature name
featValue - the feature value
Returns:

isInstanceOf

public static boolean isInstanceOf(org.eclipse.emf.ecore.EObject eObj,
                                   java.lang.String classifierName,
                                   java.util.List classifiers)
returns true if this eObj is an instance of the classifier name

Parameters:
eObj -
className -
classifiers - a list of classifiers
Returns:

isInstanceOf

public static boolean isInstanceOf(org.eclipse.emf.ecore.EObject eObj,
                                   java.lang.String classifierName,
                                   org.eclipse.emf.ecore.resource.Resource resource)
returns true if this eObj is an instance of the classifier name

Parameters:
eObj -
classifierName -
resource - (metamodel) a resource with classifiers
Returns:

getMetamodelPackages

public static java.util.List getMetamodelPackages(org.eclipse.emf.ecore.EObject eObj)
returns the metamodel packages related with this eObj

Parameters:
eObj -
Returns:

isSuperTypeOf

public static boolean isSuperTypeOf(org.eclipse.emf.ecore.EClass someClass,
                                    java.lang.String superType,
                                    org.eclipse.emf.ecore.resource.Resource resource)
returns true if someClass extends of superType(String) in resource

Parameters:
someClass - the EClass to test
superType - the name of superclass
resource -
Returns:
true or false

getSubTypeListOf

public static java.util.List getSubTypeListOf(java.lang.String eClassName,
                                              org.eclipse.emf.ecore.resource.Resource resource)
returns the list of subtype's name of eClassName in the resource

Parameters:
eClassName - the name of the eclass
resource -
Returns:
list of String

isExtends

public static boolean isExtends(java.lang.String superClass,
                                org.eclipse.emf.ecore.resource.Resource resource)
returns true if subClass extends of superClass(String) in resource

Parameters:
superClass -
subClass -
resource -
Returns:

getElementsByType

public static java.util.List getElementsByType(java.lang.String type,
                                               org.eclipse.emf.ecore.resource.Resource resource)
Gets a set of elements by type

Parameters:
type -
resource -
Returns:

getElementsByTypeHierarchy

public static java.util.List getElementsByTypeHierarchy(java.lang.String type,
                                                        org.eclipse.emf.ecore.resource.Resource resource)
Gets a set of elements by type, and navigates in the hierarchy goes up trhough the hierarchy

Parameters:
type -
resource -
Returns:

getEAttributeByName

public static org.eclipse.emf.ecore.EAttribute getEAttributeByName(org.eclipse.emf.ecore.resource.Resource modelResource,
                                                                   java.lang.String name)
Returns attribute in resource

Parameters:
modelResource -
name -
Returns:

get

public static java.lang.Object get(org.eclipse.emf.ecore.EObject object,
                                   java.lang.String name)
Gets object

Parameters:
object -
name -
Returns:

getBoolean

public static boolean getBoolean(org.eclipse.emf.ecore.EObject object,
                                 java.lang.String name)
Gets boolean

Parameters:
object -
name -
Returns:

getInt

public static int getInt(org.eclipse.emf.ecore.EObject object,
                         java.lang.String name)
Gets int

Parameters:
object -
name -
Returns:

getString

public static java.lang.String getString(org.eclipse.emf.ecore.EObject object,
                                         java.lang.String name)
Gets String

Parameters:
object -
name -
Returns:

set

public static void set(org.eclipse.emf.ecore.EObject object,
                       java.lang.String name,
                       java.lang.Object newValue)
Set object

Parameters:
object -
name -
newValue -

set

public static void set(org.eclipse.emf.ecore.EObject object,
                       java.lang.String name,
                       boolean newValue)
Set boolean

Parameters:
object -
name -
newValue -

set

public static void set(org.eclipse.emf.ecore.EObject object,
                       java.lang.String name,
                       int newValue)
Sets int

Parameters:
object -
name -
newValue -

setName

public static void setName(org.eclipse.emf.ecore.EObject object,
                           java.lang.String name)
Sets string

Parameters:
object -
name -

getName

public static java.lang.String getName(org.eclipse.emf.ecore.EObject object)
Gets name

Parameters:
object -
Returns:

setDescription

public static void setDescription(org.eclipse.emf.ecore.EObject object,
                                  java.lang.String description)
Sets description

Parameters:
object -
description -

getDescription

public static java.lang.String getDescription(org.eclipse.emf.ecore.EObject object)
Gets description

Parameters:
object -
Returns:

setPropertyValue

public static void setPropertyValue(org.eclipse.emf.ecore.EObject eObj,
                                    java.lang.Object objValue,
                                    java.lang.String propertyName,
                                    org.eclipse.emf.edit.domain.EditingDomain editingDomain)
Sets a property value for a given EObject based on the metamodel

Parameters:
eObj -
propValue -
propertyName -
editingDomain -

getIdentifierAdapter

public static IIdentifierAdapter getIdentifierAdapter(org.eclipse.emf.ecore.EObject eObj)
returns the adapter capable of generating an ID for a given object

Parameters:
eObj - the object
Returns:
the ID generator adapter

getIdentifierAdapter

public static IIdentifierAdapter getIdentifierAdapter(org.eclipse.emf.ecore.resource.Resource resource)
returns the adapter capable of generating an ID for a resource

Parameters:
eObj - the object
Returns:
the ID generator adapter

getAnnotationRefType

public static java.lang.String getAnnotationRefType(org.eclipse.emf.ecore.EClass eClass)
returns the name of the class of welementref (saved as an annotation) (if it does not exists, returns ownedElementRef for the moment every model ref class must have an ownedelementrefannotation

Parameters:
eClass -
Returns:

getDerivedReferences

public static java.util.List getDerivedReferences(org.eclipse.emf.ecore.resource.Resource resource,
                                                  java.lang.String eClass,
                                                  java.lang.String sFeature)
returns the derived values for the feature of a class

Parameters:
resource -
eClass -
sFeature -
Returns:

getWModelRefReferences

public static java.util.List getWModelRefReferences(org.eclipse.emf.ecore.resource.Resource resource,
                                                    java.lang.String className)
returns all the references to WModelREf from o given class

Parameters:
resource -
eClass -
sFeature -
Returns:

getPropertyFilePath

public static org.eclipse.core.runtime.IPath getPropertyFilePath(org.eclipse.core.resources.IFile file)
gets the property file complete path

Parameters:
file -
Returns:

getConfig

public static org.eclipse.debug.core.ILaunchConfiguration getConfig(java.lang.String fName)
returns a launch configuration of a transformation with the given launch configuration file name

Parameters:
fName - launch configuration file name
Returns: