org.eclipse.emf.compare.util
Class EFactory

java.lang.Object
  extended by org.eclipse.emf.compare.util.EFactory

public final class EFactory
extends java.lang.Object

This is a factory for an ecore metamodel. There is a factory by package. Each factory is used to create instances of classifiers.


Method Summary
static
<T> void
eAdd(org.eclipse.emf.ecore.EObject object, java.lang.String name, T arg)
          Adds the new value of the given feature of the object.
static
<T> void
eAdd(org.eclipse.emf.ecore.EObject object, java.lang.String name, T arg, int elementIndex)
          Adds the new value of the given feature of the object.
static java.lang.Object eGet(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets the value of the given feature of the object.
static java.util.List<?> eGetAsList(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets the value of the given feature of the object as a List.
static java.lang.String eGetAsString(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets the value of the given feature of the object as a String.
static
<T> void
eInsertAt(org.eclipse.emf.ecore.EObject object, java.lang.String name, T arg, int insertionIndex)
          Adds the new value of the given feature of the object at the given index.
static void eRemove(org.eclipse.emf.ecore.EObject object, java.lang.String name, java.lang.Object arg)
          Removes the value of the given feature of the object.
static void eSet(org.eclipse.emf.ecore.EObject object, java.lang.String name, java.lang.Object arg)
          Sets the value of the given feature of the object to the new value.
static org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature(org.eclipse.emf.ecore.EObject object, java.lang.String name)
          Gets the structural feature of the given feature name of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

eAdd

public static <T> void eAdd(org.eclipse.emf.ecore.EObject object,
                            java.lang.String name,
                            T arg)
                 throws FactoryException
Adds the new value of the given feature of the object. If the structural feature isn't a list, it behaves like eSet.

Type Parameters:
T - Type of the new value to be added to the list.
Parameters:
object - Object on which we want to add to the feature values list.
name - The name of the feature to add to.
arg - New value to add to the feature values.
Throws:
FactoryException - Thrown if the affectation fails.

eAdd

public static <T> void eAdd(org.eclipse.emf.ecore.EObject object,
                            java.lang.String name,
                            T arg,
                            int elementIndex)
                 throws FactoryException
Adds the new value of the given feature of the object. If the structural feature isn't a list, it behaves like eSet.

Type Parameters:
T - Type of the new value to be added to the list.
Parameters:
object - Object on which we want to add to the feature values list.
name - The name of the feature to add to.
arg - New value to add to the feature values.
elementIndex - in case the feature is multiplicity-many, specify the index where the new value has to be added. If the index is -1, the value will be appended to the feature list.
Throws:
FactoryException - Thrown if the affectation fails.

eInsertAt

public static <T> void eInsertAt(org.eclipse.emf.ecore.EObject object,
                                 java.lang.String name,
                                 T arg,
                                 int insertionIndex)
                      throws FactoryException
Adds the new value of the given feature of the object at the given index. If the structural feature isn't a list, it behaves like eSet and the index is ignored.

Type Parameters:
T - Type of the new value to be added to the list.
Parameters:
object - Object on which we want to add to the feature values list.
name - The name of the feature to add to.
arg - New value to add to the feature values.
insertionIndex - Index in the list at which the new value is to be added.
Throws:
FactoryException - Thrown if the affectation fails.
Since:
1.0

eGet

public static java.lang.Object eGet(org.eclipse.emf.ecore.EObject object,
                                    java.lang.String name)
                             throws FactoryException
Gets the value of the given feature of the object.

Parameters:
object - Object to retrieve the feature value from.
name - The feature name, or a method defined on EObject like 'eClass', 'eResource', 'eContainer', 'eContainingFeature', 'eContainmentFeature', 'eContents', 'eAllContents', 'eCrossReferences'
Returns:
Value of the given feature of the object
Throws:
FactoryException - Thrown if the retrieval fails.

eGetAsList

public static java.util.List<?> eGetAsList(org.eclipse.emf.ecore.EObject object,
                                           java.lang.String name)
                                    throws FactoryException
Gets the value of the given feature of the object as a List.

Parameters:
object - Object to retrieve the feature value from.
name - Name of the feature to get the value for.
Returns:
    If the feature is :
  • a list : value of the feature
  • a single valued feature : new list containing the value as its single element
  • not a feature : null
Throws:
FactoryException - Thrown if the retrieval fails.

eGetAsString

public static java.lang.String eGetAsString(org.eclipse.emf.ecore.EObject object,
                                            java.lang.String name)
                                     throws FactoryException
Gets the value of the given feature of the object as a String.

Parameters:
object - Object to retrieve the feature value from.
name - Name of the feature to get the value for.
Returns:
Value of the feature, null if this value isn't a String.
Throws:
FactoryException - Thrown if the retrieval fails.

eRemove

public static void eRemove(org.eclipse.emf.ecore.EObject object,
                           java.lang.String name,
                           java.lang.Object arg)
                    throws FactoryException
Removes the value of the given feature of the object. If the structural feature isn't a list, it behaves like eSet(object, name, null) and resets the feature even if specified value isn't equal to the actual feature's value.

Parameters:
object - Object on which we want to remove from the feature values list.
name - The name of the feature to remove from.
arg - Value to remove from the feature values, can be null.
Throws:
FactoryException - Thrown if the removal fails.

eSet

public static void eSet(org.eclipse.emf.ecore.EObject object,
                        java.lang.String name,
                        java.lang.Object arg)
                 throws FactoryException
Sets the value of the given feature of the object to the new value.

Parameters:
object - Object on which we want to set the feature value.
name - The name of the feature to set.
arg - New value to affect to the feature.
Throws:
FactoryException - Thrown if the affectation fails.

eStructuralFeature

public static org.eclipse.emf.ecore.EStructuralFeature eStructuralFeature(org.eclipse.emf.ecore.EObject object,
                                                                          java.lang.String name)
                                                                   throws FactoryException
Gets the structural feature of the given feature name of the object.

Parameters:
object - Object to retrieve the feature from.
name - Name of the feature to retrieve.
Returns:
The structural feature name of object.
Throws:
FactoryException - Thrown if the retrieval fails.

Copyright 2006 IBM Corporation and others.
All Rights Reserved.