|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.uml2.common.util.UML2Util
public class UML2Util
Utilities for working with EMF-based objects and resources.
Nested Class Summary | |
---|---|
static interface |
UML2Util.Converter
An interface for classes that can convert objects to another representation. |
static class |
UML2Util.EClassMatcher
A matcher that determines matches based on the class of candidate objects. |
static interface |
UML2Util.EObjectMatcher
An interface for classes that can determine matches based on some criteria. |
static class |
UML2Util.EStructuralFeatureMatcher
A matcher that determines matches based on the class of, and the value for a specific structural feature held by, candidate objects. |
static class |
UML2Util.QualifiedTextProvider
The abstract parent of classes that can provide a textual representation of objects, classes, and features. |
Field Summary | |
---|---|
protected static org.eclipse.emf.ecore.resource.URIConverter |
DEFAULT_URI_CONVERTER
The default URI converter for resource bundle look-ups. |
static java.lang.String |
EMPTY_STRING
The empty string. |
protected static java.lang.String |
LINE_SEPARATOR
The platform line separator. |
static java.lang.String |
PROPERTIES_FILE_EXTENSION
The standard extension for properties files. |
protected static java.util.Map<org.eclipse.emf.ecore.resource.Resource,java.util.Map<java.util.Locale,java.util.ResourceBundle>> |
RESOURCE_BUNDLES
A cache of resource bundles. |
static java.lang.String |
URI_SCHEME_PLATFORM
The scheme for platform URIs. |
static java.lang.String |
URI_SEGMENT_PLUGIN
The first segment for platform plugin URIs. |
static java.lang.String |
URI_SEGMENT_RESOURCE
The first segment for platform resource URIs. |
Constructor Summary | |
---|---|
protected |
UML2Util()
|
Method Summary | ||
---|---|---|
protected static boolean |
addConstraint(org.eclipse.emf.ecore.EModelElement eModelElement,
java.lang.String constraint)
|
|
protected static void |
addDocumentation(org.eclipse.emf.ecore.EModelElement eModelElement,
java.lang.String text)
|
|
static org.eclipse.emf.ecore.EAnnotation |
createEAnnotation(org.eclipse.emf.ecore.EModelElement eModelElement,
java.lang.String source)
Creates an annotation with the specified source on the specified model element. |
|
protected static void |
destroy(org.eclipse.emf.ecore.EObject eObject)
|
|
protected static void |
destroyAll(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects)
|
|
static org.eclipse.emf.ecore.EObject |
findEObject(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects,
UML2Util.EObjectMatcher filter)
Retrieves the first of the specified objects that matches the criteria used by the specified matcher. |
|
static org.eclipse.emf.ecore.EObject |
findEObject(java.util.Iterator<? extends org.eclipse.emf.ecore.EObject> iterator,
UML2Util.EObjectMatcher filter)
Retrieves the first of the specified objects that matches the criteria used by the specified matcher. |
|
static
|
getAllContents(org.eclipse.emf.ecore.EObject eObject,
boolean includeRoot,
boolean defensiveCopy)
Retrieves an iterator over the content tree of the specified object which optionally includes the root object and/or copies contents while iterating. |
|
protected static org.eclipse.emf.ecore.EClassifier |
getCommonEType(org.eclipse.emf.ecore.EClassifier eType,
org.eclipse.emf.ecore.EClassifier otherEType)
|
|
static org.eclipse.emf.ecore.EAnnotation |
getEAnnotation(org.eclipse.emf.ecore.EModelElement eModelElement,
java.lang.String source,
boolean createOnDemand)
Retrieves the annotation with the specified source on the specified model element, optionally creating one on demand if no such annotation exists. |
|
protected static int |
getGreaterUpperBound(int upperBound,
int otherUpperBound)
|
|
static int |
getInstanceCount(java.util.Iterator<?> iterator,
org.eclipse.emf.ecore.EClassifier eClassifier)
Counts the number of instances of the specified classifier. |
|
static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> |
getInverseReferences(org.eclipse.emf.ecore.EObject eObject)
Retrieves a collection of inverse references to the specified object. |
|
protected static int |
getLesserLowerBound(int lowerBound,
int otherLowerBound)
|
|
protected static java.lang.String |
getMessageSubstitution(java.util.Map<java.lang.Object,java.lang.Object> context,
java.lang.Object object)
|
|
protected static java.lang.Object[] |
getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context,
java.lang.Object object0)
|
|
protected static java.lang.Object[] |
getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context,
java.lang.Object object0,
java.lang.Object object1)
|
|
protected static java.lang.Object[] |
getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context,
java.lang.Object object0,
java.lang.Object object1,
java.lang.Object object2)
|
|
static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> |
getNonNavigableInverseReferences(org.eclipse.emf.ecore.EObject eObject)
Retrieves a collection of non-navigable inverse references to the specified object. |
|
static java.lang.String |
getQualifiedText(org.eclipse.emf.ecore.EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider)
Retrieves a qualified textual representation of the specified object using the specified qualified text provider. |
|
protected static java.lang.StringBuffer |
getQualifiedText(org.eclipse.emf.ecore.EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider,
java.lang.StringBuffer qualifiedText)
|
|
protected static java.lang.StringBuffer |
getQualifiedTextSegment(org.eclipse.emf.ecore.EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider,
java.lang.StringBuffer qualifiedText)
|
|
protected static java.util.ResourceBundle |
getResourceBundle(org.eclipse.emf.ecore.EObject eObject,
boolean localize)
Retrieves the (cached) resource bundle for the specified object, localized in the default locale if indicated. |
|
protected static java.util.ResourceBundle |
getResourceBundle(org.eclipse.emf.ecore.EObject eObject,
java.util.Locale locale)
Retrieves the (cached) resource bundle for the specified object in the specified locale (if specified). |
|
protected static java.util.List<org.eclipse.emf.common.util.URI> |
getResourceBundleURIs(org.eclipse.emf.common.util.URI uri,
java.util.Locale locale)
Retrieves the candidate resource bundle URIs for the specified URI in the specified locale (if specified). |
|
protected static java.util.List<org.eclipse.emf.common.util.URI> |
getResourceBundleURIs(org.eclipse.emf.common.util.URI baseURI,
java.util.Locale locale,
java.lang.String baseSegment)
Retrieves the candidate resource bundle URIs based on the specified base URI and base segment in the specified locale. |
|
protected static java.util.Collection<org.eclipse.emf.ecore.EObject> |
getRootContainers(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects)
|
|
protected static java.lang.String |
getString(org.eclipse.emf.ecore.EObject eObject,
java.lang.String key,
java.lang.String defaultString,
boolean localize)
Retrieves a string for the specified object, localized if indicated. |
|
static java.lang.String |
getValidJavaIdentifier(java.lang.String name)
Obtains a valid Java identifier based on the specified name. |
|
protected static java.lang.StringBuffer |
getValidJavaIdentifier(java.lang.String name,
java.lang.StringBuffer validJavaIdentifier)
Appends a valid Java identifier based on the specified name to the specified buffer. |
|
protected static java.lang.String |
getValidNCName(java.lang.String name)
|
|
protected static java.lang.StringBuffer |
getValidNCName(java.lang.String name,
java.lang.StringBuffer validNCName)
|
|
static java.lang.String |
getXMIIdentifier(org.eclipse.emf.ecore.InternalEObject internalEObject)
Obtains a valid XMI identifier for the specified object based on the URI fragment segments of its containment hierarchy. |
|
protected static java.lang.StringBuffer |
getXMIIdentifier(org.eclipse.emf.ecore.InternalEObject internalEObject,
java.lang.StringBuffer xmiIdentifier)
|
|
protected static boolean |
intersect(java.util.Collection<?> collection,
java.util.Collection<?> otherCollection)
|
|
static boolean |
isEmpty(java.lang.String string)
Determines whether the specified string is empty, i.e. is null or has a length of zero. |
|
protected static boolean |
isNCNamePart(char c)
|
|
protected static boolean |
isNCNameStart(char c)
|
|
static
|
load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
org.eclipse.emf.ecore.EClass eClass)
Loads a resource with the specified URI into the specified resource set and retrieves the first instance of the specified class from its contents. |
|
static
|
loadClassFromSystemProperty(java.lang.String systemProperty)
Load a class from the specified system property. |
|
protected static void |
removeReferences(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.EObject ancestorEObject)
|
|
static boolean |
safeEquals(java.lang.Object object,
java.lang.Object otherObject)
Safely determines whether object equals
otherObject , i.e. without throwing an exception if
object is null . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.eclipse.emf.ecore.resource.URIConverter DEFAULT_URI_CONVERTER
protected static final java.util.Map<org.eclipse.emf.ecore.resource.Resource,java.util.Map<java.util.Locale,java.util.ResourceBundle>> RESOURCE_BUNDLES
public static final java.lang.String EMPTY_STRING
protected static final java.lang.String LINE_SEPARATOR
public static final java.lang.String URI_SCHEME_PLATFORM
public static final java.lang.String URI_SEGMENT_PLUGIN
public static final java.lang.String URI_SEGMENT_RESOURCE
public static final java.lang.String PROPERTIES_FILE_EXTENSION
Constructor Detail |
---|
protected UML2Util()
Method Detail |
---|
protected static java.util.List<org.eclipse.emf.common.util.URI> getResourceBundleURIs(org.eclipse.emf.common.util.URI baseURI, java.util.Locale locale, java.lang.String baseSegment)
baseURI
- The base URI (i.e. without the last segment) for the candidate
resource bundle URIs.locale
- The locale within which to base the candidate resource bundle
URIs.baseSegment
- The base segment (i.e. the last segment without the extension)
for the candidate resource bundle URIs.
protected static java.util.List<org.eclipse.emf.common.util.URI> getResourceBundleURIs(org.eclipse.emf.common.util.URI uri, java.util.Locale locale)
uri
- The URI upon which to base the candidate resource bundle URIs.locale
- The locale within which to base the candidate resource bundle
URIs, or null
.
protected static java.util.ResourceBundle getResourceBundle(org.eclipse.emf.ecore.EObject eObject, java.util.Locale locale)
eObject
- The object for which to retrieve the resource bundle.locale
- The locale in which to retrieve the resource bundle, or
null
.
protected static java.util.ResourceBundle getResourceBundle(org.eclipse.emf.ecore.EObject eObject, boolean localize)
eObject
- The object for which to retrieve the resource bundle.localize
- Whether to retrieve the resource bundle based on (the default)
locale.
protected static java.lang.String getString(org.eclipse.emf.ecore.EObject eObject, java.lang.String key, java.lang.String defaultString, boolean localize)
eObject
- The object for which to retrieve a (localized) string.key
- The key in the resource bundle.defaultString
- The string to return if no string for the given key can be
found.localize
- Whether the string should be localized.
public static java.lang.String getQualifiedText(org.eclipse.emf.ecore.EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider)
eObject
- The object for which to retrieve qualified text.qualifiedTextProvider
- The provider to be used.
protected static java.lang.StringBuffer getQualifiedText(org.eclipse.emf.ecore.EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, java.lang.StringBuffer qualifiedText)
protected static java.lang.StringBuffer getQualifiedTextSegment(org.eclipse.emf.ecore.EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, java.lang.StringBuffer qualifiedText)
protected static java.lang.String getMessageSubstitution(java.util.Map<java.lang.Object,java.lang.Object> context, java.lang.Object object)
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context, java.lang.Object object0)
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context, java.lang.Object object0, java.lang.Object object1)
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map<java.lang.Object,java.lang.Object> context, java.lang.Object object0, java.lang.Object object1, java.lang.Object object2)
public static boolean safeEquals(java.lang.Object object, java.lang.Object otherObject)
object
equals
otherObject
, i.e. without throwing an exception if
object
is null
.
object
- The first object to compare.otherObject
- The second object to compare.
true
if object
equals
otherObject
; false
otherwise.public static boolean isEmpty(java.lang.String string)
null
or has a length of zero.
string
- The string in question.
true
if the string is empty; false
otherwise.public static org.eclipse.emf.ecore.EObject findEObject(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects, UML2Util.EObjectMatcher filter)
eObjects
- The collection of candidate objects.filter
- The matcher to be used.
public static org.eclipse.emf.ecore.EObject findEObject(java.util.Iterator<? extends org.eclipse.emf.ecore.EObject> iterator, UML2Util.EObjectMatcher filter)
iterator
- The iterator for the candidate objects.filter
- The matcher to be used.
protected static org.eclipse.emf.ecore.EClassifier getCommonEType(org.eclipse.emf.ecore.EClassifier eType, org.eclipse.emf.ecore.EClassifier otherEType)
protected static int getLesserLowerBound(int lowerBound, int otherLowerBound)
protected static int getGreaterUpperBound(int upperBound, int otherUpperBound)
public static java.lang.String getValidJavaIdentifier(java.lang.String name)
name
- The name from which to obtain a valid identifier.
protected static java.lang.StringBuffer getValidJavaIdentifier(java.lang.String name, java.lang.StringBuffer validJavaIdentifier)
name
- The name from which to obtain the valid identifier.validJavaIdentifier
- The buffer to which to append the valid identifier.
protected static boolean isNCNameStart(char c)
protected static boolean isNCNamePart(char c)
protected static java.lang.String getValidNCName(java.lang.String name)
protected static java.lang.StringBuffer getValidNCName(java.lang.String name, java.lang.StringBuffer validNCName)
public static java.lang.String getXMIIdentifier(org.eclipse.emf.ecore.InternalEObject internalEObject)
internalEObject
- The object for which to obtain an XMI identifier.
protected static java.lang.StringBuffer getXMIIdentifier(org.eclipse.emf.ecore.InternalEObject internalEObject, java.lang.StringBuffer xmiIdentifier)
public static int getInstanceCount(java.util.Iterator<?> iterator, org.eclipse.emf.ecore.EClassifier eClassifier)
iterator
- The iterator for the candidate objects.eClassifier
- The classifier in question.
protected static boolean addConstraint(org.eclipse.emf.ecore.EModelElement eModelElement, java.lang.String constraint)
protected static void addDocumentation(org.eclipse.emf.ecore.EModelElement eModelElement, java.lang.String text)
protected static java.util.Collection<org.eclipse.emf.ecore.EObject> getRootContainers(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects)
public static <T> org.eclipse.emf.common.util.TreeIterator<T> getAllContents(org.eclipse.emf.ecore.EObject eObject, boolean includeRoot, boolean defensiveCopy)
eObject
- The root of the content hierarchy.includeRoot
- Whether to include the root object.defensiveCopy
- Whether to copy contents while iterating.
public static org.eclipse.emf.ecore.EAnnotation createEAnnotation(org.eclipse.emf.ecore.EModelElement eModelElement, java.lang.String source)
eModelElement
- The model element on which to create the annotation.source
- The source for the new annotation.
public static org.eclipse.emf.ecore.EAnnotation getEAnnotation(org.eclipse.emf.ecore.EModelElement eModelElement, java.lang.String source, boolean createOnDemand)
eModelElement
- The model element from/on which to retrieve/create the
annotation.source
- The source for the (new) annotation.createOnDemand
- Whether to create one if no such annotation exists.
public static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> getNonNavigableInverseReferences(org.eclipse.emf.ecore.EObject eObject)
eObject
- The referenced object.
public static java.util.Collection<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences(org.eclipse.emf.ecore.EObject eObject)
eObject
- The referenced object.
protected static void removeReferences(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.EObject ancestorEObject)
protected static void destroy(org.eclipse.emf.ecore.EObject eObject)
protected static void destroyAll(java.util.Collection<? extends org.eclipse.emf.ecore.EObject> eObjects)
public static <T> T load(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.EClass eClass)
resourceSet
- The resource set into which to load the resource.uri
- The URI of the resource to be loaded.eClass
- The class of the object to be retrieved.
protected static boolean intersect(java.util.Collection<?> collection, java.util.Collection<?> otherCollection)
public static <T> T loadClassFromSystemProperty(java.lang.String systemProperty)
systemProperty
- The system property containing the location of the class to be loaded.
|
Copyright 2003, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |