Coverage Report - org.argouml.profile.Profile
 
Classes in this File Line Coverage Branch Coverage Complexity
Profile
82%
23/28
66%
4/6
1.286
 
 1  
 /* $Id: Profile.java 18257 2010-04-13 17:58:32Z tfmorris $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2007,2010 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    maurelio1234 - Initial implementation
 11  
  *    Tom Morris
 12  
  *****************************************************************************
 13  
  *
 14  
  * Some portions of this file was previously release using the BSD License:
 15  
  */
 16  
 
 17  
 // Copyright (c) 2007-2008 The Regents of the University of California. All
 18  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 19  
 // software and its documentation without fee, and without a written
 20  
 // agreement is hereby granted, provided that the above copyright notice
 21  
 // and this paragraph appear in all copies. This software program and
 22  
 // documentation are copyrighted by The Regents of the University of
 23  
 // California. The software program and documentation are supplied "AS
 24  
 // IS", without any accompanying services from The Regents. The Regents
 25  
 // does not warrant that the operation of the program will be
 26  
 // uninterrupted or error-free. The end-user understands that the program
 27  
 // was developed for research purposes and is advised not to rely
 28  
 // exclusively on the program for any reason. IN NO EVENT SHALL THE
 29  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 30  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 31  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 32  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 33  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 34  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 35  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 36  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 37  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 38  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 39  
 
 40  
 package org.argouml.profile;
 41  
 
 42  
 import java.util.Collection;
 43  
 import java.util.Collections;
 44  
 import java.util.HashSet;
 45  
 import java.util.Set;
 46  
 
 47  
 import org.argouml.cognitive.Critic;
 48  
 
 49  
 /**
 50  
  * Abstract class representing an ArgoUML Profile. It contains default types and
 51  
  * presentation characteristics that can be tailored to various modeling
 52  
  * environments.
 53  
  * <p>
 54  
  * An ArgoUML Profile consists of:<ul>
 55  
  * <li>a UML profile (a special type of UML Model)
 56  
  * <li>a set of ArgoUML Critics
 57  
  * <li>a set of default types for parameters, etc
 58  
  * <li>presentation characteristics for ...
 59  
  * 
 60  
  * @author maurelio1234
 61  
  */
 62  3600
 public abstract class Profile {
 63  
 
 64  3600
     private Set<String> dependencies = new HashSet<String>();
 65  
 
 66  
     /**
 67  
      * The critics provided by this profile
 68  
      */
 69  3600
     private Set<Critic> critics = new HashSet<Critic>();
 70  
 
 71  
     /**
 72  
      * Add a dependency on the given profile from this profile.
 73  
      * 
 74  
      * @param p the profile
 75  
      * @throws IllegalArgumentException never thrown
 76  
      */
 77  
     protected final void addProfileDependency(Profile p)
 78  
         throws IllegalArgumentException {
 79  0
         addProfileDependency(p.getProfileIdentifier());
 80  0
     }
 81  
 
 82  
     /**
 83  
      * Add a dependency on the given profile from this profile.
 84  
      * 
 85  
      * @param profileIdentifier the profile identifier
 86  
      */
 87  
     protected void addProfileDependency(String profileIdentifier) {
 88  900
         dependencies.add(profileIdentifier);
 89  900
     }
 90  
 
 91  
     /**
 92  
      * @return the dependencies
 93  
      */
 94  
     public final Set<Profile> getDependencies() {
 95  3816
         if (ProfileFacade.isInitiated()) {
 96  3816
             Set<Profile> ret = new HashSet<Profile>();
 97  3816
             for (String pid : dependencies) {
 98  954
                 Profile p = ProfileFacade.getManager()
 99  
                         .lookForRegisteredProfile(pid);
 100  954
                 if (p != null) {
 101  954
                     ret.add(p);
 102  954
                     ret.addAll(p.getDependencies());
 103  
                 }
 104  954
             }
 105  3816
             return ret;
 106  
         } else {
 107  0
             return new HashSet<Profile>();
 108  
         }
 109  
     }
 110  
 
 111  
     /**
 112  
      * @return the ids of the dependencies
 113  
      */
 114  
     public final Set<String> getDependenciesID() {
 115  0
         return dependencies;
 116  
     }
 117  
 
 118  
     /**
 119  
      * @return the name for this profile
 120  
      */
 121  
     public abstract String getDisplayName();
 122  
 
 123  
     /**
 124  
      * @return the formating strategy offered by this profile, if any. Returns
 125  
      *         <code>null</code> if this profile has no formating strategy.
 126  
      */
 127  
     public FormatingStrategy getFormatingStrategy() {
 128  4770
         return null;
 129  
     }
 130  
 
 131  
     /**
 132  
      * @return the FigNodeStrategy offered by this profile, if any. Returns
 133  
      *         <code>null</code> if this profile has no FigNodeStrategy.
 134  
      */
 135  
     public FigNodeStrategy getFigureStrategy() {
 136  2862
         return null;
 137  
     }
 138  
 
 139  
     /**
 140  
      * @return the DefaultTypeStrategy offered by this profile, if any. Returns
 141  
      *         <code>null</code> if this profile has no DefaultTypeStrategy.
 142  
      */
 143  
     public DefaultTypeStrategy getDefaultTypeStrategy() {
 144  4770
         return null;
 145  
     }
 146  
 
 147  
     /**
 148  
      * @return a collection of the top level UML Packages containing the
 149  
      *         profile.
 150  
      * @throws ProfileException if failed to get profile.
 151  
      */
 152  
     public Collection getProfilePackages() throws ProfileException {
 153  5724
         return Collections.emptyList();
 154  
     }
 155  
 
 156  
     /**
 157  
      * Get just those top level profile packages which have been loaded into the
 158  
      * model repository. Primarily for internal use. Applications should use
 159  
      * {@link #getProfilePackages()}.
 160  
      * 
 161  
      * @return collection of top level UML profile packages.
 162  
      * @throws ProfileException if failed to get profile.
 163  
      */
 164  
     public Collection getLoadedPackages() throws ProfileException {
 165  0
         return getProfilePackages();
 166  
     }
 167  
     
 168  
     /**
 169  
      * @return the display name
 170  
      */
 171  
     @Override
 172  
     public String toString() {
 173  780
         return getDisplayName();
 174  
     }
 175  
 
 176  
     /**
 177  
      * @return Returns the critics defined by this profile.
 178  
      */
 179  
     public Set<Critic> getCritics() {
 180  10418
         return critics;
 181  
     }
 182  
 
 183  
     /**
 184  
      * @return a unique identifier for this profile
 185  
      * 
 186  
      * For technical reasons this identifier should not contain stars '*'
 187  
      */
 188  
     public String getProfileIdentifier() {
 189  954
         return getDisplayName();
 190  
     }
 191  
 
 192  
     /**
 193  
      * @param criticsSet The critics to set.
 194  
      */
 195  
     protected void setCritics(Set<Critic> criticsSet) {
 196  3600
         this.critics = criticsSet;
 197  3600
     }
 198  
 }