org.eclipse.uml2.common.util
Class UML2Util

java.lang.Object
  extended byorg.eclipse.uml2.common.util.UML2Util
Direct Known Subclasses:
UMLUtil

public class UML2Util
extends java.lang.Object

Since:
1.2

Nested Class Summary
static interface UML2Util.Converter
           
static class UML2Util.EClassMatcher
           
static interface UML2Util.EObjectMatcher
           
static class UML2Util.EStructuralFeatureMatcher
           
static class UML2Util.QualifiedTextProvider
           
 
Field Summary
protected static 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 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(EModelElement eModelElement, java.lang.String constraint)
           
protected static void addDocumentation(EModelElement eModelElement, java.lang.String text)
           
static EAnnotation createEAnnotation(EModelElement eModelElement, java.lang.String source)
           
protected static void destroy(EObject eObject)
           
protected static void destroyAll(java.util.Collection eObjects)
           
static EObject findEObject(java.util.Collection eObjects, UML2Util.EObjectMatcher filter)
           
static EObject findEObject(java.util.Iterator iterator, UML2Util.EObjectMatcher filter)
           
static TreeIterator getAllContents(EObject eObject, boolean includeRoot, boolean defensiveCopy)
           
protected static EClassifier getCommonEType(EClassifier eType, EClassifier otherEType)
           
static EAnnotation getEAnnotation(EModelElement eModelElement, java.lang.String source, boolean createOnDemand)
           
protected static int getGreaterUpperBound(int upperBound, int otherUpperBound)
           
static int getInstanceCount(java.util.Iterator iterator, EClassifier eClassifier)
           
static java.util.Collection getInverseReferences(EObject eObject)
           
protected static int getLesserLowerBound(int lowerBound, int otherLowerBound)
           
protected static java.lang.String getMessageSubstitution(java.util.Map context, java.lang.Object object)
           
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context, java.lang.Object object0)
           
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context, java.lang.Object object0, java.lang.Object object1)
           
protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context, java.lang.Object object0, java.lang.Object object1, java.lang.Object object2)
           
static java.util.Collection getNonNavigableInverseReferences(EObject eObject)
           
static java.lang.String getQualifiedText(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider)
           
protected static java.lang.StringBuffer getQualifiedText(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, java.lang.StringBuffer qualifiedText)
           
protected static java.lang.StringBuffer getQualifiedTextSegment(EObject eObject, UML2Util.QualifiedTextProvider qualifiedTextProvider, java.lang.StringBuffer qualifiedText)
           
protected static java.util.ResourceBundle getResourceBundle(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(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 getResourceBundleURIs(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 getResourceBundleURIs(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 getRootContainers(java.util.Collection eObjects)
           
protected static java.lang.String getString(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(InternalEObject internalEObject)
           
protected static java.lang.StringBuffer getXMIIdentifier(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)
           
protected static boolean isNCNamePart(char c)
           
protected static boolean isNCNameStart(char c)
           
static java.lang.Object load(ResourceSet resourceSet, URI uri, EClass eClass)
           
static boolean safeEquals(java.lang.Object object, java.lang.Object otherObject)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_URI_CONVERTER

protected static final URIConverter DEFAULT_URI_CONVERTER
The default URI converter for resource bundle look-ups.


RESOURCE_BUNDLES

protected static final java.util.Map RESOURCE_BUNDLES
A cache of resource bundles.


EMPTY_STRING

public static final java.lang.String EMPTY_STRING
The empty string.

See Also:
Constant Field Values

LINE_SEPARATOR

protected static final java.lang.String LINE_SEPARATOR
The platform line separator.


URI_SCHEME_PLATFORM

public static final java.lang.String URI_SCHEME_PLATFORM
The scheme for platform URIs.

See Also:
Constant Field Values

URI_SEGMENT_PLUGIN

public static final java.lang.String URI_SEGMENT_PLUGIN
The first segment for platform plugin URIs.

See Also:
Constant Field Values

URI_SEGMENT_RESOURCE

public static final java.lang.String URI_SEGMENT_RESOURCE
The first segment for platform resource URIs.

See Also:
Constant Field Values

PROPERTIES_FILE_EXTENSION

public static final java.lang.String PROPERTIES_FILE_EXTENSION
The standard extension for properties files.

See Also:
Constant Field Values
Constructor Detail

UML2Util

protected UML2Util()
Method Detail

getResourceBundleURIs

protected static java.util.List getResourceBundleURIs(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.

Parameters:
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.
Returns:
The candidate resource bundle URIs with the base URI and base segment in the locale.

getResourceBundleURIs

protected static java.util.List getResourceBundleURIs(URI uri,
                                                      java.util.Locale locale)
Retrieves the candidate resource bundle URIs for the specified URI in the specified locale (if specified).

Parameters:
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.
Returns:
The candidate resource bundle URIs for the URI in the locale (if specified).

getResourceBundle

protected static java.util.ResourceBundle getResourceBundle(EObject eObject,
                                                            java.util.Locale locale)
Retrieves the (cached) resource bundle for the specified object in the specified locale (if specified).

Parameters:
eObject - The object for which to retrieve the resource bundle.
locale - The locale in which to retrieve the resource bundle, or null.
Returns:
The resource bundle for the object in the locale (if specified).

getResourceBundle

protected static java.util.ResourceBundle getResourceBundle(EObject eObject,
                                                            boolean localize)
Retrieves the (cached) resource bundle for the specified object, localized in the default locale if indicated.

Parameters:
eObject - The object for which to retrieve the resource bundle.
localize - Whether to retrieve the resource bundle based on (the default) locale.
Returns:
The resource bundle for the object (in the default locale).

getString

protected static java.lang.String getString(EObject eObject,
                                            java.lang.String key,
                                            java.lang.String defaultString,
                                            boolean localize)
Retrieves a string for the specified object, localized if indicated.

Parameters:
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.
Returns:
The (localized) string.

getQualifiedText

public static java.lang.String getQualifiedText(EObject eObject,
                                                UML2Util.QualifiedTextProvider qualifiedTextProvider)

getQualifiedText

protected static java.lang.StringBuffer getQualifiedText(EObject eObject,
                                                         UML2Util.QualifiedTextProvider qualifiedTextProvider,
                                                         java.lang.StringBuffer qualifiedText)

getQualifiedTextSegment

protected static java.lang.StringBuffer getQualifiedTextSegment(EObject eObject,
                                                                UML2Util.QualifiedTextProvider qualifiedTextProvider,
                                                                java.lang.StringBuffer qualifiedText)

getMessageSubstitution

protected static java.lang.String getMessageSubstitution(java.util.Map context,
                                                         java.lang.Object object)

getMessageSubstitutions

protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context,
                                                            java.lang.Object object0)

getMessageSubstitutions

protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context,
                                                            java.lang.Object object0,
                                                            java.lang.Object object1)

getMessageSubstitutions

protected static java.lang.Object[] getMessageSubstitutions(java.util.Map context,
                                                            java.lang.Object object0,
                                                            java.lang.Object object1,
                                                            java.lang.Object object2)

safeEquals

public static boolean safeEquals(java.lang.Object object,
                                 java.lang.Object otherObject)

isEmpty

public static boolean isEmpty(java.lang.String string)

findEObject

public static EObject findEObject(java.util.Collection eObjects,
                                  UML2Util.EObjectMatcher filter)

findEObject

public static EObject findEObject(java.util.Iterator iterator,
                                  UML2Util.EObjectMatcher filter)

getCommonEType

protected static EClassifier getCommonEType(EClassifier eType,
                                            EClassifier otherEType)

getLesserLowerBound

protected static int getLesserLowerBound(int lowerBound,
                                         int otherLowerBound)

getGreaterUpperBound

protected static int getGreaterUpperBound(int upperBound,
                                          int otherUpperBound)

getValidJavaIdentifier

public static java.lang.String getValidJavaIdentifier(java.lang.String name)
Obtains a valid Java identifier based on the specified name.

Parameters:
name - The name from which to obtain a valid identifier.
Returns:
A valid (Java) identifier.

getValidJavaIdentifier

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.

Parameters:
name - The name from which to obtain the valid identifier.
validJavaIdentifier - The buffer to which to append the valid identifier.
Returns:
The buffer.

isNCNameStart

protected static boolean isNCNameStart(char c)

isNCNamePart

protected static boolean isNCNamePart(char c)

getValidNCName

protected static java.lang.String getValidNCName(java.lang.String name)

getValidNCName

protected static java.lang.StringBuffer getValidNCName(java.lang.String name,
                                                       java.lang.StringBuffer validNCName)

getXMIIdentifier

public static java.lang.String getXMIIdentifier(InternalEObject internalEObject)

getXMIIdentifier

protected static java.lang.StringBuffer getXMIIdentifier(InternalEObject internalEObject,
                                                         java.lang.StringBuffer xmiIdentifier)

getInstanceCount

public static int getInstanceCount(java.util.Iterator iterator,
                                   EClassifier eClassifier)

addConstraint

protected static boolean addConstraint(EModelElement eModelElement,
                                       java.lang.String constraint)

addDocumentation

protected static void addDocumentation(EModelElement eModelElement,
                                       java.lang.String text)

getRootContainers

protected static java.util.Collection getRootContainers(java.util.Collection eObjects)

getAllContents

public static TreeIterator getAllContents(EObject eObject,
                                          boolean includeRoot,
                                          boolean defensiveCopy)

createEAnnotation

public static EAnnotation createEAnnotation(EModelElement eModelElement,
                                            java.lang.String source)

getEAnnotation

public static EAnnotation getEAnnotation(EModelElement eModelElement,
                                         java.lang.String source,
                                         boolean createOnDemand)

getNonNavigableInverseReferences

public static java.util.Collection getNonNavigableInverseReferences(EObject eObject)

getInverseReferences

public static java.util.Collection getInverseReferences(EObject eObject)

destroy

protected static void destroy(EObject eObject)

destroyAll

protected static void destroyAll(java.util.Collection eObjects)

load

public static java.lang.Object load(ResourceSet resourceSet,
                                    URI uri,
                                    EClass eClass)

intersect

protected static boolean intersect(java.util.Collection collection,
                                   java.util.Collection otherCollection)

Copyright 2003, 2006 IBM Corporation and others.
All Rights Reserved.