KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > csdl > jblanket > app > tree > MethodNode


1 package csdl.jblanket.app.tree;
2
3 import csdl.jblanket.app.MethodCategoryColor;
4
5 import java.awt.Color JavaDoc;
6 import java.util.List JavaDoc;
7
8 /**
9  * Implements the Nodes that represents methods.
10  * <p>
11  * A <code>MethodNode</code> contains the type signature of the method it represents as well as
12  * information about whether the method was tested or untested, and is a one-line method,
13  * constructor, etc. See the <code>MethodCategoryColor</code> class for Font colors used.
14  *
15  * @author Joy M. Agustin
16  * @version $Id: MethodNode.java,v 1.1 2004/11/07 00:32:40 timshadel Exp $
17  */

18 public class MethodNode extends Node {
19     
20   /** Color representing the category of this node depending on the XML file */
21   private Color origColor;
22   /** Color representing the category of this node as displayed in the application */
23   private Color newColor;
24   
25   /** Describes if the method represented by this node was invoked during testing */
26   private boolean tested;
27   /** List of method's parameters */
28   private List JavaDoc parameters;
29   
30   /**
31    * Constructs an untested MethodNode object for method with type signature
32    * <code>name</code>(<code>parameters</code>).
33    *
34    * @param name the name of the method.
35    * @param parameters the list of <code>name</code>'s parameters.
36    */

37   public MethodNode(String JavaDoc name, List JavaDoc parameters) {
38       super(name);
39       
40       this.origColor = Color.black;
41       this.newColor = null;
42       
43       this.tested = false;
44       this.parameters = parameters;
45   }
46
47   /**
48    * Gets the color of the node as displayed in the application.
49    *
50    * @return the color of the node in the application.
51    */

52   public Color getNewColor() {
53     return this.newColor;
54   }
55   
56   /**
57    * Gets the color of the node from the XML file.
58    *
59    * @return the color of the node from the COVER-MethodSets.xml file.
60    */

61   public Color getOrigColor() {
62     return this.origColor;
63   }
64   
65   /**
66    * Describes whether this method was individually excluded.
67    *
68    * @return true if the method was individually excluded, false otherwise.
69    */

70   public boolean isIndividualExclude() {
71     return this.newColor == MethodCategoryColor.EXCLUDED_INDIVIDUAL.getColor();
72   }
73   
74   /**
75    * Describes whether this method was invoked during testing.
76    *
77    * @return true if the method was tested, false otherwise.
78    */

79   public boolean isTested() {
80     return this.tested;
81   }
82
83   /**
84    * Sets the color of the this node as displayed in the application.
85    *
86    * @param color the new category color.
87    */

88   public void setNewColor(Color color) {
89     this.newColor = color;
90   }
91
92   /**
93    * Sets this method as a one-line method.
94    */

95   public void setOneLineMethod() {
96     this.origColor = MethodCategoryColor.ONE_LINE.getColor();
97     this.newColor = MethodCategoryColor.ONE_LINE.getColor();
98   }
99   
100   /**
101    * Sets this method as a constructor.
102    */

103   public void setConstructor() {
104     this.origColor = MethodCategoryColor.CONSTRUCTOR.getColor();
105     this.newColor = MethodCategoryColor.CONSTRUCTOR.getColor();
106   }
107
108   /**
109    * Sets this method as an individually excluded method.
110    */

111   public void setIndividualExclude() {
112     this.origColor = MethodCategoryColor.EXCLUDED_INDIVIDUAL.getColor();
113     this.newColor = MethodCategoryColor.EXCLUDED_INDIVIDUAL.getColor();
114   }
115   
116   /**
117    * Sets this method as tested.
118    */

119   public void setTested() {
120     this.tested = true;
121   }
122
123   /**
124    * Sets this method as untested.
125    */

126   public void setUntested() {
127     this.tested = false;
128   }
129
130   /**
131    * Returns the type signature of the method this node represents.
132    *
133    * @return the type signature.
134    */

135   public String JavaDoc toString() {
136     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(super.toString() + "(");
137     for (int i = 0; i < this.parameters.size(); i++) {
138       if (i > 0) {
139         buffer.append(", ");
140       }
141       buffer.append(this.parameters.get(i));
142     }
143     buffer.append(")");
144     return buffer.toString();
145   }
146 }
Popular Tags