Coverage Report - org.argouml.configuration.ConfigurationKeyImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigurationKeyImpl
66%
16/24
50%
1/2
1.222
 
 1  
 /* $Id: ConfigurationKeyImpl.java 17819 2010-01-12 18:40:41Z linus $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009 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  
  *    linus
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 1996-2007 The Regents of the University of California. All
 17  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 18  
 // software and its documentation without fee, and without a written
 19  
 // agreement is hereby granted, provided that the above copyright notice
 20  
 // and this paragraph appear in all copies.  This software program and
 21  
 // documentation are copyrighted by The Regents of the University of
 22  
 // California. The software program and documentation are supplied "AS
 23  
 // IS", without any accompanying services from The Regents. The Regents
 24  
 // does not warrant that the operation of the program will be
 25  
 // uninterrupted or error-free. The end-user understands that the program
 26  
 // was developed for research purposes and is advised not to rely
 27  
 // exclusively on the program for any reason.  IN NO EVENT SHALL THE
 28  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 29  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 30  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 31  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 32  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 33  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 34  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 35  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 36  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 37  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 38  
 
 39  
 package org.argouml.configuration;
 40  
 import java.beans.PropertyChangeEvent;
 41  
 
 42  
 
 43  
 /**
 44  
  *   This class provides definition and manipulation of configuration keys.
 45  
  *   All keys in the configuration system will be accessed using the
 46  
  *   ConfigurationKey wrapper.
 47  
  *
 48  
  *   @author Thierry Lach
 49  
  *   @since ARGO0.9.4
 50  
  */
 51  
 public class ConfigurationKeyImpl
 52  
     implements ConfigurationKey {
 53  
 
 54  
     /**
 55  
      * The string value for the key.
 56  
      */
 57  430467
     private String key = null;
 58  
 
 59  
     /**
 60  
      * Create a single component configuration key.
 61  
      *
 62  
      * @param k1 key component.
 63  
      */
 64  70200
     public ConfigurationKeyImpl(String k1) {
 65  70200
         key = "argo." + k1;
 66  70200
     }
 67  
 
 68  
     /**
 69  
      * Create a sub-component of an existing configuration key.
 70  
      *
 71  
      * @param ck configuration key
 72  
      * @param k1 additional key component.
 73  
      */
 74  0
     public ConfigurationKeyImpl(ConfigurationKey ck, String k1) {
 75  0
         key = ck.getKey() + "." + k1;
 76  0
     }
 77  
 
 78  
     /**
 79  
      * Create a two-component configuration key.
 80  
      *
 81  
      * @param k1 key component 1.
 82  
      * @param k2 key component 2.
 83  
      */
 84  27032
     public ConfigurationKeyImpl(String k1, String k2) {
 85  27032
         key = "argo." + k1 + "." + k2;
 86  27032
     }
 87  
 
 88  
     /**
 89  
      * Create a three-component configuration key.
 90  
      *
 91  
      * @param k1 key component 1.
 92  
      * @param k2 key component 2.
 93  
      * @param k3 key component 3.
 94  
      */
 95  330535
     public ConfigurationKeyImpl(String k1, String k2, String k3) {
 96  330535
         key = "argo." + k1 + "." + k2 + "." + k3;
 97  330535
     }
 98  
 
 99  
     /**
 100  
      * Create a four-component configuration key.
 101  
      *
 102  
      * @param k1 key component 1.
 103  
      * @param k2 key component 2.
 104  
      * @param k3 key component 3.
 105  
      * @param k4 key component 4.
 106  
      */
 107  2700
     public ConfigurationKeyImpl(String k1, String k2, String k3, String k4) {
 108  2700
         key = "argo." + k1 + "." + k2 + "." + k3 + "." + k4;
 109  2700
     }
 110  
 
 111  
     /**
 112  
      * Create a five-component configuration key.
 113  
      *
 114  
      * @param k1 key component 1.
 115  
      * @param k2 key component 2.
 116  
      * @param k3 key component 3.
 117  
      * @param k4 key component 4.
 118  
      * @param k5 key component 5.
 119  
      */
 120  
     public ConfigurationKeyImpl(String k1, String k2,
 121  0
                                 String k3, String k4, String k5) {
 122  0
         key = "argo." + k1 + "." + k2 + "." + k3 + "." + k4 + "." + k5;
 123  0
     }
 124  
 
 125  
     /**
 126  
      * Return the actual key used to access the configuration.
 127  
      *
 128  
      * @return the key
 129  
      */
 130  
     public final String getKey() {
 131  885873
         return key;
 132  
     }
 133  
 
 134  
     /**
 135  
      * Compare the configuration key to a string.
 136  
      *
 137  
      * @param pce PropertyChangeEvent to check
 138  
      * @return true if the changed property is for the key.
 139  
      */
 140  
     public boolean isChangedProperty(PropertyChangeEvent pce) {
 141  76
         if (pce == null) {
 142  0
             return false;
 143  
         }
 144  76
         return pce.getPropertyName().equals(key);
 145  
     }
 146  
 
 147  
     /**
 148  
      * Returns a formatted key.
 149  
      * @return a formatted key string.
 150  
      */
 151  
     public String toString() {
 152  0
         return "{ConfigurationKeyImpl:" + key + "}";
 153  
     }
 154  
 }
 155