001: /*
002: * Created on Sep 15, 2003
003: *
004: * To change the template for this generated file go to
005: * Window>Preferences>Java>Code Generation>Code and Comments
006: */
007: package org.hammurapi.inspectors.metrics.callertrace;
008:
009: import java.util.Enumeration;
010: import java.util.Hashtable;
011: import java.util.Vector;
012:
013: import org.w3c.dom.Document;
014: import org.w3c.dom.Element;
015:
016: import com.pavelvlasov.jsel.Method;
017:
018: /**
019: * @author mucbj0
020: *
021: * To change the template for this generated type comment go to
022: * Window>Preferences>Java>Code Generation>Code and Comments
023: */
024: public class MethodMap extends Hashtable {
025:
026: public void addAll(Hashtable ht) {
027: Enumeration enumk = ht.keys();
028: Enumeration enumv = ht.elements();
029: while (enumv.hasMoreElements()) {
030: Object k = enumk.nextElement();
031: Method m = (Method) enumv.nextElement();
032: this .put(k, m);
033: }
034: }
035:
036: public Vector selectMethodsByName(String methodName) {
037: Vector vc = new Vector();
038: Enumeration enumxx = this .elements();
039: while (enumxx.hasMoreElements()) {
040: Method mi = (Method) enumxx.nextElement();
041: if (mi.getName().equals(methodName)) {
042: vc.add(mi);
043: }
044: }
045: return vc;
046: }
047:
048: public MethodWrapper selectMethodsWithoutHashkey(String methodName) {
049:
050: Enumeration enumxx = this .elements();
051: while (enumxx.hasMoreElements()) {
052: MethodWrapper mi = (MethodWrapper) enumxx.nextElement();
053: String myKey = AdjacencyMatrix.nodeNameWithoutHashcode(mi
054: .getMethodKey());
055: if (myKey.equals(methodName)) {
056: return mi;
057: }
058: }
059: return null;
060: }
061:
062: public MethodWrapper selectMethodsBothWithoutHashkey(
063: String methodName) {
064:
065: Enumeration enumxx = this .elements();
066: while (enumxx.hasMoreElements()) {
067: MethodWrapper mi = (MethodWrapper) enumxx.nextElement();
068: String myKey = AdjacencyMatrix.nodeNameWithoutHashcode(mi
069: .getMethodKey());
070: if (myKey.equals(AdjacencyMatrix
071: .nodeNameWithoutHashcode(methodName))) {
072: return mi;
073: }
074: }
075: return null;
076: }
077:
078: public Vector selectConstructors() {
079: Vector vc = new Vector();
080: Enumeration enumxx = this .elements();
081: while (enumxx.hasMoreElements()) {
082: Method mi = (Method) enumxx.nextElement();
083: // if (mi instanceof Constructor) {
084: // vc.add(mi);
085: // }
086: }
087: return vc;
088: }
089:
090: public Element toDom(Document document){
091: Element ret=document.createElement("ImplementedMethodList");
092: ret.setAttribute("size", String.valueOf( this.size() ));
093:
094: Enumeration enum = this.elements();
095: Enumeration enumKey = this.keys();
096: while(enum.hasMoreElements()){
097: String key = (String)enumKey.nextElement();
098: MethodWrapperDeclaration mwd = (MethodWrapperDeclaration)enum.nextElement();
099:
100: ret.appendChild(mwd.toDom( document ));
101: }
102: return ret;
103: }
104: }
|