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 void
Adds a value to a multi-valued propert of an eobject.static void
Adds a value to a multi-valued propert of an eobject.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.static void
copy
(EObject source, EObject target) Copies all the properties from one object to anoter.static EStructuralFeature
Method 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 eachEObject
in a list.static Object
Gets the property of an eobject.static Object
getFromMap
(EObject eobject, String property, Object key) Returns a value from a map based property of an eobject.static Object
getFromMapSafe
(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 boolean
Determines if an eobject has a particular property.static boolean
isCollection
(EObject eobject, String property) Determines if a property of an eobject is a collection.static boolean
isCollection
(EObject eobject, EStructuralFeature feature) Determines if a feature of an eobject is a collection.static boolean
Determines if a particular propety has been set on eachEObject
in a list.static boolean
Determines if a particular propety has been set on an eobject.static boolean
Determines if a particular propety is unset on eachEObject
in a list.static void
Sets a particular property on eachEObject
in a list to a particular value.static void
Sets a particular property on eachEObject
in a list to a particular value.static void
Sets 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:
true
if 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:
true
if 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:
true
if 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
null
if 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 eachEObject
in 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 inobjects
values
- The value to set on each eobjct inobjects
-
set
Sets a particular property on eachEObject
in a list to a particular value.- Parameters:
objects
- A list ofEObject
.property
- The property to set on each eobject inobjects
value
- The value to set on each eobjct inobjects
-
get
Obtains the values of a particular property on eachEObject
in 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:
true
if the property has been set, otherwisefalse
-
isSet
Determines if a particular propety has been set on eachEObject
in a list.- Parameters:
objects
- A list ofEObject
property
- The property to check.- Returns:
true
if every element in the list has been set, otherwisefalse
-
isUnset
Determines if a particular propety is unset on eachEObject
in a list.- Parameters:
objects
- A list ofEObject
property
- The property to check.- Returns:
true
if 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.
-