Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/argouml/configuration/ConfigurationKeyImpl.java


1   // Copyright (c) 1996-99 The Regents of the University of California. All
2   // Rights Reserved. Permission to use, copy, modify, and distribute this
3   // software and its documentation without fee, and without a written
4   // agreement is hereby granted, provided that the above copyright notice
5   // and this paragraph appear in all copies.  This software program and
6   // documentation are copyrighted by The Regents of the University of
7   // California. The software program and documentation are supplied "AS
8   // IS", without any accompanying services from The Regents. The Regents
9   // does not warrant that the operation of the program will be
10  // uninterrupted or error-free. The end-user understands that the program
11  // was developed for research purposes and is advised not to rely
12  // exclusively on the program for any reason.  IN NO EVENT SHALL THE
13  // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
14  // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15  // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
16  // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
17  // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
18  // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
20  // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
21  // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
22  // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  
24  //
25  //  This code is originally from the open source UML editor argouml.
26  //  Information on argouml can be found at: http://argouml.tigris.org/
27  //
28  //  The original author is Thierry Lach  
29  //
30  //  Adopted by Matthieu Cormier on Fri June 27 2003.
31  
32  package org.argouml.configuration;
33  
34  import java.beans.*;
35  
36  /**
37   *   This class provides definition and manipulation of configuration keys.
38   *   All keys in the configuration system will be accessed using the
39   *   ConfigurationKey wrapper.
40   *
41   */
42  public class ConfigurationKeyImpl implements ConfigurationKey {
43  
44    /** The string value for the key.
45     */
46    private String _key = null;
47  
48    private static String _prefix = new String("allusions.");
49  
50    /** Create a single component configuration key.
51     */
52    public ConfigurationKeyImpl(String k1) {
53        _key = _prefix + k1;
54    }
55  
56    /** Create a sub-component of an existing configuration key.
57     */
58    public ConfigurationKeyImpl(ConfigurationKey ck, String k1) {
59        _key = ck.getKey() + "." + k1;
60    }
61  
62    /** Create a two-component configuration key.
63     */
64    public ConfigurationKeyImpl(String k1, String k2) {
65        _key = _prefix + k1 + "." + k2;
66    }
67  
68    /** Create a three-component configuration key.
69     */
70    public ConfigurationKeyImpl(String k1, String k2, String k3) {
71        _key = _prefix + k1 + "." + k2 + "." + k3;
72    }
73  
74    /** Create a four-component configuration key.
75     */
76    public ConfigurationKeyImpl(String k1, String k2, String k3, String k4) {
77        _key = _prefix + k1 + "." + k2 + "." + k3 + "." + k4;
78    }
79  
80    /** Create a five-component configuration key.
81     */
82    public ConfigurationKeyImpl(String k1, String k2, String k3, String k4, String k5) {
83        _key = _prefix + k1 + "." + k2 + "." + k3 + "." + k4 + "." + k5;
84    }
85  
86    /** Return the actual key used to access the configuration.
87     */ 
88    public final String getKey() {
89        return _key;
90    }
91  
92    /** Compare the configuration key to a string.
93     */
94    public boolean isChangedProperty(PropertyChangeEvent pce) {
95        if (pce == null) return false;
96        return pce.getPropertyName().equals(_key);
97    }
98  
99    public String toString() {
100       return "{ConfigurationKeyImpl:" + _key + "}";
101   }
102 }
103