Author: maurelio1234
Date: 2008-07-18 07:35:05-0700
New Revision: 15297
Modified:
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java
branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java
branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java
Log:
fixing style and implementing collections API
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/CoreProfileReference.java 2008-07-18 07:35:05-0700
@@ -29,34 +29,30 @@
/**
* This class provides the base referencing and URL for ArgoUML core profiles.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class CoreProfileReference extends ProfileReference {
-
- static final String PROFILES_RESOURCE_PATH =
- "/org/argouml/profile/profiles/uml14/";
-
- static final String PROFILES_BASE_URL =
- "http://argouml.org/profiles/uml14/";
+
+ static final String PROFILES_RESOURCE_PATH = "/org/argouml/profile/profiles/uml14/";
+
+ static final String PROFILES_BASE_URL = "http://argouml.org/profiles/uml14/";
/**
- * Constructor, which builds a ProfileReference for ArgoUML core profiles
- * by:
- * <li>prefixing the fileName with {@link #PROFILES_RESOURCE_PATH} and
+ * Constructor, which builds a ProfileReference for ArgoUML core profiles
+ * by:
+ * <li>prefixing the fileName with {@link #PROFILES_RESOURCE_PATH} and
* using this as the path;</li>
- * <li>and prefixing the fileName with {@link #PROFILES_BASE_URL} and
- * using this as the publicReference.</li>
+ * <li>and prefixing the fileName with {@link #PROFILES_BASE_URL} and using
+ * this as the publicReference.</li>
*
* @param fileName the profile file name.
* @throws MalformedURLException if the built URL is incorrect.
*/
public CoreProfileReference(String fileName) throws MalformedURLException {
- super(PROFILES_RESOURCE_PATH + fileName,
- new URL(PROFILES_BASE_URL + fileName));
- assert fileName != null
- : "null isn't acceptable as the profile file name.";
- assert !"".equals(fileName)
- : "the empty string isn't acceptable as the profile file name.";
+ super(PROFILES_RESOURCE_PATH + fileName, new URL(PROFILES_BASE_URL
+ + fileName));
+ assert fileName != null : "null isn't acceptable as the profile file name.";
+ assert !"".equals(fileName) : "the empty string isn't acceptable as the profile file name.";
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/DefaultTypeStrategy.java 2008-07-18 07:35:05-0700
@@ -25,9 +25,9 @@
package org.argouml.profile;
/**
- * Using this strategy profiles can provide the default used when creating new
+ * Using this strategy profiles can provide the default used when creating new
* parameters, operations and attributes.
- *
+ *
* @author maurelio1234
*/
public interface DefaultTypeStrategy {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FigNodeStrategy.java 2008-07-18 07:35:05-0700
@@ -27,20 +27,20 @@
import java.awt.Image;
/**
- * Using this strategy profiles can provide icons to replace the default
+ * Using this strategy profiles can provide icons to replace the default
* visualization of stereotyped node according to UML 2.0 specification.
- *
+ *
* @author maurelio1234
*/
public interface FigNodeStrategy {
-
+
/**
- * Returns the image of the icon that should replace the model elements
- * having this stereotype
+ * Returns the image of the icon that should replace the model elements
+ * having this stereotype
*
* @param stereotype the stereotype model element
- * @return the icon or <code>null</code> if the stereotype has no icon
+ * @return the icon or <code>null</code> if the stereotype has no icon
*/
Image getIconForStereotype(Object stereotype);
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FileModelLoader.java 2008-07-18 07:35:05-0700
@@ -33,14 +33,14 @@
/**
* An implementation for the ProfileModelLoader that loads profiles from files.
- *
+ *
* @author maurelio1234
*/
public class FileModelLoader extends URLModelLoader {
private static final Logger LOG = Logger.getLogger(FileModelLoader.class);
- public Collection loadModel(ProfileReference reference)
+ public Collection loadModel(ProfileReference reference)
throws ProfileException {
LOG.info("Loading profile from file'" + reference.getPath() + "'");
try {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/FormatingStrategy.java 2008-07-18 07:35:05-0700
@@ -30,18 +30,16 @@
* Interface for the formating strategy to be used when formating model element
* names.
*
- * @author Marcos Aurélio
+ * @author Marcos Aur�lio
*/
public interface FormatingStrategy {
-
+
/**
* Produce a string that represents the specific model element in the
* context of the specified namespace.
*
- * @param element
- * element to represent.
- * @param namespace
- * context namespace (may be null).
+ * @param element element to represent.
+ * @param namespace context namespace (may be null).
* @return a string representing the model element
*/
public abstract String formatElement(Object element, Object namespace);
@@ -50,10 +48,8 @@
* Produce a string the represents the collection of model elements in the
* context of the specified namespace.
*
- * @param iter
- * iterator over collection
- * @param namespace
- * context namespace (may be null).
+ * @param iter iterator over collection
+ * @param namespace context namespace (may be null).
* @return a string representing the collection
*/
public abstract String formatCollection(Iterator iter, Object namespace);
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/Profile.java 2008-07-18 07:35:05-0700
@@ -30,39 +30,35 @@
import org.argouml.uml.cognitive.critics.CrUML;
-
/**
- * Abstract class representing a Profile. It contains default types and
+ * Abstract class representing a Profile. It contains default types and
* presentation characteristics that can be tailored to various modeling
* environments.
*
* @author Marcos Aur�lio
*/
public abstract class Profile {
-
- private Set<String> dependencies = new HashSet<String>();
+
+ private Set<String> dependencies = new HashSet<String>();
+
protected Set<CrUML> critics = new HashSet<CrUML>();
-
+
/**
* Add a dependency on the given profile from this profile.
*
- * @param p
- * the profile
- * @throws IllegalArgumentException
- * never thrown
+ * @param p the profile
+ * @throws IllegalArgumentException never thrown
*/
protected final void addProfileDependency(Profile p)
throws IllegalArgumentException {
addProfileDependency(p.getProfileIdentifier());
- }
+ }
/**
* Add a dependency on the given profile from this profile.
*
- * @param p
- * the profile identifier
- *
- * @param profileIdentifier
+ * @param p the profile identifier
+ * @param profileIdentifier
*/
protected void addProfileDependency(String profileIdentifier) {
dependencies.add(profileIdentifier);
@@ -75,13 +71,14 @@
if (ProfileFacade.isInitiated()) {
Set<Profile> ret = new HashSet<Profile>();
for (String pid : dependencies) {
- Profile p = ProfileFacade.getManager().lookForRegisteredProfile(pid);
- if (p!=null) {
+ Profile p = ProfileFacade.getManager()
+ .lookForRegisteredProfile(pid);
+ if (p != null) {
ret.add(p);
ret.addAll(p.getDependencies());
}
}
- return ret;
+ return ret;
} else {
return new HashSet<Profile>();
}
@@ -95,10 +92,10 @@
}
/**
- * @return the name for this profile
+ * @return the name for this profile
*/
public abstract String getDisplayName();
-
+
/**
* @return the formating strategy offered by this profile, if any. Returns
* <code>null</code> if this profile has no formating strategy.
@@ -122,15 +119,14 @@
public DefaultTypeStrategy getDefaultTypeStrategy() {
return null;
}
-
+
/**
* @return a collection of the top level UML Packages containing the
* profile.
- * @throws ProfileException
- * if failed to get profile.
+ * @throws ProfileException if failed to get profile.
*/
public abstract Collection getProfilePackages() throws ProfileException;
-
+
/**
* @return the display name
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileException.java 2008-07-18 07:35:05-0700
@@ -25,9 +25,9 @@
package org.argouml.profile;
/**
- * An exception to be thrown during failure in the Profile subsystem.
- * This will typically be a wrapped exception containing the exception
- * representing the underlying failure cause.
+ * An exception to be thrown during failure in the Profile subsystem. This will
+ * typically be a wrapped exception containing the exception representing the
+ * underlying failure cause.
*
* @author Marcus Aurelio (maurelio1234)
*/
@@ -35,7 +35,7 @@
/**
* The constructor.
- *
+ *
* @param message the message to show
*/
public ProfileException(String message) {
@@ -44,7 +44,7 @@
/**
* The constructor.
- *
+ *
* @param message the message to show
* @param theCause the cause for the exception
*/
@@ -54,11 +54,10 @@
/**
* The constructor.
- *
+ *
* @param theCause the cause for the exception
*/
public ProfileException(Throwable theCause) {
super(theCause);
}
}
-
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileFacade.java 2008-07-18 07:35:05-0700
@@ -25,11 +25,11 @@
package org.argouml.profile;
/**
- * The <a href="http://en.wikipedia.org/wiki/Facade_pattern">Facade</a> of the
- * profile subsystem.
- * It provides a simplified interface to the subsystem, and access to objects
- * of the subsystem when the methods it provides directly aren't enough.
- *
+ * The <a href="http://en.wikipedia.org/wiki/Facade_pattern">Facade</a> of the
+ * profile subsystem. It provides a simplified interface to the subsystem, and
+ * access to objects of the subsystem when the methods it provides directly
+ * aren't enough.
+ *
* @author Luis Sergio Oliveira (euluis)
* @since 0.25.4
*/
@@ -37,6 +37,7 @@
/**
* Register a profile in the {@link ProfileManager}.
+ *
* @param profile the profile to be registered
*/
public static void register(Profile profile) {
@@ -45,6 +46,7 @@
/**
* Remove or unregister the profile from the {@link ProfileManager}.
+ *
* @param profile the profile to be removed
*/
public static void remove(Profile profile) {
@@ -55,13 +57,12 @@
* @return the profile manager
*/
public static ProfileManager getManager() {
- if (manager == null)
- notInitialized("manager");
+ if (manager == null) notInitialized("manager");
return manager;
}
private static void notInitialized(String string) {
- throw new RuntimeException("ProfileFacade's " + string
+ throw new RuntimeException("ProfileFacade's " + string
+ " isn't initialized!");
}
@@ -84,5 +85,5 @@
public static boolean isInitiated() {
return manager != null;
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileManager.java 2008-07-18 07:35:05-0700
@@ -28,7 +28,7 @@
/**
* Interface to the manager for the global set of registered profiles.
- *
+ *
* @author maurelio1234
*/
public interface ProfileManager {
@@ -37,7 +37,7 @@
* Register a new profile.
*
* @param profile A profile to be registered so that it is available to the
- * users.
+ * users.
*/
void registerProfile(Profile profile);
@@ -45,15 +45,15 @@
* Remove a profile from the list of registered profiles.
*
* @param profile the profile to unregister. It will no longer be available
- * for selection by users
+ * for selection by users
*/
void removeProfile(Profile profile);
-
+
/**
* @return the list of registered profiles
*/
List<Profile> getRegisteredProfiles();
-
+
/**
* Search for a Profile with the given Java classname.
*
@@ -61,56 +61,56 @@
* @param className the name of the Java class to search for.
*/
Profile getProfileForClass(String className);
-
+
/**
* @return the default list of profiles
*/
List<Profile> getDefaultProfiles();
-
+
/**
* Add a profile to the default list.
*
* @param profile profile to be added to the default application profiles.
- * New models will reference it by default
+ * New models will reference it by default
*/
void addToDefaultProfiles(Profile profile);
-
+
/**
* Remove a profile from the default list.
*
* @param profile the profile to be removed
*/
void removeFromDefaultProfiles(Profile profile);
-
+
/**
* Add a new directory to the directory list.
*
- * @param path a directory name where the manager will try to look for
- * user defined profiles as XMI files
+ * @param path a directory name where the manager will try to look for user
+ * defined profiles as XMI files
*/
void addSearchPathDirectory(String path);
-
+
/**
* Remove a directory from the directory list.
*
* @param path the directory path to be removed.
*/
void removeSearchPathDirectory(String path);
-
+
/**
* @return the current directory list
*/
List<String> getSearchPathDirectories();
-
+
/**
- * Look for XMI files at the current directory list and registers
- * them as user defined profiles.
+ * Look for XMI files at the current directory list and registers them as
+ * user defined profiles.
*/
void refreshRegisteredProfiles();
/**
- * @return the Profile for UML, i.e., the base UML profile as defined by
- * the standard.
+ * @return the Profile for UML, i.e., the base UML profile as defined by the
+ * standard.
*/
Profile getUMLProfile();
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileModelLoader.java 2008-07-18 07:35:05-0700
@@ -28,20 +28,19 @@
/**
* Interface to be implemented by profile model loaders.
- *
+ *
* @author maurelio1234
*/
public interface ProfileModelLoader {
-
-
+
/**
* Load a model from the specified path.
*
* @param reference the reference to the profile file, which contains the
- * path where the profile file can be found.
+ * path where the profile file can be found.
* @return the set of defined packages.
* @throws ProfileException if the profile could not be loaded for some
- * reason.
+ * reason.
*/
- Collection loadModel(ProfileReference reference) throws ProfileException;
+ Collection loadModel(ProfileReference reference) throws ProfileException;
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ProfileReference.java 2008-07-18 07:35:05-0700
@@ -28,18 +28,19 @@
import java.net.URL;
/**
- * A reference to a Profile which internally implies having
- * both a public profile reference and the path to the profile file.
+ * A reference to a Profile which internally implies having both a public
+ * profile reference and the path to the profile file.
*
* @author Luis Sergio Oliveira (euluis)
*/
public class ProfileReference {
private String path;
+
private URL url;
/**
- * Constructor. Note that this checks if the file name in path and in
+ * Constructor. Note that this checks if the file name in path and in
* publicReference are the same.
*
* @param thePath the system path to the profile file.
@@ -48,26 +49,25 @@
public ProfileReference(String thePath, URL publicReference) {
File file = new File(thePath);
File fileFromPublicReference = new File(publicReference.getPath());
- assert file.getName().equals(fileFromPublicReference.getName())
- : "File name in path and in publicReference are different.";
+ assert file.getName().equals(fileFromPublicReference.getName()) : "File name in path and in publicReference are different.";
path = thePath;
url = publicReference;
}
/**
- * @return the path to the profile, being in principle this path the
- * system path to the profile file.
+ * @return the path to the profile, being in principle this path the system
+ * path to the profile file.
*/
public String getPath() {
return path;
}
/**
- * @return the public reference by which the profile will
- * be known in models that depend on it. I.e., this reference will prefix
- * the IDs of the profile model elements referred in the XMI of models
- * that depend on the profile for which the constructed ProfileReference
- * is used.
+ * @return the public reference by which the profile will be known in models
+ * that depend on it. I.e., this reference will prefix the IDs of
+ * the profile model elements referred in the XMI of models that
+ * depend on the profile for which the constructed ProfileReference
+ * is used.
*/
public URL getPublicReference() {
return url;
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ReaderModelLoader.java 2008-07-18 07:35:05-0700
@@ -34,16 +34,15 @@
import org.xml.sax.InputSource;
/**
- * TODO: this doesn't need a full ProfileReference since it uses the
- * reader handed in the constructor. It doesn't make much sense to make
- * its callers init the path to some name which it doesn't need...
- *
+ * TODO: this doesn't need a full ProfileReference since it uses the reader
+ * handed in the constructor. It doesn't make much sense to make its callers
+ * init the path to some name which it doesn't need...
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class ReaderModelLoader implements ProfileModelLoader {
- private static final Logger LOG = Logger.getLogger(
- ReaderModelLoader.class);
+ private static final Logger LOG = Logger.getLogger(ReaderModelLoader.class);
private Reader reader;
@@ -56,24 +55,22 @@
this.reader = theReader;
}
-
- /*
+ /*
* @see ProfileModelLoader#loadModel(ProfileReference)
*/
- public Collection loadModel(ProfileReference reference)
+ public Collection loadModel(ProfileReference reference)
throws ProfileException {
-
+
if (reader == null) {
LOG.error("Profile not found");
throw new ProfileException("Profile not found!");
}
-
+
try {
XmiReader xmiReader = Model.getXmiReader();
InputSource inputSource = new InputSource(reader);
inputSource.setSystemId(reference.getPath());
- inputSource.setPublicId(
- reference.getPublicReference().toString());
+ inputSource.setPublicId(reference.getPublicReference().toString());
Collection elements = xmiReader.parse(inputSource, true);
return elements;
} catch (UmlException e) {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ResourceModelLoader.java 2008-07-18 07:35:05-0700
@@ -30,7 +30,7 @@
/**
* Loads models using the default ClassLoader or a provided one.
- *
+ *
* @author maurelio1234
*/
public class ResourceModelLoader extends URLModelLoader {
@@ -40,17 +40,17 @@
*/
private static final Logger LOG = Logger
.getLogger(ResourceModelLoader.class);
-
+
private Class clazz;
-
+
/**
- * The default constructor for this class. Loads resources from the same
+ * The default constructor for this class. Loads resources from the same
* ClassLoader that loaded this class.
*/
public ResourceModelLoader() {
this.clazz = this.getClass();
}
-
+
/**
* Loads resources from the ClassLoader that loaded the given class
*
@@ -60,12 +60,11 @@
clazz = c;
}
-
- public Collection loadModel(ProfileReference reference)
+ public Collection loadModel(ProfileReference reference)
throws ProfileException {
LOG.info("Loading profile from resource'" + reference.getPath() + "'");
- return super.loadModel(clazz.getResource(reference.getPath()),
- reference.getPublicReference());
+ return super.loadModel(clazz.getResource(reference.getPath()),
+ reference.getPublicReference());
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/StreamModelLoader.java 2008-07-18 07:35:05-0700
@@ -36,30 +36,28 @@
/**
* Abstract ProfileModelLoader which loads models from an InputStream.
- *
- * @author Marcos Aurélio
+ *
+ * @author Marcos Aur�lio
*/
public abstract class StreamModelLoader implements ProfileModelLoader {
private static final Logger LOG = Logger.getLogger(StreamModelLoader.class);
-
-
/**
* @param inputStream the stream from where the model should be loaded
* @param publicReference the URL to be used as the public reference of the
- * profile that will be loaded.
+ * profile that will be loaded.
* @return the model
* @throws ProfileException if the XMIReader couldn't read the input stream
*/
public Collection loadModel(InputStream inputStream, URL publicReference)
throws ProfileException {
-
+
if (inputStream == null) {
LOG.error("Profile not found");
throw new ProfileException("Profile not found!");
}
-
+
try {
XmiReader xmiReader = Model.getXmiReader();
InputSource inputSource = new InputSource(inputStream);
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/URLModelLoader.java 2008-07-18 07:35:05-0700
@@ -34,7 +34,7 @@
/**
* Abstract ProfileModelLoader which loads models from a URL.
- *
+ *
* @author Tom Morris
*/
public class URLModelLoader implements ProfileModelLoader {
@@ -42,14 +42,13 @@
/**
* @param url the url/system id to load
* @param publicId the publicId for which the model will be known - must be
- * equal in different machines in order to be possible to
- * load the model.
+ * equal in different machines in order to be possible to load
+ * the model.
* @return a collection of top level elements in the profile (usually a
* single package stereotyped <<profile>>
* @throws ProfileException if the XMIReader couldn't read the profile
*/
- public Collection loadModel(URL url, URL publicId)
- throws ProfileException {
+ public Collection loadModel(URL url, URL publicId) throws ProfileException {
if (url == null) {
throw new ProfileException("Null profile URL");
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserDefinedProfile.java 2008-07-18 07:35:05-0700
@@ -61,16 +61,17 @@
/**
* Logger.
*/
- private static final Logger LOG = Logger.getLogger(UserDefinedProfile.class);
+ private static final Logger LOG = Logger
+ .getLogger(UserDefinedProfile.class);
private String displayName;
private File modelFile;
+
private Collection profilePackages;
- private UserDefinedFigNodeStrategy figNodeStrategy
- = new UserDefinedFigNodeStrategy();
-
+ private UserDefinedFigNodeStrategy figNodeStrategy = new UserDefinedFigNodeStrategy();
+
private class UserDefinedFigNodeStrategy implements FigNodeStrategy {
private HashMap<String, Image> images = new HashMap<String, Image>();
@@ -136,14 +137,14 @@
*/
public UserDefinedProfile(URL url) throws ProfileException {
LOG.info("load " + url);
-
+
ProfileReference reference = null;
reference = new UserProfileReference(url.getPath(), url);
profilePackages = new URLModelLoader().loadModel(reference);
finishLoading();
}
-
+
/**
* A constructor that reads a file from an URL associated with some profiles
*
@@ -151,7 +152,6 @@
* @param url the URL of the profile mode
* @param critics the Critics defined by this profile
* @param dependencies the dependencies of this profile
- *
* @throws ProfileException if the model cannot be loaded
*/
public UserDefinedProfile(String displayName, URL url, Set<CrUML> critics,
@@ -172,17 +172,16 @@
for (String profileID : dependencies) {
addProfileDependency(profileID);
}
-
+
finishLoading();
}
-
/**
* Reads the informations defined as TaggedValues
*/
private void finishLoading() {
- for (Object obj : profilePackages) {
+ for (Object obj : profilePackages) {
if (Model.getExtensionMechanismsHelper().hasStereotype(obj,
"profile")) {
@@ -192,24 +191,26 @@
displayName = name;
} else {
if (displayName == null) {
- displayName = Translator.localize("misc.profile.unnamed");
+ displayName = Translator
+ .localize("misc.profile.unnamed");
}
}
LOG.info("profile " + displayName);
// load profile dependencies
- String dependencyListStr = Model.getFacade().getTaggedValueValue(obj,
- "Dependency");
- StringTokenizer st = new StringTokenizer(dependencyListStr, " ,;:");
+ String dependencyListStr = Model.getFacade()
+ .getTaggedValueValue(obj, "Dependency");
+ StringTokenizer st = new StringTokenizer(dependencyListStr,
+ " ,;:");
String profile = null;
while (st.hasMoreTokens()) {
profile = st.nextToken();
if (profile != null) {
- LOG.debug("AddingDependency " + profile);
- this.
- addProfileDependency(ProfileFacade.getManager().lookForRegisteredProfile(profile));
+ LOG.debug("AddingDependency " + profile);
+ this.addProfileDependency(ProfileFacade.getManager()
+ .lookForRegisteredProfile(profile));
}
}
@@ -217,16 +218,18 @@
}
// load fig nodes
- Collection allStereotypes = Model.getExtensionMechanismsHelper().getStereotypes(
- profilePackages);
+ Collection allStereotypes = Model.getExtensionMechanismsHelper()
+ .getStereotypes(profilePackages);
for (Object stereotype : allStereotypes) {
- Collection tags = Model.getFacade().getTaggedValuesCollection(stereotype);
+ Collection tags = Model.getFacade().getTaggedValuesCollection(
+ stereotype);
for (Object tag : tags) {
if (Model.getFacade().getTag(tag).toLowerCase()
.equals("figure")) {
- LOG.debug("AddFigNode " + Model.getFacade().getName(stereotype));
-
+ LOG.debug("AddFigNode "
+ + Model.getFacade().getName(stereotype));
+
String value = Model.getFacade().getValueOfTag(tag);
File f = new File(value);
FigNodeDescriptor fnd = null;
@@ -240,7 +243,7 @@
}
}
}
-
+
// load critiques
Vector<CrUML> allCritiques = getAllCritiquesInModel();
@@ -250,27 +253,26 @@
}
private CrUML generateCriticFromComment(Object critique) {
- String ocl = ""+Model.getFacade().getBody(critique);
+ String ocl = "" + Model.getFacade().getBody(critique);
String headline = null;
String description = null;
- int priority = ToDoItem.HIGH_PRIORITY;
+ int priority = ToDoItem.HIGH_PRIORITY;
Vector<Decision> supportedDecisions = new Vector<Decision>();
- Vector<String> knowledgeTypes = new Vector<String>();
+ Vector<String> knowledgeTypes = new Vector<String>();
String moreInfoURL = null;
-
+
Collection tags = Model.getFacade().getTaggedValuesCollection(critique);
for (Object tag : tags) {
- if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("headline")) {
- headline = Model.getFacade().getValueOfTag(tag);
- } else if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("description")) {
- description = Model.getFacade().getValueOfTag(tag);
- } else if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("priority")) {
- String prioStr = Model.getFacade().getValueOfTag(tag);
-
+ if (Model.getFacade().getTag(tag).toLowerCase().equals("headline")) {
+ headline = Model.getFacade().getValueOfTag(tag);
+ } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
+ "description")) {
+ description = Model.getFacade().getValueOfTag(tag);
+ } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
+ "priority")) {
+ String prioStr = Model.getFacade().getValueOfTag(tag);
+
if (prioStr.toLowerCase().equals("high")) {
priority = ToDoItem.HIGH_PRIORITY;
} else if (prioStr.toLowerCase().equals("med")) {
@@ -280,12 +282,12 @@
} else if (prioStr.toLowerCase().equals("interruptive")) {
priority = ToDoItem.INTERRUPTIVE_PRIORITY;
}
- } else if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("supporteddecision")) {
+ } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
+ "supporteddecision")) {
String decStr = Model.getFacade().getValueOfTag(tag);
-
+
StringTokenizer st = new StringTokenizer(decStr, ",;:");
-
+
while (st.hasMoreTokens()) {
String token = st.nextToken().trim().toLowerCase();
@@ -322,12 +324,12 @@
if (token.equals("storage"))
supportedDecisions.add(UMLDecision.STORAGE);
}
- } else if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("knowledgetype")) {
+ } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
+ "knowledgetype")) {
String ktStr = Model.getFacade().getValueOfTag(tag);
-
+
StringTokenizer st = new StringTokenizer(ktStr, ",;:");
-
+
while (st.hasMoreTokens()) {
String token = st.nextToken().trim().toLowerCase();
@@ -354,25 +356,24 @@
if (token.equals("tool"))
knowledgeTypes.add(Critic.KT_TOOL);
}
- } else if (Model.getFacade().getTag(tag).toLowerCase()
- .equals("moreinfourl")) {
- moreInfoURL = Model.getFacade().getValueOfTag(tag);
- }
-
-
- }
-
- LOG.debug("OCL-Critic: "+ocl);
-
+ } else if (Model.getFacade().getTag(tag).toLowerCase().equals(
+ "moreinfourl")) {
+ moreInfoURL = Model.getFacade().getValueOfTag(tag);
+ }
+
+ }
+
+ LOG.debug("OCL-Critic: " + ocl);
+
try {
return new CrOCL(ocl, headline, description, priority,
supportedDecisions, knowledgeTypes, moreInfoURL);
} catch (InvalidOclException e) {
LOG.error("Invalid OCL in XMI!", e);
-
+
return null;
}
-
+
}
@SuppressWarnings("unchecked")
@@ -385,9 +386,9 @@
if (Model.getExtensionMechanismsHelper().hasStereotype(comment,
"Critic")) {
CrUML cr = generateCriticFromComment(comment);
-
- if (cr!= null) {
- ret.add(cr);
+
+ if (cr != null) {
+ ret.add(cr);
}
}
}
@@ -396,7 +397,7 @@
@SuppressWarnings("unchecked")
private Collection getAllCommentsInModel(Collection objs) {
- Collection col = new Vector<Object>();
+ Collection col = new Vector<Object>();
for (Object obj : objs) {
if (Model.getFacade().isAComment(obj)) {
col.add(obj);
@@ -404,16 +405,15 @@
Collection contents = Model.getModelManagementHelper()
.getAllContents(obj);
if (contents != null) {
- col.addAll(contents);
+ col.addAll(contents);
}
}
- }
+ }
return col;
}
-
- /**
- * @return the string that should represent this profile in the GUI.
+ /**
+ * @return the string that should represent this profile in the GUI.
*/
public String getDisplayName() {
return displayName;
@@ -452,7 +452,7 @@
@Override
public String toString() {
File str = getModelFile();
- return super.toString() + (str !=null ? " [" + str + "]" : "");
+ return super.toString() + (str != null ? " [" + str + "]" : "");
}
@Override
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/UserProfileReference.java 2008-07-18 07:35:05-0700
@@ -30,37 +30,36 @@
/**
* This class provides the base URL for user defined profiles.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class UserProfileReference extends ProfileReference {
- static final String DEFAULT_USER_PROFILE_BASE_URL =
- "http://argouml.org/user-profiles/";
+ static final String DEFAULT_USER_PROFILE_BASE_URL = "http://argouml.org/user-profiles/";
/**
* Constructor that simply delegates to super.
*
- * @param thePath see thePath documentation in
- * {@link ProfileReference#ProfileReference(String, URL)}.
- * @param publicReference see publicReference documentation in
- * {@link ProfileReference#ProfileReference(String, URL)}.
+ * @param thePath see thePath documentation in
+ * {@link ProfileReference#ProfileReference(String, URL)}.
+ * @param publicReference see publicReference documentation in
+ * {@link ProfileReference#ProfileReference(String, URL)}.
*/
public UserProfileReference(String thePath, URL publicReference) {
super(thePath, publicReference);
}
/**
- * Constructor, which builds a ProfileReference for a user defined profile
- * by prefixing the fileName with {@link #DEFAULT_USER_PROFILE_BASE_URL}
- * and using this as the publicReference.
+ * Constructor, which builds a ProfileReference for a user defined profile
+ * by prefixing the fileName with {@link #DEFAULT_USER_PROFILE_BASE_URL} and
+ * using this as the publicReference.
*
* @param path the profile absolute file name.
* @throws MalformedURLException if the built URL is incorrect.
*/
public UserProfileReference(String path) throws MalformedURLException {
- super(path,
- new URL(DEFAULT_USER_PROFILE_BASE_URL + new File(path).getName()));
+ super(path, new URL(DEFAULT_USER_PROFILE_BASE_URL
+ + new File(path).getName()));
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/ZipModelLoader.java 2008-07-18 07:35:05-0700
@@ -44,61 +44,55 @@
private static final Logger LOG = Logger.getLogger(ZipModelLoader.class);
-
- public Collection loadModel(ProfileReference reference)
+ public Collection loadModel(ProfileReference reference)
throws ProfileException {
LOG.info("Loading profile from ZIP '" + reference.getPath() + "'");
-
+
if (!reference.getPath().endsWith("zip")) {
throw new ProfileException("Profile could not be loaded!");
}
InputStream is = null;
File modelFile = new File(reference.getPath());
- // TODO: This is in the wrong place. It's not profile specific.
+ // TODO: This is in the wrong place. It's not profile specific.
// It needs to be moved to main XMI reading code. - tfm 20060326
String filename = modelFile.getName();
- String extension = filename.substring(filename.indexOf('.'),
- filename.lastIndexOf('.'));
+ String extension = filename.substring(filename.indexOf('.'), filename
+ .lastIndexOf('.'));
String path = modelFile.getParent();
// Add the path of the model to the search path, so we can
// read dependent models
if (path != null) {
- System.setProperty("org.argouml.model.modules_search_path",
- path);
+ System.setProperty("org.argouml.model.modules_search_path", path);
}
try {
is = openZipStreamAt(modelFile.toURI().toURL(), extension);
} catch (MalformedURLException e) {
- LOG.error("Exception while loading profile '"
- + reference.getPath() + "'", e);
+ LOG.error("Exception while loading profile '" + reference.getPath()
+ + "'", e);
throw new ProfileException(e);
} catch (IOException e) {
- LOG.error("Exception while loading profile '"
- + reference.getPath() + "'", e);
+ LOG.error("Exception while loading profile '" + reference.getPath()
+ + "'", e);
throw new ProfileException(e);
}
-
+
if (is == null) {
throw new ProfileException("Profile could not be loaded!");
}
-
+
return super.loadModel(is, reference.getPublicReference());
}
/**
* Open a ZipInputStream to the first file found with a given extension.
- *
- * TODO: Remove since this is a duplicate of ZipFilePersister method
- * when we have refactored the Persister subsystem.
- *
- * @param url
- * The URL of the zip file.
- * @param ext
- * The required extension.
+ * TODO: Remove since this is a duplicate of ZipFilePersister method when we
+ * have refactored the Persister subsystem.
+ *
+ * @param url The URL of the zip file.
+ * @param ext The required extension.
* @return the zip stream positioned at the required location.
- * @throws IOException
- * if there is a problem opening the file.
+ * @throws IOException if there is a problem opening the file.
*/
private ZipInputStream openZipStreamAt(URL url, String ext)
throws IOException {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/JavaFormatingStrategy.java 2008-07-18 07:35:05-0700
@@ -31,11 +31,10 @@
/**
* The Formating Strategy based on Java naming conventions.
- *
- * @author Marcos Aurélio
+ *
+ * @author Marcos Aur�lio
*/
public class JavaFormatingStrategy implements FormatingStrategy {
-
public String formatElement(Object element, Object namespace) {
String value = null;
@@ -44,8 +43,8 @@
} else {
Object elementNs = Model.getFacade().getNamespace(element);
//
- // if element is an AssociationEnd use
- // the namespace of containing association
+ // if element is an AssociationEnd use
+ // the namespace of containing association
//
if (Model.getFacade().isAAssociationEnd(element)) {
Object assoc = Model.getFacade().getAssociation(element);
@@ -73,8 +72,7 @@
* @param namespace the namespace
* @return the default name for the given associationend
*/
- protected String defaultAssocEndName(Object assocEnd,
- Object namespace) {
+ protected String defaultAssocEndName(Object assocEnd, Object namespace) {
String name = null;
Object type = Model.getFacade().getType(assocEnd);
if (type != null) {
@@ -102,7 +100,7 @@
/**
* Create a default association name from its ends.
- *
+ *
* @param assoc the given association
* @param ns the namespace
* @return the default association name
@@ -169,8 +167,7 @@
* @param element the given modelelement
* @param pathSep the path separator character(s)
*/
- private void buildPath(StringBuffer buffer, Object element,
- String pathSep) {
+ private void buildPath(StringBuffer buffer, Object element, String pathSep) {
if (element != null) {
Object parent = Model.getFacade().getNamespace(element);
if (parent != null && parent != element) {
@@ -199,7 +196,6 @@
return "[empty]";
}
-
public String formatCollection(Iterator iter, Object namespace) {
String value = null;
if (iter.hasNext()) {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ModelUtils.java 2008-07-18 07:35:05-0700
@@ -30,7 +30,7 @@
/**
* Helper utility methods for searching the model.
- *
+ *
* @author maurelio1234
*/
public class ModelUtils {
@@ -44,20 +44,18 @@
public static Object findTypeInModel(String s, Object model) {
if (!Model.getFacade().isANamespace(model)) {
- throw new IllegalArgumentException(
- "Looking for the classifier " + s
- + " in a non-namespace object of " + model
+ throw new IllegalArgumentException("Looking for the classifier "
+ + s + " in a non-namespace object of " + model
+ ". A namespace was expected.");
}
- Collection allClassifiers =
- Model.getModelManagementHelper()
+ Collection allClassifiers = Model.getModelManagementHelper()
.getAllModelElementsOfKind(model,
Model.getMetaTypes().getClassifier());
for (Object classifier : allClassifiers) {
if (Model.getFacade().getName(classifier) != null
- && Model.getFacade().getName(classifier).equals(s)) {
+ && Model.getFacade().getName(classifier).equals(s)) {
return classifier;
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileJava.java 2008-07-18 07:35:05-0700
@@ -40,20 +40,23 @@
/**
* This class represents the Java default Profile
- *
- * @author Marcos Aurélio
+ *
+ * @author Marcos Aur�lio
*/
public class ProfileJava extends Profile {
private static final String PROFILE_FILE = "default-java.xmi";
+
static final String NAME = "Java";
-
+
private ProfileModelLoader profileModelLoader;
+
private Collection model;
-
+
/**
- * The default constructor for this class
- * @throws ProfileException
+ * The default constructor for this class
+ *
+ * @throws ProfileException
*/
@SuppressWarnings("unchecked")
ProfileJava(Profile uml) throws ProfileException {
@@ -63,7 +66,7 @@
profileReference = new CoreProfileReference(PROFILE_FILE);
} catch (MalformedURLException e) {
throw new ProfileException(
- "Exception while creating profile reference.", e);
+ "Exception while creating profile reference.", e);
}
model = profileModelLoader.loadModel(profileReference);
@@ -73,24 +76,21 @@
}
addProfileDependency(uml);
- }
-
+ }
+
ProfileJava() throws ProfileException {
this(ProfileFacade.getManager().getProfileForClass(
ProfileUML.class.getName()));
}
-
public String getDisplayName() {
return NAME;
}
-
@Override
public Collection getProfilePackages() {
return model;
}
-
@Override
public DefaultTypeStrategy getDefaultTypeStrategy() {
@@ -109,7 +109,7 @@
return ModelUtils.findTypeInModel("void", model.iterator()
.next());
}
-
+
};
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileManagerImpl.java 2008-07-18 07:35:05-0700
@@ -44,13 +44,13 @@
/**
* Default <code>ProfileManager</code> implementation
- *
+ *
* @author Marcos Aur�lio
*/
public class ProfileManagerImpl implements ProfileManager {
-
- private static final Logger LOG = Logger.getLogger(
- ProfileManagerImpl.class);
+
+ private static final Logger LOG = Logger
+ .getLogger(ProfileManagerImpl.class);
private static final String DIRECTORY_SEPARATOR = "*";
@@ -70,7 +70,7 @@
* Avoids recursive configuration update when loading configuration
*/
private boolean disableConfigurationUpdate = false;
-
+
private List<Profile> profiles = new ArrayList<Profile>();
private List<Profile> defaultProfiles = new ArrayList<Profile>();
@@ -98,19 +98,19 @@
loadDefaultProfilesfromConfiguration();
}
- private void loadDefaultProfilesfromConfiguration() {
+ private void loadDefaultProfilesfromConfiguration() {
disableConfigurationUpdate = true;
-
+
StringTokenizer tokenizer = new StringTokenizer(Configuration
.getString(KEY_DEFAULT_PROFILES), DIRECTORY_SEPARATOR, false);
while (tokenizer.hasMoreTokens()) {
String desc = tokenizer.nextToken();
Profile p = null;
-
+
if (desc.charAt(0) == 'U') {
String fileName = desc.substring(1);
- p = findUserDefinedProfile(new File(fileName));
+ p = findUserDefinedProfile(new File(fileName));
} else if (desc.charAt(0) == 'C') {
String className = desc.substring(1);
p = getProfileForClass(className);
@@ -127,7 +127,7 @@
private void updateDefaultProfilesConfiguration() {
if (!disableConfigurationUpdate) {
StringBuffer buf = new StringBuffer();
-
+
for (Profile p : defaultProfiles) {
if (p instanceof UserDefinedProfile) {
buf.append("U"
@@ -146,16 +146,14 @@
private void loadDirectoriesFromConfiguration() {
disableConfigurationUpdate = true;
-
- StringTokenizer tokenizer =
- new StringTokenizer(
- Configuration.getString(KEY_DEFAULT_DIRECTORIES),
- DIRECTORY_SEPARATOR, false);
+
+ StringTokenizer tokenizer = new StringTokenizer(Configuration
+ .getString(KEY_DEFAULT_DIRECTORIES), DIRECTORY_SEPARATOR, false);
while (tokenizer.hasMoreTokens()) {
searchDirectories.add(tokenizer.nextToken());
}
-
+
disableConfigurationUpdate = false;
}
@@ -171,35 +169,32 @@
}
}
-
public List<Profile> getRegisteredProfiles() {
return profiles;
}
-
- public void registerProfile(Profile p) {
+ public void registerProfile(Profile p) {
if (p != null && !profiles.contains(p)) {
if (p instanceof UserDefinedProfile
|| getProfileForClass(p.getClass().getName()) == null) {
profiles.add(p);
-
+
for (CrUML critic : p.getCritics()) {
for (Object meta : critic.getCriticizedMetatypes()) {
- Agency.register(critic, meta);
+ Agency.register(critic, meta);
}
-
+
critic.setEnabled(false);
}
-
- // this profile could have not been loaded when
- // the default profile configuration
+
+ // this profile could have not been loaded when
+ // the default profile configuration
// was loaded at first, so we need to do it again
loadDefaultProfilesfromConfiguration();
}
}
}
-
public void removeProfile(Profile p) {
if (p != null) {
profiles.remove(p);
@@ -207,7 +202,6 @@
}
}
-
public Profile getProfileForClass(String profileClass) {
Profile found = null;
for (Profile p : profiles) {
@@ -219,21 +213,17 @@
return found;
}
-
public void addToDefaultProfiles(Profile p) {
- if (p != null && profiles.contains(p)
- && !defaultProfiles.contains(p)) {
+ if (p != null && profiles.contains(p) && !defaultProfiles.contains(p)) {
defaultProfiles.add(p);
updateDefaultProfilesConfiguration();
}
}
-
public List<Profile> getDefaultProfiles() {
return Collections.unmodifiableList(defaultProfiles);
}
-
public void removeFromDefaultProfiles(Profile p) {
if (p != null && profiles.contains(p)) {
defaultProfiles.remove(p);
@@ -241,7 +231,6 @@
}
}
-
public void addSearchPathDirectory(String path) {
if (path != null && !searchDirectories.contains(path)) {
searchDirectories.add(path);
@@ -254,12 +243,10 @@
}
}
-
public List<String> getSearchPathDirectories() {
return Collections.unmodifiableList(searchDirectories);
}
-
public void removeSearchPathDirectory(String path) {
if (path != null) {
searchDirectories.remove(path);
@@ -272,7 +259,6 @@
}
}
-
public void refreshRegisteredProfiles() {
for (String dirName : searchDirectories) {
@@ -283,8 +269,7 @@
// TODO: Allow .zargo as profile as well?
if (file.getName().toLowerCase().endsWith(".xmi")) {
- boolean found =
- findUserDefinedProfile(file) != null;
+ boolean found = findUserDefinedProfile(file) != null;
if (!found) {
UserDefinedProfile udp = null;
@@ -294,7 +279,7 @@
} catch (ProfileException e) {
// if an exception is raised file is unusable
LOG.warn("Failed to load user defined profile "
- + file.getAbsolutePath() + ".", e);
+ + file.getAbsolutePath() + ".", e);
}
}
}
@@ -304,7 +289,7 @@
}
private Profile findUserDefinedProfile(File file) {
-
+
for (Profile p : profiles) {
if (p instanceof UserDefinedProfile) {
UserDefinedProfile udp = (UserDefinedProfile) p;
@@ -317,12 +302,10 @@
return null;
}
-
public Profile getUMLProfile() {
for (Profile p : getRegisteredProfiles())
- if (p.getDisplayName() != null
- && p.getDisplayName().contains("UML"))
- return p;
+ if (p.getDisplayName() != null
+ && p.getDisplayName().contains("UML")) return p;
Profile p = null;
try {
p = new ProfileUML();
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileMeta.java 2008-07-18 07:35:05-0700
@@ -37,13 +37,15 @@
import org.argouml.profile.ResourceModelLoader;
/**
- * Meta Profile which defines the TaggedValues to be used in User defined Profiles
- *
+ * Meta Profile which defines the TaggedValues to be used in User defined
+ * Profiles
+ *
* @author maas
*/
public class ProfileMeta extends Profile {
private static final String PROFILE_FILE = "metaprofile.xmi";
+
private Collection model;
/**
@@ -59,7 +61,7 @@
profileReference = new CoreProfileReference(PROFILE_FILE);
} catch (MalformedURLException e) {
throw new ProfileException(
- "Exception while creating profile reference.", e);
+ "Exception while creating profile reference.", e);
}
model = profileModelLoader.loadModel(profileReference);
@@ -69,7 +71,7 @@
}
}
-
+
@Override
public String getDisplayName() {
return "MetaProfile";
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ProfileUML.java 2008-07-18 07:35:05-0700
@@ -40,22 +40,25 @@
/**
* This class represents the default UML profile
- *
- * @author Marcos Aurélio
+ *
+ * @author Marcos Aur�lio
*/
public class ProfileUML extends Profile {
-
+
private static final String PROFILE_FILE = "default-uml14.xmi";
static final String NAME = "UML 1.4";
-
+
private FormatingStrategy formatingStrategy;
+
private ProfileModelLoader profileModelLoader;
+
private Collection model;
-
+
/**
- * Construct a Profile for UML modeling.
- * @throws ProfileException
+ * Construct a Profile for UML modeling.
+ *
+ * @throws ProfileException
*/
@SuppressWarnings("unchecked")
ProfileUML() throws ProfileException {
@@ -66,15 +69,15 @@
profileReference = new CoreProfileReference(PROFILE_FILE);
} catch (MalformedURLException e) {
throw new ProfileException(
- "Exception while creating profile reference.", e);
+ "Exception while creating profile reference.", e);
}
model = profileModelLoader.loadModel(profileReference);
if (model == null) {
model = new ArrayList();
model.add(Model.getModelManagementFactory().createModel());
- }
- }
+ }
+ }
@Override
public FormatingStrategy getFormatingStrategy() {
@@ -86,12 +89,10 @@
return NAME;
}
-
@Override
public Collection getProfilePackages() {
return model;
}
-
@Override
public DefaultTypeStrategy getDefaultTypeStrategy() {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CompositeModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -36,16 +36,16 @@
public class CompositeModelInterpreter implements ModelInterpreter {
private Set<ModelInterpreter> set = new HashSet<ModelInterpreter>();
-
+
/**
* Adds a ModelInterpreter to this set
*
* @param mi
*/
public void addModelInterpreter(ModelInterpreter mi) {
- set.add(mi);
+ set.add(mi);
}
-
+
/**
* @see org.argouml.profile.internal.ocl.ModelInterpreter#invokeFeature(java.util.HashMap,
* java.lang.Object, java.lang.String, java.lang.String,
@@ -64,7 +64,7 @@
}
/**
- * @see org.argouml.profile.internal.ocl.ModelInterpreter#getBuiltInSymbol(java.lang.Object)
+ * @see org.argouml.profile.internal.ocl.ModelInterpreter#getBuiltInSymbol(java.lang.String)
*/
public Object getBuiltInSymbol(String sym) {
for (ModelInterpreter mi : set) {
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ComputeTriggers.java 2008-07-18 07:35:05-0700
@@ -31,21 +31,21 @@
/**
* Check the triggers related to this OCL
- *
+ *
* @author maas
*/
public class ComputeTriggers extends DepthFirstAdapter {
private Vector<String> triggs = new Vector<String>();
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAClassifierContext(tudresden.ocl.parser.node.AClassifierContext)
*/
public void caseAClassifierContext(AClassifierContext node) {
- String str = ""+node.getPathTypeName();
+ String str = "" + node.getPathTypeName();
triggs.add(str.trim().toLowerCase());
}
-
+
/**
* @return the triggers
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ContextApplicable.java 2008-07-18 07:35:05-0700
@@ -36,8 +36,8 @@
import tudresden.ocl.parser.node.APreStereotype;
/**
- * Checks the context clause of the OCL expression to verify if it
- * is applicable to the given model element.
+ * Checks the context clause of the OCL expression to verify if it is applicable
+ * to the given model element.
*
* @author maurelio1234
*/
@@ -51,7 +51,7 @@
private boolean applicable = true;
private Object modelElement;
-
+
/**
* Constructos
*
@@ -87,24 +87,21 @@
}
}
-
+
/**
* @param node
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#inAPreStereotype(tudresden.ocl.parser.node.APreStereotype)
*/
- public void inAPreStereotype(APreStereotype node)
- {
+ public void inAPreStereotype(APreStereotype node) {
applicable = false;
}
-
/**
* @param node
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#inAPostStereotype(tudresden.ocl.parser.node.APostStereotype)
*/
- public void inAPostStereotype(APostStereotype node)
- {
+ public void inAPostStereotype(APostStereotype node) {
applicable = false;
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/CrOCL.java 2008-07-18 07:35:05-0700
@@ -34,9 +34,8 @@
import org.argouml.uml.cognitive.critics.CrUML;
/**
- * Represents an critics defined as an OCL expression in
- * a profile
- *
+ * Represents an critics defined as an OCL expression in a profile
+ *
* @author maurelio1234
*/
public class CrOCL extends CrUML {
@@ -44,23 +43,22 @@
/**
* Logger.
*/
- //private static final Logger LOG = Logger.getLogger(CrOCL.class);
-
+ // private static final Logger LOG = Logger.getLogger(CrOCL.class);
/**
- * the OCL Interpreter
+ * the OCL Interpreter
*/
private OclInterpreter interpreter = null;
-
+
/**
* Creates a new OCL critic
*
* @param ocl ocl expression
* @param headline headline
* @param description description
- * @param moreInfoURL
- * @param knowledgeTypes
- * @param supportedDecisions
- * @param priority
+ * @param moreInfoURL
+ * @param knowledgeTypes
+ * @param supportedDecisions
+ * @param priority
* @throws InvalidOclException if the ocl is not valid
*/
public CrOCL(String ocl, String headline, String description,
@@ -68,51 +66,51 @@
Vector<String> knowledgeTypes, String moreInfoURL)
throws InvalidOclException {
interpreter = new OclInterpreter(ocl, new Uml14ModelInterpreter());
-
+
addSupportedDecision(UMLDecision.PLANNED_EXTENSIONS);
setPriority(ToDoItem.HIGH_PRIORITY);
-
+
Vector<String> triggers = interpreter.getTriggers();
-
+
for (String string : triggers) {
- addTrigger(string);
+ addTrigger(string);
}
-
+
if (headline == null) {
- super.setHeadline("OCL Expression");
+ super.setHeadline("OCL Expression");
} else {
- super.setHeadline(headline);
+ super.setHeadline(headline);
}
if (description == null) {
super.setDescription(ocl);
} else {
- super.setDescription(description);
+ super.setDescription(description);
}
-
+
if (priority == null) {
setPriority(ToDoItem.HIGH_PRIORITY);
} else {
setPriority(priority);
}
-
+
if (supportedDecisions != null) {
for (Decision d : supportedDecisions) {
addSupportedDecision(d);
}
}
-
+
if (knowledgeTypes != null) {
for (String k : knowledgeTypes) {
addKnowledgeType(k);
- }
+ }
}
-
+
if (moreInfoURL != null) {
setMoreInfoURL(moreInfoURL);
}
}
-
+
/**
* @see org.argouml.uml.cognitive.critics.CrUML#predicate2(java.lang.Object,
* org.argouml.cognitive.Designer)
@@ -128,5 +126,5 @@
}
}
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateExpression.java 2008-07-18 07:35:05-0700
@@ -75,7 +75,7 @@
/**
* Evaluates OCL expressions, this class should not depend on the model
* subsystem. This adapter assumes the ocl expression is syntacally and
- * semantically correct.
+ * semantically correct.
*
* @author maurelio1234
*/
@@ -84,30 +84,31 @@
/**
* Logger.
*/
- private static final Logger LOG = Logger.getLogger(EvaluateExpression.class);
-
+ private static final Logger LOG = Logger
+ .getLogger(EvaluateExpression.class);
+
/**
* The Variable Table
*/
private HashMap<String, Object> vt = null;
-
+
/**
- * Keeps the return value of the visitor
+ * Keeps the return value of the visitor
*/
private Object val = null;
-
+
/**
* Keeps a forward propagated value
*/
- private Object fwd = null;
-
+ private Object fwd = null;
+
/**
* The model interpreter
*/
private ModelInterpreter interp = null;
-
+
/**
- * Constructor
+ * Constructor
*
* @param modelElement self
* @param mi model interpreter
@@ -119,75 +120,67 @@
/**
* Resets the internal state of this adapter
*
- * @param mi
- * @param modelElement
+ * @param mi
+ * @param modelElement
*/
public void reset(Object modelElement, ModelInterpreter mi) {
this.interp = mi;
-
+
val = null;
fwd = null;
vt = new HashMap<String, Object>();
vt.put("self", modelElement);
}
-
+
/**
* @return is the invariant ok?
*/
public Object getValue() {
return val;
}
-
- /** Interpreter Code **/
-
+
+ /** Interpreter Code * */
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAIfExpression(tudresden.ocl.parser.node.AIfExpression)
*/
- public void caseAIfExpression(AIfExpression node)
- {
+ public void caseAIfExpression(AIfExpression node) {
boolean test = false;
boolean ret = false;
-
+
inAIfExpression(node);
- if(node.getTIf() != null)
- {
+ if (node.getTIf() != null) {
node.getTIf().apply(this);
}
- if(node.getIfBranch() != null)
- {
- node.getIfBranch().apply(this);
+ if (node.getIfBranch() != null) {
+ node.getIfBranch().apply(this);
test = asBoolean(val, node.getIfBranch());
val = null;
}
- if(node.getTThen() != null)
- {
+ if (node.getTThen() != null) {
node.getTThen().apply(this);
}
- if(node.getThenBranch() != null)
- {
+ if (node.getThenBranch() != null) {
node.getThenBranch().apply(this);
if (test) {
ret = asBoolean(val, node.getThenBranch());
val = null;
}
}
- if(node.getTElse() != null)
- {
+ if (node.getTElse() != null) {
node.getTElse().apply(this);
}
- if(node.getElseBranch() != null)
- {
+ if (node.getElseBranch() != null) {
node.getElseBranch().apply(this);
if (!test) {
- ret = asBoolean(val, node.getThenBranch());
+ ret = asBoolean(val, node.getThenBranch());
val = null;
}
}
- if(node.getEndif() != null)
- {
+ if (node.getEndif() != null) {
node.getEndif().apply(this);
}
-
+
val = ret;
outAIfExpression(node);
}
@@ -195,26 +188,23 @@
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseALogicalExpressionTail(tudresden.ocl.parser.node.ALogicalExpressionTail)
*/
- public void caseALogicalExpressionTail(ALogicalExpressionTail node)
- {
+ public void caseALogicalExpressionTail(ALogicalExpressionTail node) {
Object left = val;
val = null;
inALogicalExpressionTail(node);
- if(node.getLogicalOperator() != null)
- {
+ if (node.getLogicalOperator() != null) {
node.getLogicalOperator().apply(this);
}
- if(node.getRelationalExpression() != null)
- {
+ if (node.getRelationalExpression() != null) {
node.getRelationalExpression().apply(this);
}
Object op = node.getLogicalOperator();
Object right = val;
val = null;
-
- if (left != null && op!= null && right != null) {
+
+ if (left != null && op != null && right != null) {
if (op instanceof AAndLogicalOperator) {
val = asBoolean(left, node) && asBoolean(right, node);
} else if (op instanceof AImpliesLogicalOperator) {
@@ -225,38 +215,35 @@
val = !asBoolean(left, node) ^ asBoolean(right, node);
} else {
error(node);
- }
+ }
} else {
error(node);
}
outALogicalExpressionTail(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseARelationalExpressionTail(tudresden.ocl.parser.node.ARelationalExpressionTail)
*/
- public void caseARelationalExpressionTail(ARelationalExpressionTail node)
- {
+ public void caseARelationalExpressionTail(ARelationalExpressionTail node) {
Object left = val;
val = null;
-
+
inARelationalExpressionTail(node);
- if(node.getRelationalOperator() != null)
- {
- node.getRelationalOperator().apply(this);
+ if (node.getRelationalOperator() != null) {
+ node.getRelationalOperator().apply(this);
}
- if(node.getAdditiveExpression() != null)
- {
+ if (node.getAdditiveExpression() != null) {
node.getAdditiveExpression().apply(this);
}
Object op = node.getRelationalOperator();
Object right = val;
val = null;
-
- if (left != null && op!= null && right != null) {
+
+ if (left != null && op != null && right != null) {
if (op instanceof AEqualRelationalOperator) {
- val = left.equals(right);
+ val = left.equals(right);
} else if (op instanceof AGteqRelationalOperator) {
val = asInteger(left, node) >= asInteger(right, node);
} else if (op instanceof AGtRelationalOperator) {
@@ -266,9 +253,9 @@
} else if (op instanceof ALtRelationalOperator) {
val = asInteger(left, node) < asInteger(right, node);
} else if (op instanceof ANEqualRelationalOperator) {
- val = !left.equals(right);
+ val = !left.equals(right);
} else {
- error(node);
+ error(node);
}
} else {
error(node);
@@ -279,154 +266,138 @@
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAAdditiveExpressionTail(tudresden.ocl.parser.node.AAdditiveExpressionTail)
*/
- public void caseAAdditiveExpressionTail(AAdditiveExpressionTail node)
- {
+ public void caseAAdditiveExpressionTail(AAdditiveExpressionTail node) {
Object left = val;
val = null;
inAAdditiveExpressionTail(node);
- if(node.getAddOperator() != null)
- {
+ if (node.getAddOperator() != null) {
node.getAddOperator().apply(this);
}
- if(node.getMultiplicativeExpression() != null)
- {
+ if (node.getMultiplicativeExpression() != null) {
node.getMultiplicativeExpression().apply(this);
}
Object op = node.getAddOperator();
Object right = val;
val = null;
-
- if (left != null && op!= null && right != null) {
+
+ if (left != null && op != null && right != null) {
if (op instanceof AMinusAddOperator) {
val = asInteger(left, node) - asInteger(right, node);
} else if (op instanceof APlusAddOperator) {
val = asInteger(left, node) + asInteger(right, node);
} else {
error(node);
- }
+ }
} else {
error(node);
}
-
+
outAAdditiveExpressionTail(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAMultiplicativeExpressionTail(tudresden.ocl.parser.node.AMultiplicativeExpressionTail)
*/
- public void caseAMultiplicativeExpressionTail(AMultiplicativeExpressionTail node)
- {
+ public void caseAMultiplicativeExpressionTail(
+ AMultiplicativeExpressionTail node) {
Object left = val;
val = null;
inAMultiplicativeExpressionTail(node);
- if(node.getMultiplyOperator() != null)
- {
+ if (node.getMultiplyOperator() != null) {
node.getMultiplyOperator().apply(this);
}
- if(node.getUnaryExpression() != null)
- {
+ if (node.getUnaryExpression() != null) {
node.getUnaryExpression().apply(this);
}
Object op = node.getMultiplyOperator();
Object right = val;
val = null;
-
- if (left != null && op!= null && right != null) {
+
+ if (left != null && op != null && right != null) {
if (op instanceof ADivMultiplyOperator) {
val = asInteger(left, node) / asInteger(right, node);
} else if (op instanceof AMultMultiplyOperator) {
val = asInteger(left, node) * asInteger(right, node);
} else {
error(node);
- }
+ }
} else {
error(node);
}
-
+
outAMultiplicativeExpressionTail(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAUnaryUnaryExpression(tudresden.ocl.parser.node.AUnaryUnaryExpression)
*/
- public void caseAUnaryUnaryExpression(AUnaryUnaryExpression node)
- {
+ public void caseAUnaryUnaryExpression(AUnaryUnaryExpression node) {
inAUnaryUnaryExpression(node);
- if(node.getUnaryOperator() != null)
- {
+ if (node.getUnaryOperator() != null) {
node.getUnaryOperator().apply(this);
}
- if(node.getPostfixExpression() != null)
- {
+ if (node.getPostfixExpression() != null) {
val = null;
node.getPostfixExpression().apply(this);
}
-
+
Object op = node.getUnaryOperator();
if (op instanceof AMinusUnaryOperator) {
val = -asInteger(val, node);
} else if (op instanceof ANotUnaryOperator) {
val = !asBoolean(val, node);
}
-
+
outAUnaryUnaryExpression(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAPostfixExpressionTail(tudresden.ocl.parser.node.APostfixExpressionTail)
*/
- public void caseAPostfixExpressionTail(APostfixExpressionTail node)
- {
+ public void caseAPostfixExpressionTail(APostfixExpressionTail node) {
inAPostfixExpressionTail(node);
- if(node.getPostfixExpressionTailBegin() != null)
- {
+ if (node.getPostfixExpressionTailBegin() != null) {
node.getPostfixExpressionTailBegin().apply(this);
}
- if(node.getFeatureCall() != null)
- {
+ if (node.getFeatureCall() != null) {
fwd = node.getPostfixExpressionTailBegin();
node.getFeatureCall().apply(this);
-
+
// XXX: hypotheses for AFeatureCall: fwd = op, val = head
}
outAPostfixExpressionTail(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAFeaturePrimaryExpression(tudresden.ocl.parser.node.AFeaturePrimaryExpression)
*/
@SuppressWarnings("unchecked")
- public void caseAFeaturePrimaryExpression(AFeaturePrimaryExpression node)
- {
+ public void caseAFeaturePrimaryExpression(AFeaturePrimaryExpression node) {
Object subject = val;
Object feature = null;
Vector<Object> parameters = null;
-
+
inAFeaturePrimaryExpression(node);
- if(node.getPathName() != null)
- {
- // TODO support other name kinds
+ if (node.getPathName() != null) {
+ // TODO support other name kinds
node.getPathName().apply(this);
feature = node.getPathName().toString().trim();
}
- if(node.getTimeExpression() != null)
- {
+ if (node.getTimeExpression() != null) {
// hypotheses no time expression (only invariants)
node.getTimeExpression().apply(this);
}
- if(node.getQualifiers() != null)
- {
+ if (node.getQualifiers() != null) {
// XXX: hypotheses no qualifiers (I don't know)
node.getQualifiers().apply(this);
}
- if(node.getFeatureCallParameters() != null)
- {
+ if (node.getFeatureCallParameters() != null) {
val = null;
- node.getFeatureCallParameters().apply(this);
+ node.getFeatureCallParameters().apply(this);
parameters = (Vector<Object>) val;
}
@@ -436,35 +407,31 @@
val = this.interp.getBuiltInSymbol(feature.toString().trim());
}
} else {
- val = runFeatureCall(subject, feature,fwd,parameters);
+ val = runFeatureCall(subject, feature, fwd, parameters);
}
outAFeaturePrimaryExpression(node);
- }
+ }
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outAEmptyFeatureCallParameters(tudresden.ocl.parser.node.AEmptyFeatureCallParameters)
*/
- public void outAEmptyFeatureCallParameters(AEmptyFeatureCallParameters node)
- {
+ public void outAEmptyFeatureCallParameters(AEmptyFeatureCallParameters node) {
val = new Vector<Object>();
defaultOut(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAFeatureCallParameters(tudresden.ocl.parser.node.AFeatureCallParameters)
*/
@SuppressWarnings("unchecked")
- public void caseAFeatureCallParameters(AFeatureCallParameters node)
- {
+ public void caseAFeatureCallParameters(AFeatureCallParameters node) {
inAFeatureCallParameters(node);
- if(node.getLPar() != null)
- {
+ if (node.getLPar() != null) {
node.getLPar().apply(this);
}
-
+
boolean hasDeclarator = false;
- if(node.getDeclarator() != null)
- {
+ if (node.getDeclarator() != null) {
node.getDeclarator().apply(this);
hasDeclarator = true;
}
@@ -475,34 +442,35 @@
vars = (Vector<String>) val;
final PExpression exp = ((AActualParameterList) node
.getActualParameterList()).getExpression();
-
+
/*
- * For a iterator call we should provide:
- * (a) the variables
- * (b) the expression to be evaluated on each step
- * (c) the lambda-evaluator to evaluate it
+ * For a iterator call we should provide: (a) the variables (b)
+ * the expression to be evaluated on each step (c) the
+ * lambda-evaluator to evaluate it
*/
-
+
ret.add(vars);
ret.add(exp);
ret.add(new LambdaEvaluator() {
/**
- * @see org.argouml.profile.internal.ocl.LambdaEvaluator#evaluate(java.util.HashMap, java.lang.Object)
+ * @see org.argouml.profile.internal.ocl.LambdaEvaluator#evaluate(java.util.HashMap,
+ * java.lang.Object)
*/
- public Object evaluate(HashMap<String, Object> vti, Object expi) {
+ public Object evaluate(HashMap<String, Object> vti,
+ Object expi) {
Object old_val = EvaluateExpression.this.val;
EvaluateExpression.this.val = null;
- ((PExpression)expi).apply(EvaluateExpression.this);
-
+ ((PExpression) expi).apply(EvaluateExpression.this);
+
Object reti = EvaluateExpression.this.val;
EvaluateExpression.this.val = old_val;
-
+
return reti;
}
-
- });
-
+
+ });
+
val = ret;
} else {
node.getActualParameterList().apply(this);
@@ -514,50 +482,45 @@
}
outAFeatureCallParameters(node);
}
-
+
/**
* @param node
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAStandardDeclarator(tudresden.ocl.parser.node.AStandardDeclarator)
*/
- public void caseAStandardDeclarator(AStandardDeclarator node)
- {
+ public void caseAStandardDeclarator(AStandardDeclarator node) {
inAStandardDeclarator(node);
-
+
Vector<String> vars = new Vector<String>();
-
- if(node.getName() != null)
- {
+
+ if (node.getName() != null) {
node.getName().apply(this);
-
+
vars.add(node.getName().toString().trim());
}
- {
+ {
Object temp[] = node.getDeclaratorTail().toArray();
for (int i = 0; i < temp.length; i++) {
((PDeclaratorTail) temp[i]).apply(this);
vars.add(((ADeclaratorTail) temp[i]).getName()
- .toString().trim());
+ .toString().trim());
}
-
+
val = vars;
}
- if(node.getDeclaratorTypeDeclaration() != null)
- {
+ if (node.getDeclaratorTypeDeclaration() != null) {
// TODO check types!
node.getDeclaratorTypeDeclaration().apply(this);
}
- if(node.getBar() != null)
- {
+ if (node.getBar() != null) {
node.getBar().apply(this);
}
outAStandardDeclarator(node);
}
- public void outAIterateDeclarator(AIterateDeclarator node)
- {
- //TODO support iterate declarator
+ public void outAIterateDeclarator(AIterateDeclarator node) {
+ // TODO support iterate declarator
val = new Vector<String>();
defaultOut(node);
}
@@ -565,51 +528,43 @@
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseALetExpression(tudresden.ocl.parser.node.ALetExpression)
*/
- public void caseALetExpression(ALetExpression node)
- {
+ public void caseALetExpression(ALetExpression node) {
// TODO support nested let expressions !
Object name = null;
Object value = null;
-
+
inALetExpression(node);
- if(node.getTLet() != null)
- {
+ if (node.getTLet() != null) {
node.getTLet().apply(this);
}
- if(node.getName() != null)
- {
+ if (node.getName() != null) {
node.getName().apply(this);
name = node.getName().toString().trim();
}
- if(node.getLetExpressionTypeDeclaration() != null)
- {
+ if (node.getLetExpressionTypeDeclaration() != null) {
// TODO: check type!
node.getLetExpressionTypeDeclaration().apply(this);
}
- if(node.getEqual() != null)
- {
+ if (node.getEqual() != null) {
node.getEqual().apply(this);
}
- if(node.getExpression() != null)
- {
+ if (node.getExpression() != null) {
node.getExpression().apply(this);
}
- if(node.getTIn() != null)
- {
+ if (node.getTIn() != null) {
node.getTIn().apply(this);
}
-
- vt.put((""+name).trim(), value);
+
+ vt.put(("" + name).trim(), value);
val = value;
outALetExpression(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outAStringLiteral(tudresden.ocl.parser.node.AStringLiteral)
*/
- public void outAStringLiteral(AStringLiteral node)
- {
+ public void outAStringLiteral(AStringLiteral node) {
val = node.getStringLit().getText();
defaultOut(node);
}
@@ -617,27 +572,24 @@
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outARealLiteral(tudresden.ocl.parser.node.ARealLiteral)
*/
- public void outARealLiteral(ARealLiteral node)
- {
+ public void outARealLiteral(ARealLiteral node) {
// TODO support real types
- val = (int)Double.parseDouble(node.getReal().getText());
+ val = (int) Double.parseDouble(node.getReal().getText());
defaultOut(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outAIntegerLiteral(tudresden.ocl.parser.node.AIntegerLiteral)
*/
- public void outAIntegerLiteral(AIntegerLiteral node)
- {
+ public void outAIntegerLiteral(AIntegerLiteral node) {
val = Integer.parseInt(node.getInt().getText());
defaultOut(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outABooleanLiteral(tudresden.ocl.parser.node.ABooleanLiteral)
*/
- public void outABooleanLiteral(ABooleanLiteral node)
- {
+ public void outABooleanLiteral(ABooleanLiteral node) {
val = Boolean.parseBoolean(node.getBool().getText());
defaultOut(node);
}
@@ -645,18 +597,16 @@
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outAEnumLiteral(tudresden.ocl.parser.node.AEnumLiteral)
*/
- public void outAEnumLiteral(AEnumLiteral node)
- {
+ public void outAEnumLiteral(AEnumLiteral node) {
// TODO support enums!
val = null;
defaultOut(node);
}
-
+
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#outALiteralCollection(tudresden.ocl.parser.node.ALiteralCollection)
*/
- public void outALiteralCollection(ALiteralCollection node)
- {
+ public void outALiteralCollection(ALiteralCollection node) {
// TODO support collections
val = new Vector<Object>();
defaultOut(node);
@@ -666,77 +616,69 @@
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAFeatureCall(tudresden.ocl.parser.node.AFeatureCall)
*/
@SuppressWarnings("unchecked")
- public void caseAFeatureCall(AFeatureCall node)
- {
+ public void caseAFeatureCall(AFeatureCall node) {
Object subject = val;
Object feature = null;
Vector<Object> parameters = null;
-
+
inAFeatureCall(node);
- if(node.getPathName() != null)
- {
- // TODO support other name kinds
+ if (node.getPathName() != null) {
+ // TODO support other name kinds
node.getPathName().apply(this);
-
+
feature = node.getPathName().toString().trim();
}
- if(node.getTimeExpression() != null)
- {
+ if (node.getTimeExpression() != null) {
// XXX hypothesis: no time expression (inv)
node.getTimeExpression().apply(this);
}
- if(node.getQualifiers() != null)
- {
+ if (node.getQualifiers() != null) {
// TODO understand qualifiers
node.getQualifiers().apply(this);
}
- if(node.getFeatureCallParameters() != null)
- {
- val = null;
+ if (node.getFeatureCallParameters() != null) {
+ val = null;
node.getFeatureCallParameters().apply(this);
-
+
parameters = (Vector<Object>) val;
} else {
parameters = new Vector<Object>();
}
-
+
val = runFeatureCall(subject, feature, fwd, parameters);
outAFeatureCall(node);
}
-
- public void caseAActualParameterList(AActualParameterList node)
- {
- Vector<Object> list = new Vector<Object>();
+
+ public void caseAActualParameterList(AActualParameterList node) {
+ Vector<Object> list = new Vector<Object>();
inAActualParameterList(node);
- if(node.getExpression() != null)
- {
+ if (node.getExpression() != null) {
val = null;
node.getExpression().apply(this);
list.add(val);
}
{
-
+
Object temp[] = node.getActualParameterListTail().toArray();
- for(int i = 0; i < temp.length; i++)
- {
+ for (int i = 0; i < temp.length; i++) {
val = null;
- ((PActualParameterListTail) temp[i]).apply(this);
+ ((PActualParameterListTail) temp[i]).apply(this);
list.add(val);
}
}
-
+
val = list;
outAActualParameterList(node);
}
-
- /** HELPER METHODS **/
+
+ /** HELPER METHODS * */
private boolean asBoolean(Object value, Object node) {
if (value instanceof Boolean) {
return (Boolean) value;
} else {
errorNotType(node, "Boolean", false);
return false;
- }
+ }
}
private int asInteger(Object value, Object node) {
@@ -745,32 +687,34 @@
} else {
errorNotType(node, "integer", 0);
return 0;
- }
+ }
}
@SuppressWarnings("unchecked")
- private Object runFeatureCall(Object subject, Object feature, Object type, Vector<Object> parameters) {
- //LOG.debug("OCL FEATURE CALL: " + subject + ""+ type +""+ feature + "" + parameters);
-
+ private Object runFeatureCall(Object subject, Object feature, Object type,
+ Vector<Object> parameters) {
+ // LOG.debug("OCL FEATURE CALL: " + subject + ""+ type +""+ feature + ""
+ // + parameters);
+
if (parameters == null) {
parameters = new Vector<Object>();
}
-
+
return interp.invokeFeature(vt, subject, feature.toString().trim(),
type.toString().trim(), parameters.toArray());
}
-
- /** Error Handling **/
+
+ /** Error Handling * */
private void errorNotType(Object node, String type, Object dft) {
- LOG.error("OCL does not evaluate to a "+type+ " expression!! Exp: "
+ LOG.error("OCL does not evaluate to a " + type + " expression!! Exp: "
+ node + " Val: " + val);
val = dft;
}
private void error(Object node) {
- LOG.error("Unknown error processing OCL exp!! Exp: "
- + node + " Val: " + val);
+ LOG.error("Unknown error processing OCL exp!! Exp: " + node + " Val: "
+ + val);
val = null;
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/EvaluateInvariant.java 2008-07-18 07:35:05-0700
@@ -30,7 +30,7 @@
/**
* Evaluates OCL invariants, this class should not depend on the model
- * subsystem.
+ * subsystem.
*
* @author maurelio1234
*/
@@ -39,8 +39,8 @@
/**
* Logger.
*/
- //private static final Logger LOG = Logger.getLogger(EvaluateInvariant.class);
-
+ // private static final Logger LOG =
+ // Logger.getLogger(EvaluateInvariant.class);
/**
* Is this invariant satified?
*/
@@ -56,7 +56,7 @@
private ModelInterpreter mi;
/**
- * Constructor
+ * Constructor
*
* @param modelElement self
* @param mi model interpreter
@@ -74,7 +74,7 @@
return ok;
}
- /** Interpreter Code **/
+ /** Interpreter Code * */
/**
* @see tudresden.ocl.parser.analysis.DepthFirstAdapter#caseAConstraint(tudresden.ocl.parser.node.AConstraint)
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/InvalidOclException.java 2008-07-18 07:35:05-0700
@@ -26,13 +26,13 @@
/**
* Exception thrown when an invalid ocl is set
- *
+ *
* @author maurelio1234
*/
public class InvalidOclException extends Exception {
-
+
/**
- * Default Constructor
+ * Default Constructor
*
* @param ocl
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/LambdaEvaluator.java 2008-07-18 07:35:05-0700
@@ -28,12 +28,12 @@
/**
* Evaluates an OCL expression given a variable table
- *
+ *
* @author maurelio1234
*/
public interface LambdaEvaluator {
/**
- * Evaluates the given OCL expression
+ * Evaluates the given OCL expression
*
* @param vt variable table
* @param exp expression
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/ModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -28,9 +28,9 @@
/**
* Actually interprets the feature and operations in the model, in the sense
- * that the OclInterpreter is only responsible for interpreting the OCL
+ * that the OclInterpreter is only responsible for interpreting the OCL
* constructors
- *
+ *
* @author maurelio1234
*/
public interface ModelInterpreter {
@@ -53,13 +53,13 @@
/**
* Looks for a built-in symbol. In the case that not all possible built-in
- * symbols are not in the variable table, the remaining ones should be
+ * symbols are not in the variable table, the remaining ones should be
* resolved using this method. This should be the case, e.g., for the names
- * of the UML metaclasses.
+ * of the UML metaclasses.
*
* @param sym the symbol name
* @return the symbol value, or null if the passed symbol is not built-in
*/
Object getBuiltInSymbol(String sym);
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/OclInterpreter.java 2008-07-18 07:35:05-0700
@@ -28,7 +28,6 @@
import java.io.StringReader;
import java.util.Vector;
-import org.apache.log4j.Logger;
import org.argouml.cognitive.Critic;
import tudresden.ocl.parser.OclParser;
@@ -36,9 +35,9 @@
import tudresden.ocl.parser.node.Start;
/**
- * Encapsulates actual interpretation of the OCL expressions for
- * OCL critics provided by a Profile
- *
+ * Encapsulates actual interpretation of the OCL expressions for OCL critics
+ * provided by a Profile
+ *
* @author maurelio1234
*/
public class OclInterpreter {
@@ -46,29 +45,28 @@
/**
* Logger.
*/
- //private static final Logger LOG = Logger.getLogger(OclInterpreter.class);
-
+ // private static final Logger LOG = Logger.getLogger(OclInterpreter.class);
/**
* Parser OCL tree
*/
- private Start tree = null;
+ private Start tree = null;
/**
* The model interpreter
*/
private ModelInterpreter modelInterpreter;
-
+
/**
* Creates a new OCL interpreter for a given OCL expression
*
* @param ocl expression
- * @param interpreter
- * @throws InvalidOclException
+ * @param interpreter
+ * @throws InvalidOclException
*/
public OclInterpreter(String ocl, ModelInterpreter interpreter)
throws InvalidOclException {
this.modelInterpreter = interpreter;
-
+
Lexer lexer = new Lexer(new PushbackReader(new StringReader(ocl), 2));
OclParser parser = new OclParser(lexer);
@@ -81,11 +79,10 @@
}
/**
- * Checks whether this OCL expression is applicable to a given
- * model element
+ * Checks whether this OCL expression is applicable to a given model element
*
* @param modelElement the ModelElement
- * @return if is applicable
+ * @return if is applicable
*/
public boolean applicable(Object modelElement) {
ContextApplicable ca = new ContextApplicable(modelElement);
@@ -94,8 +91,8 @@
}
/**
- * Checks if this expression (invariant) is satisfied for
- * the given model element
+ * Checks if this expression (invariant) is satisfied for the given model
+ * element
*
* @param modelElement the ModelElement
* @return if is satisfied
@@ -108,15 +105,14 @@
}
/**
- * Computes and returns the set of triggers for this
- * constraint.
+ * Computes and returns the set of triggers for this constraint.
*
* @see Critic#addTrigger(String)
- * @return the set of triggers
+ * @return the set of triggers
*/
public Vector<String> getTriggers() {
ComputeTriggers ct = new ComputeTriggers();
- tree.apply(ct);
+ tree.apply(ct);
return ct.getTriggers();
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Bag.java 2008-07-18 07:35:05-0700
@@ -28,16 +28,15 @@
/**
* Represent OCL bags (sets which allow repeated elements
- *
+ *
* @author maurelio1234
* @param <E> the type
*/
public interface Bag<E> extends Set<E> {
-
/**
- * Counts the number of repetitons of E in this Bag,
- * if E is not present return 0
+ * Counts the number of repetitons of E in this Bag, if E is not present
+ * return 0
*
* @param element
* @return the number of occourrences of E in this bag
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/CollectionsModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -80,45 +80,374 @@
vt.put(varName, oldVal);
return col;
+ } else if (feature.toString().trim().equals("reject")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = cloneCollection((Collection) subject);
+ Vector<Object> remove = new Vector<Object>();
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+
+ for (Object object : col) {
+ vt.put(varName, object);
+ Object res = eval.evaluate(vt, exp);
+ if (res instanceof Boolean && (Boolean) res) {
+ // if test is ok this element should not
+ // be in the result set
+ remove.add(object);
+ }
+ }
+
+ col.removeAll(remove);
+ vt.put(varName, oldVal);
+
+ return col;
} else if (feature.toString().trim().equals("forAll")) {
Vector<String> vars = (Vector<String>) parameters[0];
Object exp = parameters[1];
LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
- return doForAll(vt, (Collection)subject, vars, exp, eval);
+ return doForAll(vt, (Collection) subject, vars, exp, eval);
+ } else if (feature.toString().trim().equals("collect")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = (Collection) subject;
+ Bag<Object> res = new HashBag<Object>();
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+
+ for (Object object : col) {
+ vt.put(varName, object);
+
+ Object val = eval.evaluate(vt, exp);
+ res.add(val);
+ }
+
+ vt.put(varName, oldVal);
+
+ return col;
+ } else if (feature.toString().trim().equals("exists")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = (Collection) subject;
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+
+ for (Object object : col) {
+ vt.put(varName, object);
+
+ Object val = eval.evaluate(vt, exp);
+ if (val instanceof Boolean && (Boolean) val) {
+ return true;
+ }
+ }
+
+ vt.put(varName, oldVal);
+
+ return false;
+ } else if (feature.toString().trim().equals("isUnique")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = (Collection) subject;
+ Bag<Object> res = new HashBag<Object>();
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+
+ for (Object object : col) {
+ vt.put(varName, object);
+
+ Object val = eval.evaluate(vt, exp);
+ res.add(val);
+ if (res.count(val) > 1) {
+ return false;
+ }
+ }
+
+ vt.put(varName, oldVal);
+
+ return true;
}
+ } else if (feature.toString().trim().equals("one")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = (Collection) subject;
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+ boolean found = false;
+
+ for (Object object : col) {
+ vt.put(varName, object);
+
+ Object val = eval.evaluate(vt, exp);
+ if (val instanceof Boolean && (Boolean) val) {
+ if (!found) {
+ found = true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ vt.put(varName, oldVal);
+
+ return found;
+ } else if (feature.toString().trim().equals("any")) {
+ Vector<String> vars = (Vector<String>) parameters[0];
+ Object exp = parameters[1];
+ LambdaEvaluator eval = (LambdaEvaluator) parameters[2];
+
+ Collection col = (Collection) subject;
+
+ // TODO is it possible to use more than one variable?
+ String varName = vars.elementAt(0);
+ Object oldVal = vt.get(varName);
+
+ for (Object object : col) {
+ vt.put(varName, object);
+
+ Object val = eval.evaluate(vt, exp);
+ if (val instanceof Boolean && (Boolean) val) {
+ return object;
+ }
+ }
+
+ vt.put(varName, oldVal);
+
+ return null;
}
+
+ // TODO implement iterate()
+ // TODO implement sortedBy()
+ // TODO implement subSequence()
}
- if (subject instanceof Set) {
+ // these operations are ok for lists too
+ if (subject instanceof Collection) {
if (type.equals("->")) {
if (feature.equals("size")) {
- return ((Set) subject).size();
+ return ((Collection) subject).size();
+ }
+
+ if (feature.equals("includes")) {
+ return ((Collection) subject).contains(parameters[0]);
+ }
+
+ if (feature.equals("excludes")) {
+ return !((Collection) subject).contains(parameters[0]);
+ }
+
+ if (feature.equals("count")) {
+ return (new HashBag<Object>((Collection) subject))
+ .count(parameters[0]);
+ }
+
+ if (feature.equals("includesAll")) {
+
+ Collection col = (Collection) parameters[0];
+ for (Object object : col) {
+ if (!((Collection) subject).contains(object)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ if (feature.equals("excludesAll")) {
+
+ Collection col = (Collection) parameters[0];
+ for (Object object : col) {
+ if (((Collection) subject).contains(object)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ if (feature.equals("isEmpty")) {
+ return ((Collection) subject).isEmpty();
+ }
+
+ if (feature.equals("notEmpty")) {
+ return !((Collection) subject).isEmpty();
+ }
+
+ if (feature.equals("asSequence")) {
+ return new ArrayList<Object>((Collection) subject);
+ }
+
+ if (feature.equals("asBag")) {
+ return new HashBag<Object>((Collection) subject);
+ }
+
+ if (feature.equals("asSet")) {
+ return new HashSet<Object>((Collection) subject);
+ }
+
+ // TODO support real numbers
+ if (feature.equals("sum")) {
+ Integer sum = 0;
+
+ Collection col = (Collection) subject;
+ for (Object object : col) {
+ sum += (Integer) object;
+ }
+ return sum;
+ }
+
+ if (feature.equals("union")) {
+ Collection copy = cloneCollection((Collection) subject);
+ copy.addAll((Collection) parameters[0]);
+ return copy;
+ }
+
+ if (feature.equals("append")) {
+ Collection copy = cloneCollection((Collection) subject);
+ copy.add(parameters[0]);
+ return copy;
+ }
+
+ if (feature.equals("prepend")) {
+ Collection copy = cloneCollection((Collection) subject);
+ if (copy instanceof List) {
+ ((List)copy).add(0, parameters[0]);
+ } else {
+ copy.add(parameters[0]);
+ }
+ return copy;
+ }
+ }
+ }
+
+ if (subject instanceof List) {
+ if (type.equals("->")) {
+ if (feature.equals("at")) {
+ return ((List)subject).get((Integer) parameters[0]);
+ }
+
+ if (feature.equals("first")) {
+ return ((List)subject).get(0);
+ }
+
+ if (feature.equals("last")) {
+ return ((List)subject).get(((List)subject).size());
+ }
+ }
+ }
+ // these operations are ok for bags too
+ if (subject instanceof Set) {
+ if (type.equals("->")) {
+
+ if (feature.equals("intersection")) {
+ Set c1 = (Set) subject;
+ Set c2 = (Set) parameters[0];
+ Set r = new HashSet<Object>();
+
+ for (Object o : c1) {
+ if (c2.contains(o)) {
+ r.add(o);
+ }
+ }
+
+ for (Object o : c2) {
+ if (c1.contains(o)) {
+ r.add(o);
+ }
+ }
+
+ return r;
+ }
+
+ if (feature.equals("including")) {
+ Set copy = (Set) cloneCollection((Set) subject);
+ copy.add(parameters[0]);
+ return copy;
+ }
+
+ if (feature.equals("excluding")) {
+ Set copy = (Set) cloneCollection((Set) subject);
+ copy.remove(parameters[0]);
+ return copy;
+ }
+
+ if (feature.equals("symmetricDifference")) {
+ Set c1 = (Set) subject;
+ Set c2 = (Set) parameters[0];
+ Set r = new HashSet<Object>();
+
+ for (Object o : c1) {
+ if (!c2.contains(o)) {
+ r.add(o);
+ }
+ }
+
+ for (Object o : c2) {
+ if (!c1.contains(o)) {
+ r.add(o);
+ }
+ }
+
+ return r;
+ }
+ }
+ }
+
+ if (subject instanceof Bag) {
+ if (type.equals("->")) {
+ if (feature.equals("count")) {
+ return ((Bag) subject).count(parameters[0]);
}
}
}
+ if (!(subject instanceof Collection)) {
+ if (type.equals("->")) {
+ Set ns = new HashSet();
+ ns.add(subject);
+ return ns;
+ }
+ }
return null;
}
- private boolean doForAll(HashMap<String,Object> vt, Collection collection, Vector<String> vars, Object exp, LambdaEvaluator eval) {
+ private boolean doForAll(HashMap<String, Object> vt, Collection collection,
+ Vector<String> vars, Object exp, LambdaEvaluator eval) {
if (vars.isEmpty()) {
- return (Boolean) eval.evaluate(vt, exp);
+ return (Boolean) eval.evaluate(vt, exp);
} else {
String var = vars.firstElement();
vars.removeElement(var);
Object oldval = vt.get(var);
-
+
for (Object element : collection) {
vt.put(var, element);
-
+
boolean ret = doForAll(vt, collection, vars, exp, eval);
-
+
if (!ret) {
return false;
- }
+ }
}
-
+
vt.put(var, oldval);
}
return true;
@@ -126,15 +455,15 @@
@SuppressWarnings("unchecked")
private Collection cloneCollection(Collection col) {
- if (col instanceof Set) {
- return new HashSet(col);
- } else if (col instanceof List) {
+ if (col instanceof List) {
return new ArrayList(col);
} else if (col instanceof Bag) {
return new HashBag(col);
+ } else if (col instanceof Set) {
+ return new HashSet(col);
} else {
throw new IllegalArgumentException();
- }
+ }
}
/**
@@ -144,5 +473,4 @@
return null;
}
-
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/HashBag.java 2008-07-18 07:35:05-0700
@@ -28,7 +28,6 @@
import java.util.HashMap;
import java.util.Iterator;
-
/**
* An implementation for the Bag interface
*
@@ -37,7 +36,14 @@
*/
public class HashBag<E> implements Bag<E> {
- private HashMap<E,Integer> map = new HashMap<E,Integer>();
+ private HashMap<E, Integer> map = new HashMap<E, Integer>();
+
+ /**
+ * Default Constructor
+ *
+ */
+ public HashBag() {
+ }
/**
* Creates a new Bag from a Collection
@@ -46,15 +52,16 @@
*/
@SuppressWarnings("unchecked")
public HashBag(Collection col) {
+ this();
addAll(col);
}
-
+
/**
* @see org.argouml.profile.internal.ocl.uml14.Bag#count(java.lang.Object)
*/
public int count(Object element) {
Integer c = map.get(element);
- return c == null ? 0 : c;
+ return c == null ? 0 : c;
}
/**
@@ -67,7 +74,7 @@
} else {
map.put(e, map.get(e) + 1);
}
-
+
return true;
}
@@ -78,7 +85,7 @@
public boolean addAll(Collection c) {
for (Object object : c) {
add((E) object);
- }
+ }
return true;
}
@@ -93,7 +100,7 @@
* @see java.util.Set#contains(java.lang.Object)
*/
public boolean contains(Object o) {
- return count(o) > 0;
+ return count(o) > 0;
}
/**
@@ -157,9 +164,9 @@
*/
public int size() {
int sum = 0;
-
+
Iterator<E> it = iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
E next = it.next();
sum += count(next);
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/ModelAccessModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -48,7 +48,9 @@
.getLogger(ModelAccessModelInterpreter.class);
/**
- * @see org.argouml.profile.internal.ocl.ModelInterpreter#invokeFeature(java.util.HashMap, java.lang.Object, java.lang.String, java.lang.String, java.lang.Object[])
+ * @see org.argouml.profile.internal.ocl.ModelInterpreter#invokeFeature(java.util.HashMap,
+ * java.lang.Object, java.lang.String, java.lang.String,
+ * java.lang.Object[])
*/
@SuppressWarnings("unchecked")
public Object invokeFeature(HashMap<String, Object> vt, Object subject,
@@ -57,7 +59,7 @@
if (subject == null) {
subject = vt.get("self");
}
-
+
if (Model.getFacade().isAModelElement(subject)) {
if (type.equals(".")) {
if (feature.equals("name")) {
@@ -65,7 +67,7 @@
}
}
}
-
+
if (Model.getFacade().isAClass(subject)) {
if (type.equals(".")) {
if (feature.equals("feature")) {
@@ -73,10 +75,10 @@
ret.addAll(Model.getCoreHelper().getAllAttributes(subject));
ret.addAll(Model.getCoreHelper().getOperationsInh(subject));
return ret;
- }
+ }
}
- }
-
+ }
+
return null;
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclAPIModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -39,12 +39,12 @@
*/
public class OclAPIModelInterpreter implements ModelInterpreter {
-
/**
* Logger.
*/
- private static final Logger LOG = Logger.getLogger(OclAPIModelInterpreter.class);
-
+ private static final Logger LOG = Logger
+ .getLogger(OclAPIModelInterpreter.class);
+
/**
* @see org.argouml.profile.internal.ocl.ModelInterpreter#invokeFeature(java.util.HashMap,
* java.lang.Object, java.lang.String, java.lang.String,
@@ -53,19 +53,19 @@
public Object invokeFeature(HashMap<String, Object> vt, Object subject,
String feature, String type, Object[] parameters) {
if (type.equals(".")) {
- // TODO implement the difference between oclIsKindOf and oclIsTypeOf
- if (feature.toString().trim().equals("oclIsKindOf") ||
- feature.toString().trim().equals("oclIsTypeOf")) {
-
- String typeName = ((OclType)parameters[0]).getName();
-
+ // TODO implement the difference between oclIsKindOf and oclIsTypeOf
+ if (feature.toString().trim().equals("oclIsKindOf")
+ || feature.toString().trim().equals("oclIsTypeOf")) {
+
+ String typeName = ((OclType) parameters[0]).getName();
+
if (typeName.equals("OclAny")) {
return true;
} else {
boolean applicable = false;
try {
- Method m = Facade.class.getDeclaredMethod("isA" + typeName,
- new Class[] { Object.class });
+ Method m = Facade.class.getDeclaredMethod("isA"
+ + typeName, new Class[] { Object.class });
if (m != null) {
applicable = (Boolean) m.invoke(Model.getFacade(),
new Object[] { subject });
@@ -76,11 +76,35 @@
return applicable;
}
}
-
+
if (subject instanceof OclType) {
if (feature.toString().trim().equals("name")) {
- return ((OclType)subject).getName();
- }
+ return ((OclType) subject).getName();
+ }
+ }
+
+ if (subject instanceof String) {
+ if (feature.toString().trim().equals("size")) {
+ return ((String) subject).length();
+ }
+
+ if (feature.toString().trim().equals("concat")) {
+ return ((String) subject).concat((String) parameters[0]);
+ }
+
+ if (feature.toString().trim().equals("toLower")) {
+ return ((String) subject).toLowerCase();
+ }
+
+ if (feature.toString().trim().equals("toUpper")) {
+ return ((String) subject).toUpperCase();
+ }
+
+ if (feature.toString().trim().equals("substring")) {
+ return ((String) subject).substring(
+ (Integer) parameters[0], (Integer) parameters[1]);
+ }
+
}
}
@@ -90,9 +114,10 @@
/**
* @see org.argouml.profile.internal.ocl.ModelInterpreter#getBuiltInSymbol(java.lang.String)
*/
- public Object getBuiltInSymbol(String sym) {
+ public Object getBuiltInSymbol(String sym) {
if (sym.equals("OclType")) {
return new OclType("OclType");
+ // TODO implement OCLExpression
} else if (sym.equals("OclExpression")) {
return new OclType("OclExpression");
}
@@ -102,5 +127,4 @@
return null;
}
-
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/OclType.java 2008-07-18 07:35:05-0700
@@ -35,7 +35,7 @@
* The name of the type
*/
private String name;
-
+
/**
* Default Constructor
*
@@ -51,5 +51,5 @@
public String getName() {
return name;
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/profile/internal/ocl/uml14/Uml14ModelInterpreter.java 2008-07-18 07:35:05-0700
@@ -34,7 +34,7 @@
public class Uml14ModelInterpreter extends CompositeModelInterpreter {
/**
- * Default Constructor
+ * Default Constructor
*/
public Uml14ModelInterpreter() {
addModelInterpreter(new ModelAccessModelInterpreter());
Modified: branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java&p2=branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/src/org/argouml/ui/explorer/rules/GoProfileToCritics.java 2008-07-18 07:35:05-0700
@@ -33,7 +33,7 @@
/**
* Show the critics exported by a Profile
- *
+ *
* @author maurelio1234
*/
public class GoProfileToCritics implements PerspectiveRule {
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/ProfileMother.java 2008-07-18 07:35:05-0700
@@ -45,27 +45,28 @@
import org.argouml.persistence.UmlFilePersister;
/**
- * Based on the
- * <a href="http://www.xpuniverse.com/2001/pdfs/Testing03.pdf">ObjectMother
- * design pattern</a>, provides reusable facilities to create profiles.
- *
+ * Based on the <a
+ * href="http://www.xpuniverse.com/2001/pdfs/Testing03.pdf">ObjectMother design
+ * pattern</a>, provides reusable facilities to create profiles.
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class ProfileMother {
-
+
private static final Logger LOG = Logger.getLogger(ProfileMother.class);
/**
* "profile"
*/
public static final String STEREOTYPE_NAME_PROFILE = "profile";
+
/**
* "st" the example stereotype name.
*/
public static final String STEREOTYPE_NAME_ST = "st";
/**
- * Create a simple profile model with a class named "foo" and with a
+ * Create a simple profile model with a class named "foo" and with a
* stereotype named "st".
*
* @return the profile model.
@@ -75,7 +76,7 @@
Object profileStereotype = getProfileStereotype();
getCoreHelper().addStereotype(model, profileStereotype);
Object fooClass = Model.getCoreFactory().buildClass("foo", model);
- getExtensionMechanismsFactory().buildStereotype(fooClass,
+ getExtensionMechanismsFactory().buildStereotype(fooClass,
STEREOTYPE_NAME_ST, model);
return model;
}
@@ -85,22 +86,21 @@
Collection<Object> models = new ArrayList<Object>();
models.add(umlProfile);
Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
- models);
+ models);
for (Object stereotype : stereotypes) {
- if (STEREOTYPE_NAME_PROFILE.equals(
- Model.getFacade().getName(stereotype)))
- return stereotype;
+ if (STEREOTYPE_NAME_PROFILE.equals(Model.getFacade().getName(
+ stereotype))) return stereotype;
}
return null;
}
-
+
private Object umlProfileModel;
Object getUmlProfileModel() {
if (ProfileFacade.isInitiated()) {
try {
- umlProfileModel = ProfileFacade.getManager().getUMLProfile().
- getProfilePackages().iterator().next();
+ umlProfileModel = ProfileFacade.getManager().getUMLProfile()
+ .getProfilePackages().iterator().next();
TestCase.assertTrue(getFacade().isAModel(umlProfileModel));
} catch (ProfileException e) {
LOG.error("Exception", e);
@@ -108,8 +108,8 @@
}
if (umlProfileModel == null) {
umlProfileModel = getModelManagementFactory().createModel();
- getExtensionMechanismsFactory().buildStereotype(
- umlProfileModel, STEREOTYPE_NAME_PROFILE, umlProfileModel);
+ getExtensionMechanismsFactory().buildStereotype(umlProfileModel,
+ STEREOTYPE_NAME_PROFILE, umlProfileModel);
}
return umlProfileModel;
}
@@ -124,7 +124,7 @@
public void saveProfileModel(Object model, File file) throws IOException {
FileOutputStream fileOut = new FileOutputStream(file);
try {
- XmiWriter xmiWriter = Model.getXmiWriter(model, fileOut, "x("
+ XmiWriter xmiWriter = Model.getXmiWriter(model, fileOut, "x("
+ UmlFilePersister.PERSISTENCE_VERSION + ")");
xmiWriter.write();
fileOut.flush();
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestCoreProfileReference.java 2008-07-18 07:35:05-0700
@@ -35,7 +35,7 @@
* @author Luis Sergio Oliveira (euluis)
*/
public class TestCoreProfileReference extends TestCase {
-
+
/**
* Tests {@link CoreProfileReference#CoreProfileReference(String)}.
*
@@ -44,20 +44,19 @@
public void testCtorHappyPath() throws MalformedURLException {
String fileName = "profileName.xmi";
ProfileReference reference = new CoreProfileReference(fileName);
- assertEquals(CoreProfileReference.PROFILES_RESOURCE_PATH + fileName,
- reference.getPath());
+ assertEquals(CoreProfileReference.PROFILES_RESOURCE_PATH + fileName,
+ reference.getPath());
assertEquals(
- new URL(CoreProfileReference.PROFILES_BASE_URL + fileName),
- reference.getPublicReference());
+ new URL(CoreProfileReference.PROFILES_BASE_URL + fileName),
+ reference.getPublicReference());
}
-
+
/**
* Tests that the constructor checks for empty file name.
*
* @throws MalformedURLException if the built URL is incorrect.
*/
- public void testCtorFailsWhenFileNameIsEmpty()
- throws MalformedURLException {
+ public void testCtorFailsWhenFileNameIsEmpty() throws MalformedURLException {
try {
new CoreProfileReference("");
// TODO: This requires that the tests be run with assertions
@@ -67,14 +66,13 @@
// expected
}
}
-
+
/**
* Tests that the constructor checks for null file name.
*
* @throws MalformedURLException if the built URL is incorrect.
*/
- public void testCtorFailsWhenFileNameIsNull()
- throws MalformedURLException {
+ public void testCtorFailsWhenFileNameIsNull() throws MalformedURLException {
try {
new CoreProfileReference(null);
// TODO: This requires that the tests be run with assertions
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileFacade.java 2008-07-18 07:35:05-0700
@@ -29,25 +29,24 @@
import junit.framework.TestCase;
/**
- *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileFacade extends TestCase {
private MockControl managerCtrl;
+
private ProfileManager manager;
- /*
+ /*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
- managerCtrl = MockControl.createControl(
- ProfileManager.class);
+ managerCtrl = MockControl.createControl(ProfileManager.class);
manager = (ProfileManager) managerCtrl.getMock();
ProfileFacade.setManager(manager);
}
-
+
@Override
protected void tearDown() throws Exception {
ProfileFacade.reset();
@@ -66,14 +65,14 @@
// expected
}
}
-
+
/**
* Test {@link ProfileFacade#register(Profile)}.
*/
public void testRegister() {
manager.registerProfile(null);
managerCtrl.replay();
-
+
ProfileFacade.register(null);
managerCtrl.verify();
}
@@ -84,7 +83,7 @@
public void testRemove() {
manager.removeProfile(null);
managerCtrl.replay();
-
+
ProfileFacade.remove((Profile) null);
managerCtrl.verify();
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileManager.java 2008-07-18 07:35:05-0700
@@ -36,13 +36,15 @@
/**
* Tests for a ProfileManager implementation.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileManager extends TestCase {
-
+
private Profile mockProfile;
+
private ProfileManager manager;
+
private String mockProfileClassName;
@Override
@@ -54,8 +56,9 @@
public String getDisplayName() {
return null;
}
+
@Override
- public Collection<Object> getProfilePackages()
+ public Collection<Object> getProfilePackages()
throws ProfileException {
return Collections.emptyList();
}
@@ -63,7 +66,7 @@
manager = ProfileFacade.getManager();
assertNotNull(manager);
}
-
+
@Override
protected void tearDown() throws Exception {
ProfileFacade.reset();
@@ -77,7 +80,7 @@
manager.registerProfile(mockProfile);
assertTrue(manager.getRegisteredProfiles().contains(mockProfile));
}
-
+
/**
* Test the {@link ProfileManager#removeProfile(Profile)} method.
*/
@@ -96,30 +99,30 @@
mockProfileClassName = mockProfile.getClass().getName();
assertNull(manager.getProfileForClass(mockProfileClassName));
manager.registerProfile(mockProfile);
- assertEquals(mockProfile, manager.getProfileForClass(
- mockProfileClassName));
+ assertEquals(mockProfile, manager
+ .getProfileForClass(mockProfileClassName));
manager.removeProfile(mockProfile);
assertNull(manager.getProfileForClass(mockProfileClassName));
}
-
+
/**
- * Tests the methods of {@link ProfileManager} related to default profiles
+ * Tests the methods of {@link ProfileManager} related to default profiles
* management.
*/
public void testDefaultProfilesManagement() {
- List<Object> initialDefaultProfiles =
- new ArrayList<Object>(manager.getDefaultProfiles());
+ List<Object> initialDefaultProfiles = new ArrayList<Object>(manager
+ .getDefaultProfiles());
assertNull(manager.getProfileForClass(mockProfileClassName));
manager.registerProfile(mockProfile);
manager.addToDefaultProfiles(mockProfile);
- assertEquals(initialDefaultProfiles.size() + 1,
- manager.getDefaultProfiles().size());
+ assertEquals(initialDefaultProfiles.size() + 1, manager
+ .getDefaultProfiles().size());
manager.removeFromDefaultProfiles(mockProfile);
- assertEquals(initialDefaultProfiles.size(),
- manager.getDefaultProfiles().size());
+ assertEquals(initialDefaultProfiles.size(), manager
+ .getDefaultProfiles().size());
assertFalse(manager.getDefaultProfiles().contains(mockProfile));
}
-
+
/**
* Test the method {@link ProfileManager#getUMLProfile()}.
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileMother.java 2008-07-18 07:35:05-0700
@@ -37,12 +37,12 @@
import junit.framework.TestCase;
/**
- *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileMother extends TestCase {
-
+
private ProfileMother mother;
+
private File testDir;
@Override
@@ -50,43 +50,57 @@
InitializeModel.initializeDefault();
mother = new ProfileMother();
}
-
+
+ /**
+ * test profile model creation
+ */
public void testCreateProfileModel() {
Object model = mother.createSimpleProfileModel();
assertNotNull(model);
Collection profileStereotypes = getFacade().getStereotypes(model);
assertEquals(1, profileStereotypes.size());
- assertEquals(ProfileMother.STEREOTYPE_NAME_PROFILE,
- getFacade().getName(profileStereotypes.iterator().next()));
+ assertEquals(ProfileMother.STEREOTYPE_NAME_PROFILE, getFacade()
+ .getName(profileStereotypes.iterator().next()));
}
-
+
+ /**
+ * test simple profile model creation
+ *
+ * @throws Exception
+ */
public void testCreateSimpleProfileModel() throws Exception {
final Object model = mother.createSimpleProfileModel();
- Collection<Object> models = new ArrayList<Object>() { {
+ Collection<Object> models = new ArrayList<Object>() {
+ {
add(model);
}
};
- Collection stereotypes =
- getExtensionMechanismsHelper().getStereotypes(models);
+ Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
+ models);
Object st = null;
for (Object stereotype : stereotypes) {
- if (ProfileMother.STEREOTYPE_NAME_ST.equals(
- getFacade().getName(stereotype))) {
+ if (ProfileMother.STEREOTYPE_NAME_ST.equals(getFacade().getName(
+ stereotype))) {
st = stereotype;
break;
}
}
assertNotNull("\"st\" stereotype not found in model.", st);
- assertTrue(Model.getExtensionMechanismsHelper().isStereotype(st,
+ assertTrue(Model.getExtensionMechanismsHelper().isStereotype(st,
ProfileMother.STEREOTYPE_NAME_ST, "Class"));
}
-
+
+ /**
+ * test save profile model
+ *
+ * @throws Exception
+ */
public void testSaveProfileModel() throws Exception {
Object model = mother.createSimpleProfileModel();
File file = new File(testDir, "testSaveProfileModel.xmi");
mother.saveProfileModel(model, file);
- assertTrue("The file to where the file was supposed to be saved "
+ assertTrue("The file to where the file was supposed to be saved "
+ "doesn't exist.", file.exists());
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestProfileReference.java 2008-07-18 07:35:05-0700
@@ -31,33 +31,32 @@
/**
* Tests for the ProfileReference class.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileReference extends TestCase {
-
+
/**
* Test correct call to constructor.
*
* @throws MalformedURLException if the URL is incorrect.
*/
public void testCtorHappyPath() throws MalformedURLException {
- new ProfileReference("systemId/name.xmi",
- new URL("file:///publicId/name.xmi"));
+ new ProfileReference("systemId/name.xmi", new URL(
+ "file:///publicId/name.xmi"));
}
-
+
/**
- * Test call to constructor with inconsistent file names in the path and
- * the publicReference arguments.
- *
- * NOTE: to run successfully this test you'll have to enable assertions.
+ * Test call to constructor with inconsistent file names in the path and the
+ * publicReference arguments. NOTE: to run successfully this test you'll
+ * have to enable assertions.
*
* @throws MalformedURLException if the URL is incorrect.
*/
- public void testCtorInconsistentFileNameDetected()
+ public void testCtorInconsistentFileNameDetected()
throws MalformedURLException {
try {
- new ProfileReference("/org/argouml/language/x/profile/name.xmi",
+ new ProfileReference("/org/argouml/language/x/profile/name.xmi",
new URL("http://argouml-x.tigris.org/iconsistentName.xmi"));
fail("Expected an AssertionError to be thrown!");
} catch (MalformedURLException e) {
@@ -66,22 +65,22 @@
// expected
}
}
-
+
/**
- * Checks that the path handed to the constructor is correctly returned by
+ * Checks that the path handed to the constructor is correctly returned by
* {@link ProfileReference#getPath()}.
*
* @throws MalformedURLException if the URL is incorrect.
*/
public void testGetPath() throws MalformedURLException {
String path = "/org/argouml/language/x/profile/name.xmi";
- ProfileReference profileReference = new ProfileReference(
- path, new URL("http://x.org/name.xmi"));
+ ProfileReference profileReference = new ProfileReference(path, new URL(
+ "http://x.org/name.xmi"));
assertEquals(path, profileReference.getPath());
}
-
+
/**
- * Checks that the publicReference handed to the constructor is correctly
+ * Checks that the publicReference handed to the constructor is correctly
* returned by {@link ProfileReference#getPublicReference()}.
*
* @throws MalformedURLException if the URL is incorrect.
@@ -89,7 +88,7 @@
public void testGetPublicReference() throws MalformedURLException {
URL publicReference = new URL("http://x.org/name.xmi");
ProfileReference profileReference = new ProfileReference(
- "/org/argouml/language/x/profile/name.xmi", publicReference);
+ "/org/argouml/language/x/profile/name.xmi", publicReference);
assertEquals(publicReference, profileReference.getPublicReference());
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestReaderModelLoader.java 2008-07-18 07:35:05-0700
@@ -38,7 +38,7 @@
/**
* Tests for the {@link ReaderModelLoader} class.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestReaderModelLoader extends TestCase {
@@ -49,7 +49,7 @@
Reader reader = new StringReader("dummy string");
new ReaderModelLoader(reader);
}
-
+
/**
* Test {@link ReaderModelLoader#loadModel(ProfileReference)}.
*
@@ -64,10 +64,10 @@
File file = new File(testDir, "testSaveProfileModel.xmi");
mother.saveProfileModel(model, file);
Reader reader = new FileReader(file);
- ProfileReference profileReference = new UserProfileReference(
- file.toURL().toExternalForm());
- Collection models = new ReaderModelLoader(reader).
- loadModel(profileReference);
+ ProfileReference profileReference = new UserProfileReference(file
+ .toURI().toURL().toExternalForm());
+ Collection models = new ReaderModelLoader(reader)
+ .loadModel(profileReference);
assertNotNull(models);
assertTrue(models.size() >= 1);
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestSubsystemInit.java 2008-07-18 07:35:05-0700
@@ -31,11 +31,11 @@
/**
* Test cases for the initialization of the profile subsystem.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestSubsystemInit extends TestCase {
-
+
private InitProfileSubsystem initSubsystem;
@Override
@@ -45,11 +45,15 @@
initSubsystem = new InitProfileSubsystem();
}
+ /**
+ * tests subsystem initialization
+ */
public void testInitMakesManagerAvailableInFacade() {
try {
ProfileFacade.getManager();
fail("ProfileFacade shouldn't be initialized!");
- } catch (RuntimeException e) { }
+ } catch (RuntimeException e) {
+ }
initSubsystem.init();
assertNotNull(ProfileFacade.getManager());
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserDefinedProfile.java 2008-07-18 07:35:05-0700
@@ -43,7 +43,7 @@
* @authos maurelio1234
*/
public class TestUserDefinedProfile extends TestCase {
-
+
private File testDir;
@Override
@@ -51,16 +51,16 @@
super.setUp();
InitializeModel.initializeDefault();
ProfileFacade.setManager(new ProfileManagerImpl());
-
+
testDir = FileHelper.setUpDir4Test(getClass());
}
-
+
@Override
protected void tearDown() throws Exception {
FileHelper.deleteDir(testDir);
super.tearDown();
}
-
+
/**
* Test loading of a very simple profile via its constructor. Check that its
* display name contains the file name.
@@ -79,15 +79,14 @@
}
/**
- * Test the constructor used for loading a profile from a Jar file
- *
- * TODO Test FigNode!
+ * Test the constructor used for loading a profile from a Jar file TODO Test
+ * FigNode!
*
* @throws Exception if something goes wrong
*/
public void testLoadingAsFromJar() throws Exception {
ProfileManager pm = ProfileFacade.getManager();
-
+
// create profile model
ProfileMother profileMother = new ProfileMother();
Object model = profileMother.createSimpleProfileModel();
@@ -99,15 +98,15 @@
null, null, null);
Set<CrUML> critics = new HashSet<CrUML>();
critics.add(critic);
-
+
Set<String> profiles = new HashSet<String>();
profiles.add(pm.getUMLProfile().getProfileIdentifier());
-
+
Profile profile = new UserDefinedProfile("displayName", profileFile
.toURI().toURL(), critics, profiles);
-
+
assertEquals(profile.getDisplayName(), "displayName");
assertTrue(profile.getDependencies().contains(pm.getUMLProfile()));
- assertTrue(profile.getCritics().contains(critic));
+ assertTrue(profile.getCritics().contains(critic));
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/TestUserProfileReference.java 2008-07-18 07:35:05-0700
@@ -32,38 +32,35 @@
/**
* Unit tests for UserProfileReference class.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestUserProfileReference extends TestCase {
-
+
/**
- * Tests {@link UserProfileReference#UserProfileReference(String)} in the
+ * Tests {@link UserProfileReference#UserProfileReference(String)} in the
* happy path.
*
* @throws MalformedURLException if the built URL is incorrect.
*/
public void testCtorHappyPath() throws MalformedURLException {
String fileName = "profileName.xmi";
- // [euluis] Using Windows style initial path, don't know if this fails
+ // [euluis] Using Windows style initial path, don't know if this fails
// in *nixes.
- String path = "C:" + File.separatorChar + "userProfilesDir"
- + File.separatorChar + fileName;
+ String path = "C:" + File.separatorChar + "userProfilesDir"
+ + File.separatorChar + fileName;
ProfileReference reference = new UserProfileReference(path);
assertEquals(path, reference.getPath());
- assertEquals(
- new URL(UserProfileReference.DEFAULT_USER_PROFILE_BASE_URL
- + fileName),
- reference.getPublicReference());
+ assertEquals(new URL(UserProfileReference.DEFAULT_USER_PROFILE_BASE_URL
+ + fileName), reference.getPublicReference());
}
-
+
/**
* Tests that the constructor checks for empty file name.
*
* @throws MalformedURLException if the built URL is incorrect.
*/
- public void testCtorFailsWhenFileNameIsEmpty()
- throws MalformedURLException {
+ public void testCtorFailsWhenFileNameIsEmpty() throws MalformedURLException {
try {
new UserProfileReference("");
fail("Expecting AssertionError due to empty file name.");
@@ -71,14 +68,13 @@
// expected
}
}
-
+
/**
* Tests that the constructor checks for null file name.
*
* @throws MalformedURLException if the built URL is incorrect.
*/
- public void testCtorFailsWhenFileNameIsNull()
- throws MalformedURLException {
+ public void testCtorFailsWhenFileNameIsNull() throws MalformedURLException {
try {
new UserProfileReference(null);
fail("Expecting NullPointerException due to null path.");
@@ -86,5 +82,5 @@
// expected
}
}
-
+
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileJava.java 2008-07-18 07:35:05-0700
@@ -32,11 +32,11 @@
/**
* Tests for the ProfileJava class.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileJava extends TestCase {
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -44,10 +44,20 @@
new InitProfileSubsystem().init();
}
+ /**
+ * test java profile creation
+ *
+ * @throws ProfileException
+ */
public void testProfileJava() throws ProfileException {
new ProfileJava(new ProfileUML());
}
-
+
+ /**
+ * test java profile creation
+ *
+ * @throws Exception
+ */
public void testProfileJavaNoArgs() throws Exception {
new ProfileJava();
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/TestProfileManagerImpl.java 2008-07-18 07:35:05-0700
@@ -36,11 +36,11 @@
/**
* Tests for the ProfileManagerImpl class.
- *
+ *
* @author Luis Sergio Oliveira (euluis)
*/
public class TestProfileManagerImpl extends TestCase {
-
+
private ProfileManager manager;
@Override
@@ -50,30 +50,39 @@
manager = new ProfileManagerImpl();
}
+ /**
+ * test profile manager
+ */
public void testProfileManagerImpl() {
List<Profile> registeredProfiles = manager.getRegisteredProfiles();
assertTrue(2 <= registeredProfiles.size());
Set<String> internalProfileNameSet = new HashSet<String>();
for (Profile profile : registeredProfiles) {
- if (profile.getDisplayName().equals(ProfileUML.NAME)
+ if (profile.getDisplayName().equals(ProfileUML.NAME)
|| profile.getDisplayName().equals(ProfileJava.NAME))
internalProfileNameSet.add(profile.getDisplayName());
}
assertEquals(2, internalProfileNameSet.size());
}
-
+
+ /**
+ * test remove profile
+ */
public void testRemoveProfileThatIsntDefault() {
- Profile javaProfile = manager.getProfileForClass(
- ProfileJava.class.getName());
+ Profile javaProfile = manager.getProfileForClass(ProfileJava.class
+ .getName());
assertNotNull(javaProfile);
assertTrue(manager.getRegisteredProfiles().contains(javaProfile));
manager.removeProfile(javaProfile);
assertFalse(manager.getRegisteredProfiles().contains(javaProfile));
}
-
+
+ /**
+ * test remove profile
+ */
public void testRemoveDefaultProfile() {
- Profile umlProfile = manager.getProfileForClass(
- ProfileUML.class.getName());
+ Profile umlProfile = manager.getProfileForClass(ProfileUML.class
+ .getName());
assertNotNull(umlProfile);
assertTrue(manager.getRegisteredProfiles().contains(umlProfile));
assertTrue(manager.getDefaultProfiles().contains(umlProfile));
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL.java 2008-07-18 07:35:05-0700
@@ -55,13 +55,12 @@
String ocl = "context Actor inv: 0 > 2";
- CrOCL cr = new CrOCL(ocl, null, null, null,
- null, null, null);
-
+ CrOCL cr = new CrOCL(ocl, null, null, null, null, null, null);
+
assertEquals(cr.predicate2(obj1, Designer.theDesigner()),
Critic.PROBLEM_FOUND);
assertEquals(cr.predicate2(obj2, Designer.theDesigner()),
Critic.NO_PROBLEM);
-
+
}
}
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestCrOCL2.java 2008-07-18 07:35:05-0700
@@ -37,15 +37,15 @@
* @author maurelio1234
*/
public class TestCrOCL2 extends TestCase {
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
InitializeModel.initializeDefault();
}
-
+
/**
- * Test collections operations in objects
+ * Test collections operations in objects
*
* @throws Exception
*/
Modified: branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java?view=diff&rev=15297&p1=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java&p2=branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java&r1=15296&r2=15297
==============================================================================
--- branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java (original)
+++ branches/gsoc2008/work_midterm_maurelio1234/tests/org/argouml/profile/internal/ocl/TestOclInterpreter.java 2008-07-18 07:35:05-0700
@@ -48,7 +48,7 @@
return null;
}
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -68,11 +68,11 @@
OclInterpreter interpreter = new OclInterpreter(ocl,
new DefaultModelInterpreter());
-
+
assertTrue(interpreter.applicable(obj1));
assertFalse(interpreter.applicable(obj2));
}
-
+
/**
* Test <code>getTriggers</code> operation
*
@@ -83,7 +83,7 @@
OclInterpreter interpreter = new OclInterpreter(ocl,
new DefaultModelInterpreter());
-
+
assertTrue(interpreter.getTriggers().contains("actor"));
}
@@ -102,7 +102,7 @@
new DefaultModelInterpreter());
OclInterpreter interpreter2 = new OclInterpreter(ocl2,
new DefaultModelInterpreter());
-
+
assertTrue(interpreter1.check(obj));
assertFalse(interpreter2.check(obj));
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.