Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

MethodTreeNode.java

00001 package edu.ksu.cis.bandera.abstraction.gui;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998, 1999, 2000   Shawn Laubach (laubach@acm.org)  *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * Modifications by Robby (robby@cis.ksu.edu) are                    *
00009  * Copyright (C) 2000 Robby.  All rights reserved.                   *
00010  *                                                                   *
00011  * This work was done as a project in the SAnToS Laboratory,         *
00012  * Department of Computing and Information Sciences, Kansas State    *
00013  * University, USA (http://www.cis.ksu.edu/santos).                  *
00014  * It is understood that any modification not identified as such is  *
00015  * not covered by the preceding statement.                           *
00016  *                                                                   *
00017  * This work is free software; you can redistribute it and/or        *
00018  * modify it under the terms of the GNU Library General Public       *
00019  * License as published by the Free Software Foundation; either      *
00020  * version 2 of the License, or (at your option) any later version.  *
00021  *                                                                   *
00022  * This work is distributed in the hope that it will be useful,      *
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00025  * Library General Public License for more details.                  *
00026  *                                                                   *
00027  * You should have received a copy of the GNU Library General Public *
00028  * License along with this toolkit; if not, write to the             *
00029  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00030  * Boston, MA  02111-1307, USA.                                      *
00031  *                                                                   *
00032  * Java is a trademark of Sun Microsystems, Inc.                     *
00033  *                                                                   *
00034  * To submit a bug report, send a comment, or get the latest news on *
00035  * this project and other SAnToS projects, please visit the web-site *
00036  *                http://www.cis.ksu.edu/santos                      *
00037  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00038 import java.util.*;
00039 import javax.swing.*;
00040 import javax.swing.table.*;
00041 import ca.mcgill.sable.soot.*;
00042 import javax.swing.tree.TreeNode;
00043 import ca.mcgill.sable.soot.jimple.*;
00044 import edu.ksu.cis.bandera.abstraction.*;
00045 import edu.ksu.cis.bandera.abstraction.util.*;
00046 public class MethodTreeNode extends TypeTreeNode {
00047     static Hashtable methodsTable;
00048     protected SootMethod method;
00049 /**
00050  * MethodTreeNode constructor comment.
00051  */
00052 public MethodTreeNode(SootMethod method) {
00053     super(method.getName());
00054     this.method = method;
00055     methodsTable.put(method, this);
00056     if (!method.isBodyStored(Jimple.v()))
00057         new BuildAndStoreBody(Jimple.v(), new StoredBody(ClassFile.v()), 0).resolveFor(method);
00058     JimpleBody body = (JimpleBody) method.getBody(Jimple.v());
00059     for (ca.mcgill.sable.util.Iterator i = body.getLocals().iterator(); i.hasNext();) {
00060         Local l = (Local) i.next();
00061         if (!l.getName().startsWith("JJJCTEMP$") && !"$ret".equals(l.getName()))
00062             addChild(new LocalTreeNode(l));
00063     }
00064 }
00065 /**
00066  * Insert the method's description here.
00067  * Creation date: (3/24/00 12:20:36 AM)
00068  * @return javax.swing.table.TableCellRenderer
00069  * @param row int
00070  * @param column int
00071  */
00072 public TableCellEditor getCellEditor(int column) {
00073     /*
00074     if (column == 2) {
00075     TableCellEditor editor;
00076     editor = new JTable().getDefaultEditor(Boolean.class);
00077     return editor;
00078     }
00079     */
00080     return null;
00081 }
00082 /**
00083  * Insert the method's description here.
00084  * Creation date: (3/24/00 12:20:36 AM)
00085  * @return javax.swing.table.TableCellRenderer
00086  * @param row int
00087  * @param column int
00088  */
00089 public TableCellRenderer getCellRenderer(int column) {
00090     if (column == 1) {
00091         DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
00092         renderer.setToolTipText(method.getParameterTypes().toString());
00093         return renderer;
00094     } else
00095         /*
00096         if (column == 2) {
00097         TableCellRenderer renderer;
00098         renderer = new JTable().getDefaultRenderer(Boolean.class);
00099         return renderer;
00100         } else*/
00101         return null;
00102 }
00103 /**
00104  * Insert the method's description here.
00105  * Creation date: (5/19/00 2:43:38 PM)
00106  * @return ca.mcgill.sable.soot.SootMethod
00107  */
00108 public SootMethod getMethod() {
00109     return method;
00110 }
00111 /**
00112  * Insert the method's description here.
00113  * Creation date: (5/12/00 12:09:20 PM)
00114  * @return edu.ksu.cis.bandera.abps.options.MethodOptions
00115  */
00116 public void getOption(Hashtable result) {
00117     HashSet locals = new HashSet();
00118     for (int i = 0; i < getChildCount(); i++) {
00119         LocalTreeNode local = (LocalTreeNode) getChildAt(i);
00120         if (local.getAbstraction() != null) {
00121             Local lcl = (Local) local.getVar();
00122             locals.add(lcl);
00123             LocalMethod lm = new LocalMethod(method, lcl);
00124             result.put(lm, local.getAbstraction());
00125         }
00126     }
00127     result.put(method, locals);
00128     ((HashSet) result.get(method.getDeclaringClass())).add(method);
00129 }
00130         /**
00131          * Insert the method's description here.
00132          * Creation date: (3/24/00 12:08:42 AM)
00133          * @return java.lang.String
00134          */
00135         public String getParams() {
00136                 return method.getParameterTypes().toString().replace('{', '(').replace('}', ')');
00137         }
00138         /**
00139          * Insert the method's description here.
00140          * Creation date: (3/23/00 11:30:08 PM)
00141          * @return java.lang.String
00142          */
00143         public String toString() {
00144             String name = getName().toString();
00145             if ("<init>".equals(name)) {
00146                 name = method.getDeclaringClass().getName();
00147                 int i = name.lastIndexOf(".");
00148                 if (i != -1) name = name.substring(i + 1);
00149             }
00150                 return name;
00151         }
00152 }

Generated at Thu Feb 7 06:50:28 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001