001: package csdl.jblanket.app.tree;
002:
003: import csdl.jblanket.app.MethodCategoryColor;
004:
005: import java.awt.Color;
006: import java.util.List;
007:
008: /**
009: * Implements the Nodes that represents methods.
010: * <p>
011: * A <code>MethodNode</code> contains the type signature of the method it represents as well as
012: * information about whether the method was tested or untested, and is a one-line method,
013: * constructor, etc. See the <code>MethodCategoryColor</code> class for Font colors used.
014: *
015: * @author Joy M. Agustin
016: * @version $Id: MethodNode.java,v 1.1 2004/11/07 00:32:40 timshadel Exp $
017: */
018: public class MethodNode extends Node {
019:
020: /** Color representing the category of this node depending on the XML file */
021: private Color origColor;
022: /** Color representing the category of this node as displayed in the application */
023: private Color newColor;
024:
025: /** Describes if the method represented by this node was invoked during testing */
026: private boolean tested;
027: /** List of method's parameters */
028: private List parameters;
029:
030: /**
031: * Constructs an untested MethodNode object for method with type signature
032: * <code>name</code>(<code>parameters</code>).
033: *
034: * @param name the name of the method.
035: * @param parameters the list of <code>name</code>'s parameters.
036: */
037: public MethodNode(String name, List parameters) {
038: super (name);
039:
040: this .origColor = Color.black;
041: this .newColor = null;
042:
043: this .tested = false;
044: this .parameters = parameters;
045: }
046:
047: /**
048: * Gets the color of the node as displayed in the application.
049: *
050: * @return the color of the node in the application.
051: */
052: public Color getNewColor() {
053: return this .newColor;
054: }
055:
056: /**
057: * Gets the color of the node from the XML file.
058: *
059: * @return the color of the node from the COVER-MethodSets.xml file.
060: */
061: public Color getOrigColor() {
062: return this .origColor;
063: }
064:
065: /**
066: * Describes whether this method was individually excluded.
067: *
068: * @return true if the method was individually excluded, false otherwise.
069: */
070: public boolean isIndividualExclude() {
071: return this .newColor == MethodCategoryColor.EXCLUDED_INDIVIDUAL
072: .getColor();
073: }
074:
075: /**
076: * Describes whether this method was invoked during testing.
077: *
078: * @return true if the method was tested, false otherwise.
079: */
080: public boolean isTested() {
081: return this .tested;
082: }
083:
084: /**
085: * Sets the color of the this node as displayed in the application.
086: *
087: * @param color the new category color.
088: */
089: public void setNewColor(Color color) {
090: this .newColor = color;
091: }
092:
093: /**
094: * Sets this method as a one-line method.
095: */
096: public void setOneLineMethod() {
097: this .origColor = MethodCategoryColor.ONE_LINE.getColor();
098: this .newColor = MethodCategoryColor.ONE_LINE.getColor();
099: }
100:
101: /**
102: * Sets this method as a constructor.
103: */
104: public void setConstructor() {
105: this .origColor = MethodCategoryColor.CONSTRUCTOR.getColor();
106: this .newColor = MethodCategoryColor.CONSTRUCTOR.getColor();
107: }
108:
109: /**
110: * Sets this method as an individually excluded method.
111: */
112: public void setIndividualExclude() {
113: this .origColor = MethodCategoryColor.EXCLUDED_INDIVIDUAL
114: .getColor();
115: this .newColor = MethodCategoryColor.EXCLUDED_INDIVIDUAL
116: .getColor();
117: }
118:
119: /**
120: * Sets this method as tested.
121: */
122: public void setTested() {
123: this .tested = true;
124: }
125:
126: /**
127: * Sets this method as untested.
128: */
129: public void setUntested() {
130: this .tested = false;
131: }
132:
133: /**
134: * Returns the type signature of the method this node represents.
135: *
136: * @return the type signature.
137: */
138: public String toString() {
139: StringBuffer buffer = new StringBuffer(super .toString() + "(");
140: for (int i = 0; i < this .parameters.size(); i++) {
141: if (i > 0) {
142: buffer.append(", ");
143: }
144: buffer.append(this .parameters.get(i));
145: }
146: buffer.append(")");
147: return buffer.toString();
148: }
149: }
|