KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > model > SimpleAttribute


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.designer.model;
5
6 import java.util.Observable JavaDoc;
7
8 /**
9  * An DesignElement that is only an attribute in an objects
10  * configuration.
11  *
12  * @author Rob Gordon.
13  */

14 abstract public class SimpleAttribute extends Observable JavaDoc
15 implements DesignAttribute {
16
17     /** The attribute */
18     private String JavaDoc attribute;
19
20     /*
21      * (non-Javadoc)
22      * @see org.oddjob.designer.model.DesignAttribute#attribute()
23      */

24     public String JavaDoc attribute() {
25         return attribute;
26     }
27
28     /*
29      * (non-Javadoc)
30      * @see org.oddjob.designer.model.DesignAttribute#attribute(java.lang.String)
31      */

32     public void attribute(String JavaDoc value) {
33         if ("".equals(value)) {
34             attribute = null;
35         }
36         else {
37             attribute = value;
38         }
39         setChanged();
40         notifyObservers(DEObservable.attributeChanged(attribute));
41     }
42     
43     /*
44      * (non-Javadoc)
45      * @see org.oddjob.designer.model.DesignElement#hasDetail()
46      */

47     public boolean hasDetail() {
48         try {
49             getClass().getDeclaredMethod("detail", new Class JavaDoc[0]);
50             return true;
51         } catch (NoSuchMethodException JavaDoc e) {
52             return false;
53         }
54     }
55     
56     /* (non-Javadoc)
57      * @see org.oddjob.designer.model.DesignElement#detail()
58      */

59     public DesignDefinition detail() {
60         throw new IllegalStateException JavaDoc("Call hasDetail first!");
61     }
62     
63
64     /*
65      * (non-Javadoc)
66      * @see org.oddjob.designer.model.DesignElement#clear()
67      */

68     public void clear() {
69         attribute(null);
70     }
71     
72 }
73
Popular Tags