KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hammurapi > inspectors > metrics > callertrace > MethodWrapperDeclaration


1 /*
2  * Hammurapi
3  * Automated Java code review system.
4  * Copyright (C) 2004 Johannes Bellert
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * URL: http://www.pavelvlasov.com/pv/content/menu.show?id=products.jtaste
21  * e-Mail: Johannes.Bellert@ercgroup.com
22  *
23  * * Created on Apr 18, 2004
24  *
25  */

26 package org.hammurapi.inspectors.metrics.callertrace;
27
28 import java.util.HashSet JavaDoc;
29
30 import org.w3c.dom.Document JavaDoc;
31 import org.w3c.dom.Element JavaDoc;
32
33 import com.pavelvlasov.jsel.OperationInfo;
34 import com.pavelvlasov.review.SourceMarker;
35
36 /**
37  * @author Johannes Bellert
38  *
39  * To change the template for this generated type comment go to
40  * Window - Preferences - Java - Code Generation - Code and Comments
41  */

42 public class MethodWrapperDeclaration extends MethodWrapperImpl implements MethodWrapper {
43     private boolean called = false;
44     private HashSet JavaDoc invokedMethods = new HashSet JavaDoc();
45     public int afferentMethodCoupling = 0;
46     public int efferentMethodCoupling = 0;
47
48     
49     public MethodWrapperDeclaration(OperationInfo _method, SourceMarker srcMrk){
50         super( _method, srcMrk);
51         }
52
53     // only for Test Case usage !!
54
public MethodWrapperDeclaration(String JavaDoc _name, String JavaDoc _declType){
55         super(_name, _declType);
56     }
57
58     public boolean isCalled(){
59         return called;
60     }
61     
62     public void setCalled(){
63         called = true;
64     }
65     
66     /*
67     public OperationInfo getOperationInfo(){
68         return aMethod;
69     }
70     */

71     public boolean equals(Object JavaDoc obj ){
72         return this.getMethodKey().equals( ((MethodWrapper)obj).getMethodKey() );
73     }
74
75     /**
76      * @return Returns the invokedMethods.
77      */

78     public HashSet JavaDoc getInvokedMethods() {
79         return invokedMethods;
80     }
81     
82     public Element JavaDoc toDom(Document JavaDoc document){
83         Element JavaDoc ret=document.createElement("MethodWrapperDeclaration");
84         ret.setAttribute("id", String.valueOf( this.hashCode() ));
85         ret.setAttribute("called", String.valueOf(this.isCalled()));
86         ret.setAttribute("key", printMethodName());
87         ret.setAttribute("source-url", getSrcURL());
88         ret.setAttribute("line", String.valueOf(getSrcLine()));
89         ret.setAttribute("Ma", String.valueOf(afferentMethodCoupling));
90         ret.setAttribute("Me", String.valueOf(this.invokedMethods.size()));
91     /*
92         Enumeration enum = this.invokedMethods.elements();
93         
94         while(enum.hasMoreElements()){
95             MethodWrapperDeclaration mwd = (MethodWrapperDeclaration)enum.nextElement();
96             
97             ret.appendChild(mwd.toDom( document ));
98         }
99         */

100         return ret;
101     }
102 }
103
Popular Tags