/** * Obtains a valid Java identifier based on the specified name. * * @param name * The name from which to obtain a valid identifier. * @return A valid (Java) identifier. */ public static String getValidJavaIdentifier(String name) { return getValidJavaIdentifier(name, new StringBuffer()).toString(); }
protected static StringBuffer getValidNCName(String name, StringBuffer validNCName) { if (isEmpty(name)) { validNCName.insert(0, '_'); } else { for (int i = name.length(); --i > 0;) { char char_i = name.charAt(i); if (isNCNamePart(char_i)) { validNCName.insert(0, char_i); } } char char_0 = name.charAt(0); if (isNCNameStart(char_0)) { validNCName.insert(0, char_0); } else { if (isNCNamePart(char_0)) { validNCName.insert(0, char_0); } validNCName.insert(0, '_'); } } return validNCName; }
private static CacheAdapter createCacheAdapter() { CacheAdapter cacheAdapter = UML2Util .loadClassFromSystemProperty("org.eclipse.uml2.common.util.CacheAdapter.INSTANCE"); //$NON-NLS-1$ if (cacheAdapter != null) { return cacheAdapter; } return new CacheAdapter(); }
protected static void destroy(EObject eObject) { if (eObject.eContents().isEmpty()) { removeReferences(eObject, eObject); eObject.eAdapters().clear(); } else { for (Iterator<EObject> allContents = getAllContents(eObject, true, false); allContents.hasNext();) { removeReferences(allContents.next(), eObject); } for (Iterator<EObject> allContents = getAllContents(eObject, true, false); allContents.hasNext();) { (allContents.next()).eAdapters().clear(); } } EcoreUtil.remove(eObject); }
protected static boolean addConstraint(EModelElement eModelElement, String constraint) { if (isEmpty(constraint)) { return false; } else { List<String> constraints = new ArrayList<String>(EcoreUtil .getConstraints(eModelElement)); boolean result = constraints.add(constraint); EcoreUtil.setConstraints(eModelElement, constraints); return result; } }
String version = details.get("version"); //$NON-NLS-1$ if (!UML2Util.isEmpty(version)) { Profile appliedProfile = profileApplication .getAppliedProfile(); .endsWith( UML2Util .getValidJavaIdentifier(profileName) + '_' + version)) {
/** * Performs a reverse-reference lookup for slots that have * <code>InstanceValue</code>s referencing the specified instance * specification. * * @param instance * an instance specification * @return the slots referencing it (or an empty collection if none) */ private Collection<Slot> getSlotsReferencing(InstanceSpecification instance) { Collection<Slot> result = CollectionUtil.createNewSet(); for (EStructuralFeature.Setting setting : UML2Util .getNonNavigableInverseReferences(instance)) { if (setting.getEStructuralFeature() == UMLPackage.Literals.INSTANCE_VALUE__INSTANCE) { InstanceValue value = (InstanceValue) setting.getEObject(); if (value.getOwner() instanceof Slot) { result.add((Slot) value.getOwner()); } } } return result; }
return getQualifiedText(eObject, qualifiedTestProvider); messageSubstitution.append(getMessageSubstitution(context, element));
boolean ignoreCase, EClass eClass) { if (!isEmpty(qualifiedName) && EcorePackage.Literals.ENAMED_ELEMENT.isSuperTypeOf(eClass)) { findENamedElements(resources.get(i).getContents(), qualifiedName, separator, ignoreCase, eClass, eNamedElements);
@Override public boolean matches(EObject otherEObject) { return super.matches(otherEObject) && safeEquals(eObject.eGet(eStructuralFeature), otherEObject .eGet(eStructuralFeature)); } }
protected static Object[] getMessageSubstitutions( Map<Object, Object> context, Object object0, Object object1, Object object2) { return new Object[]{getMessageSubstitution(context, object0), getMessageSubstitution(context, object1), getMessageSubstitution(context, object2)}; }
protected static void destroyAll(Collection<? extends EObject> eObjects) { for (Iterator<? extends EObject> o = eObjects.iterator(); o.hasNext();) { destroy(o.next()); } }
/** * Retrieves the first of the specified objects that matches the criteria * used by the specified matcher. * * @param eObjects * The collection of candidate objects. * @param filter * The matcher to be used. * @return The first object that matches the criteria. */ public static EObject findEObject(Collection<? extends EObject> eObjects, EObjectMatcher filter) { return findEObject(eObjects.iterator(), filter); }
/** * Retrieves the annotation with the specified source on the specified model * element, optionally creating one on demand if no such annotation exists. * * @param eModelElement * The model element from/on which to retrieve/create the * annotation. * @param source * The source for the (new) annotation. * @param createOnDemand * Whether to create one if no such annotation exists. * @return The (new) annotation. */ public static EAnnotation getEAnnotation(EModelElement eModelElement, String source, boolean createOnDemand) { EAnnotation eAnnotation = eModelElement.getEAnnotation(source); return eAnnotation == null && createOnDemand ? createEAnnotation(eModelElement, source) : eAnnotation; }
protected static boolean addInvocationDelegate(EPackage ePackage, String invocationDelegate) { boolean result = false; if (!isEmpty(invocationDelegate)) { List<String> invocationDelegates = EcoreUtil .getInvocationDelegates(ePackage); if (!invocationDelegates.contains(invocationDelegate)) { result = (invocationDelegates = new ArrayList<String>( invocationDelegates)).add(invocationDelegate); EcoreUtil.setInvocationDelegates(ePackage, invocationDelegates); } } return result; }
protected static void destroy(EObject eObject) { if (eObject.eContents().isEmpty()) { removeReferences(eObject, eObject); eObject.eAdapters().clear(); } else { for (Iterator<EObject> allContents = getAllContents(eObject, true, false); allContents.hasNext();) { removeReferences(allContents.next(), eObject); } for (Iterator<EObject> allContents = getAllContents(eObject, true, false); allContents.hasNext();) { (allContents.next()).eAdapters().clear(); } } EcoreUtil.remove(eObject); }
return getQualifiedText(eObject, qualifiedTestProvider); messageSubstitution.append(getMessageSubstitution(context, element));
/** * Queries whether the specified <code>instance</code> has slots for the * given <code>properties</code> that have these <code>values</code>. * * @param instance * an instance specification * @param properties * a list of properties * @param values * values to look for in the slots of the instance defined by the * given properties * * @return <code>true</code> if this instance has the matching property * values; <code>false</code>, otherwise */ private boolean match(InstanceSpecification instance, List<Property> properties, List<?> values) { int found = 0; for (Slot slot : instance.getSlots()) { int index = properties.indexOf(slot.getDefiningFeature()); if (index >= 0) { Object actualValue = getValue(slot); if (UML2Util.safeEquals(actualValue, values.get(index))) { found++; } } } return found == properties.size(); }
public static Object[] getMessageSubstitutions(Map<Object, Object> context, Object object0, Object object1, Object object2) { return new Object[]{getMessageSubstitution(context, object0), getMessageSubstitution(context, object1), getMessageSubstitution(context, object2)}; }