|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.uml2.common.util.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 URIConverter |
DEFAULT_URI_CONVERTER
The default URI converter for resource bundle look-ups. |
static String |
EMPTY_STRING
The empty string. |
protected static String |
LINE_SEPARATOR
The platform line separator. |
static String |
PROPERTIES_FILE_EXTENSION
The standard extension for properties files. |
protected static Map |
RESOURCE_BUNDLES
A cache of resource bundles. |
static String |
URI_SCHEME_PLATFORM
The scheme for platform URIs. |
static String |
URI_SEGMENT_PLUGIN
The first segment for platform plugin URIs. |
static String |
URI_SEGMENT_RESOURCE
The first segment for platform resource URIs. |
Constructor Summary | |
protected |
UML2Util()
|
Method Summary | |
protected static boolean |
addConstraint(EModelElement eModelElement,
String constraint)
|
protected static void |
addDocumentation(EModelElement eModelElement,
String text)
|
static EAnnotation |
createEAnnotation(EModelElement eModelElement,
String source)
Creates an annotation with the specified source on the specified model element. |
protected static void |
destroy(EObject eObject)
|
protected static void |
destroyAll(Collection eObjects)
|
static EObject |
findEObject(Collection eObjects,
UML2Util.EObjectMatcher filter)
Retrieves the first of the specified objects that matches the criteria used by the specified matcher. |
static EObject |
findEObject(Iterator iterator,
UML2Util.EObjectMatcher filter)
Retrieves the first of the specified objects that matches the criteria used by the specified matcher. |
static TreeIterator |
getAllContents(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 EClassifier |
getCommonEType(EClassifier eType,
EClassifier otherEType)
|
static EAnnotation |
getEAnnotation(EModelElement eModelElement,
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(Iterator iterator,
EClassifier eClassifier)
Counts the number of instances of the specified classifier. |
static Collection |
getInverseReferences(EObject eObject)
Retrieves a collection of inverse references to the specified object. |
protected static int |
getLesserLowerBound(int lowerBound,
int otherLowerBound)
|
protected static String |
getMessageSubstitution(Map context,
Object object)
|
protected static Object[] |
getMessageSubstitutions(Map context,
Object object0)
|
protected static Object[] |
getMessageSubstitutions(Map context,
Object object0,
Object object1)
|
protected static Object[] |
getMessageSubstitutions(Map context,
Object object0,
Object object1,
Object object2)
|
static Collection |
getNonNavigableInverseReferences(EObject eObject)
Retrieves a collection of non-navigable inverse references to the specified object. |
static String |
getQualifiedText(EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider)
Retrieves a qualified textual representation of the specified object using the specified qualified text provider. |
protected static StringBuffer |
getQualifiedText(EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider,
StringBuffer qualifiedText)
|
protected static StringBuffer |
getQualifiedTextSegment(EObject eObject,
UML2Util.QualifiedTextProvider qualifiedTextProvider,
StringBuffer qualifiedText)
|
protected static ResourceBundle |
getResourceBundle(EObject eObject,
boolean localize)
Retrieves the (cached) resource bundle for the specified object, localized in the default locale if indicated. |
protected static ResourceBundle |
getResourceBundle(EObject eObject,
Locale locale)
Retrieves the (cached) resource bundle for the specified object in the specified locale (if specified). |
protected static List |
getResourceBundleURIs(URI uri,
Locale locale)
Retrieves the candidate resource bundle URIs for the specified URI in the specified locale (if specified). |
protected static List |
getResourceBundleURIs(URI baseURI,
Locale locale,
String baseSegment)
Retrieves the candidate resource bundle URIs based on the specified base URI and base segment in the specified locale. |
protected static Collection |
getRootContainers(Collection eObjects)
|
protected static String |
getString(EObject eObject,
String key,
String defaultString,
boolean localize)
Retrieves a string for the specified object, localized if indicated. |
static String |
getValidJavaIdentifier(String name)
Obtains a valid Java identifier based on the specified name. |
protected static StringBuffer |
getValidJavaIdentifier(String name,
StringBuffer validJavaIdentifier)
Appends a valid Java identifier based on the specified name to the specified buffer. |
protected static String |
getValidNCName(String name)
|
protected static StringBuffer |
getValidNCName(String name,
StringBuffer validNCName)
|
static String |
getXMIIdentifier(InternalEObject internalEObject)
Obtains a valid XMI identifier for the specified object based on the URI fragment segments of its containment hierarchy. |
protected static StringBuffer |
getXMIIdentifier(InternalEObject internalEObject,
StringBuffer xmiIdentifier)
|
protected static boolean |
intersect(Collection collection,
Collection otherCollection)
|
static boolean |
isEmpty(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 Object |
load(ResourceSet resourceSet,
URI uri,
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. |
protected static void |
removeReferences(EObject eObject,
EObject ancestorEObject)
|
static boolean |
safeEquals(Object object,
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 URIConverter DEFAULT_URI_CONVERTER
protected static final Map RESOURCE_BUNDLES
public static final String EMPTY_STRING
protected static final String LINE_SEPARATOR
public static final String URI_SCHEME_PLATFORM
public static final String URI_SEGMENT_PLUGIN
public static final String URI_SEGMENT_RESOURCE
public static final String PROPERTIES_FILE_EXTENSION
Constructor Detail |
protected UML2Util()
Method Detail |
protected static List getResourceBundleURIs(URI baseURI, Locale locale, 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 List getResourceBundleURIs(URI uri, 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 ResourceBundle getResourceBundle(EObject eObject, 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 ResourceBundle getResourceBundle(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 String getString(EObject eObject, String key, String defaultString, boolean localize)
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 String getQualifiedText(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider)
eObject
- The object for which to retrieve qualified text.qualifiedTextProvider
- The provider to be used.
protected static StringBuffer getQualifiedText(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, StringBuffer qualifiedText)
protected static StringBuffer getQualifiedTextSegment(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, StringBuffer qualifiedText)
protected static String getMessageSubstitution(Map context, Object object)
protected static Object[] getMessageSubstitutions(Map context, Object object0)
protected static Object[] getMessageSubstitutions(Map context, Object object0, Object object1)
protected static Object[] getMessageSubstitutions(Map context, Object object0, Object object1, Object object2)
public static boolean safeEquals(Object object, 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(String string)
null
or has a length of zero.
string
- The string in question.
true
if the string is empty; false
otherwise.public static EObject findEObject(Collection eObjects, UML2Util.EObjectMatcher filter)
eObjects
- The collection of candidate objects.filter
- The matcher to be used.
public static EObject findEObject(Iterator iterator, UML2Util.EObjectMatcher filter)
iterator
- The iterator for the candidate objects.filter
- The matcher to be used.
protected static EClassifier getCommonEType(EClassifier eType, EClassifier otherEType)
protected static int getLesserLowerBound(int lowerBound, int otherLowerBound)
protected static int getGreaterUpperBound(int upperBound, int otherUpperBound)
public static String getValidJavaIdentifier(String name)
name
- The name from which to obtain a valid identifier.
protected static StringBuffer getValidJavaIdentifier(String name, 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 String getValidNCName(String name)
protected static StringBuffer getValidNCName(String name, StringBuffer validNCName)
public static String getXMIIdentifier(InternalEObject internalEObject)
internalEObject
- The object for which to obtain an XMI identifier.
protected static StringBuffer getXMIIdentifier(InternalEObject internalEObject, StringBuffer xmiIdentifier)
public static int getInstanceCount(Iterator iterator, EClassifier eClassifier)
iterator
- The iterator for the candidate objects.eClassifier
- The classifier in question.
protected static boolean addConstraint(EModelElement eModelElement, String constraint)
protected static void addDocumentation(EModelElement eModelElement, String text)
protected static Collection getRootContainers(Collection eObjects)
public static TreeIterator getAllContents(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 EAnnotation createEAnnotation(EModelElement eModelElement, String source)
eModelElement
- The model element on which to create the annotation.source
- The source for the new annotation.
public static EAnnotation getEAnnotation(EModelElement eModelElement, 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 Collection getNonNavigableInverseReferences(EObject eObject)
eObject
- The referenced object.
public static Collection getInverseReferences(EObject eObject)
eObject
- The referenced object.
protected static void removeReferences(EObject eObject, EObject ancestorEObject)
protected static void destroy(EObject eObject)
protected static void destroyAll(Collection eObjects)
public static Object load(ResourceSet resourceSet, URI uri, 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(Collection collection, Collection otherCollection)
|
Copyright 2003, 2006 IBM Corporation and others. All Rights Reserved. |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |