001: /*
002: * Hammurapi
003: * Automated Java code review system.
004: * Copyright (C) 2004 Johannes Bellert
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.pavelvlasov.com/pv/content/menu.show?id=products.jtaste
021: * e-Mail: Johannes.Bellert@ercgroup.com
022: *
023: * * Created on Apr 18, 2004
024: *
025: */
026: package org.hammurapi.inspectors.metrics.callertrace;
027:
028: import java.util.HashSet;
029:
030: import org.w3c.dom.Document;
031: import org.w3c.dom.Element;
032:
033: import com.pavelvlasov.jsel.OperationInfo;
034: import com.pavelvlasov.review.SourceMarker;
035:
036: /**
037: * @author Johannes Bellert
038: *
039: * To change the template for this generated type comment go to
040: * Window - Preferences - Java - Code Generation - Code and Comments
041: */
042: public class MethodWrapperDeclaration extends MethodWrapperImpl
043: implements MethodWrapper {
044: private boolean called = false;
045: private HashSet invokedMethods = new HashSet();
046: public int afferentMethodCoupling = 0;
047: public int efferentMethodCoupling = 0;
048:
049: public MethodWrapperDeclaration(OperationInfo _method,
050: SourceMarker srcMrk) {
051: super (_method, srcMrk);
052: }
053:
054: // only for Test Case usage !!
055: public MethodWrapperDeclaration(String _name, String _declType) {
056: super (_name, _declType);
057: }
058:
059: public boolean isCalled() {
060: return called;
061: }
062:
063: public void setCalled() {
064: called = true;
065: }
066:
067: /*
068: public OperationInfo getOperationInfo(){
069: return aMethod;
070: }
071: */
072: public boolean equals(Object obj) {
073: return this .getMethodKey().equals(
074: ((MethodWrapper) obj).getMethodKey());
075: }
076:
077: /**
078: * @return Returns the invokedMethods.
079: */
080: public HashSet getInvokedMethods() {
081: return invokedMethods;
082: }
083:
084: public Element toDom(Document document) {
085: Element ret = document
086: .createElement("MethodWrapperDeclaration");
087: ret.setAttribute("id", String.valueOf(this .hashCode()));
088: ret.setAttribute("called", String.valueOf(this .isCalled()));
089: ret.setAttribute("key", printMethodName());
090: ret.setAttribute("source-url", getSrcURL());
091: ret.setAttribute("line", String.valueOf(getSrcLine()));
092: ret.setAttribute("Ma", String.valueOf(afferentMethodCoupling));
093: ret.setAttribute("Me", String.valueOf(this .invokedMethods
094: .size()));
095: /*
096: Enumeration enum = this.invokedMethods.elements();
097:
098: while(enum.hasMoreElements()){
099: MethodWrapperDeclaration mwd = (MethodWrapperDeclaration)enum.nextElement();
100:
101: ret.appendChild(mwd.toDom( document ));
102: }
103: */
104: return ret;
105: }
106: }
|