Package org.geotools.xsd
Class EMFUtils
Object
EMFUtils
Utility methods for working with emf model objects.
- Author:
- Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a value to a multi-valued propert of an eobject.static voidAdds a value to a multi-valued propert of an eobject.static EObjectclone(EObject prototype, EFactory factory, boolean deep) Clones an eobject, with the option of performing a deep clone in which referenced eobjects are also cloned.static voidcopy(EObject source, EObject target) Copies all the properties from one object to anoter.static EStructuralFeatureMethod which looks up a structure feature of an eobject, first doing an exact name match, then a case insensitive one.static List<EStructuralFeature>Method which looks up structural features of an eobject by type.Obtains the values of a particular property on eachEObjectin a list.static ObjectGets the property of an eobject.static ObjectgetFromMap(EObject eobject, String property, Object key) Returns a value from a map based property of an eobject.static ObjectgetFromMapSafe(EObject eobject, String property, String key) Returns a value from a map based property of an eobject, handling null cases and the case where the property is not actually a map.static booleanDetermines if an eobject has a particular property.static booleanisCollection(EObject eobject, String property) Determines if a property of an eobject is a collection.static booleanisCollection(EObject eobject, EStructuralFeature feature) Determines if a feature of an eobject is a collection.static booleanDetermines if a particular propety has been set on eachEObjectin a list.static booleanDetermines if a particular propety has been set on an eobject.static booleanDetermines if a particular propety is unset on eachEObjectin a list.static voidSets a particular property on eachEObjectin a list to a particular value.static voidSets a particular property on eachEObjectin a list to a particular value.static voidSets a property of an eobject.
-
Constructor Details
-
EMFUtils
public EMFUtils()
-
-
Method Details
-
has
Determines if an eobject has a particular property.- Parameters:
eobject- The eobject.property- The property to check for.- Returns:
trueif the property exists, otherwisefalse</code.
-
set
Sets a property of an eobject.- Parameters:
eobject- THe object.property- The property to set.value- The value of the property.
-
get
Gets the property of an eobject.- Parameters:
eobject- The object.property- The property to get.- Returns:
- The value of the property.
-
getFromMap
Returns a value from a map based property of an eobject.This method does not sort of checking of the property, use
getFromMapSafe(EObject, String, String)for more leniency.- Parameters:
eobject- The object.property- The map property.key- The key to obtain from the map.- Returns:
- The map value, possibly
null.
-
getFromMapSafe
Returns a value from a map based property of an eobject, handling null cases and the case where the property is not actually a map.This method returns null in cases where the the property does not exist, or it is not a map.
- Parameters:
eobject- The object.property- The map property.key- The key to obtain from the map.- Returns:
- The map value, possibly
null.
-
add
Adds a value to a multi-valued propert of an eobject.The property must map to a multi-valued property of the eobject. The
isCollection(EObject, String)method can be used to test this.- Parameters:
eobject- The object.property- The multi-valued property.value- The value to add.
-
add
Adds a value to a multi-valued propert of an eobject.The feature must map to a multi-valued property of the eobject. The
#isCollection(EStructuralFeature)method can be used to test this.- Parameters:
eobject- The object.feature- The multi-valued feature.value- The value to add.
-
isCollection
Determines if a property of an eobject is a collection.In the event the property does not exist, this method will return
false- Returns:
trueif hte property is a collection, otherwisefalse
-
isCollection
public static boolean isCollection(EObject eobject, EStructuralFeature feature) Determines if a feature of an eobject is a collection.- Returns:
trueif the feature is a collection, otherwisefalse
-
feature
Method which looks up a structure feature of an eobject, first doing an exact name match, then a case insensitive one.- Parameters:
eobject- The eobject.property- The property- Returns:
- The structure feature, or
nullif not found.
-
features
Method which looks up structural features of an eobject by type.- Parameters:
eobject- The eobject.propertyType- The type of the properties.- Returns:
- The list of structure features, or an empty list if none are found.
-
set
Sets a particular property on eachEObjectin a list to a particular value.The following must hold:
objects.size() == values.size()- Parameters:
objects- A list ofEObject.property- The property to set on each eobject inobjectsvalues- The value to set on each eobjct inobjects
-
set
Sets a particular property on eachEObjectin a list to a particular value.- Parameters:
objects- A list ofEObject.property- The property to set on each eobject inobjectsvalue- The value to set on each eobjct inobjects
-
get
Obtains the values of a particular property on eachEObjectin a list.- Parameters:
objects- A list ofEObject.property- The property to obtain.- Returns:
- The list of values.
-
isSet
Determines if a particular propety has been set on an eobject.- Parameters:
eobject- The eobject.property- The property to check.- Returns:
trueif the property has been set, otherwisefalse
-
isSet
Determines if a particular propety has been set on eachEObjectin a list.- Parameters:
objects- A list ofEObjectproperty- The property to check.- Returns:
trueif every element in the list has been set, otherwisefalse
-
isUnset
Determines if a particular propety is unset on eachEObjectin a list.- Parameters:
objects- A list ofEObjectproperty- The property to check.- Returns:
trueif every element in the list is unset, otherwisefalse
-
clone
public static EObject clone(EObject prototype, EFactory factory, boolean deep) Clones an eobject, with the option of performing a deep clone in which referenced eobjects are also cloned.- Parameters:
prototype- The object to be cloned from.factory- The factory used to create the clone.deep- indicating wether to perform a deep clone.- Returns:
- THe cloned object, with all properties the same to the original.
-
copy
public static void copy(EObject source, EObject target) Copies all the properties from one object to anoter.- Parameters:
source- The object to copy from.target- The object to copy to.
-