KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > launching > SootProjectLauncher


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package ca.mcgill.sable.soot.launching;
21
22 import java.util.*;
23
24 import org.eclipse.jdt.core.*;
25 import org.eclipse.jface.action.*;
26
27 /**
28  * Handles launching Soot on project.
29  */

30 public class SootProjectLauncher extends SootLauncher {
31
32     private String JavaDoc process_path;
33     private ArrayList javaProcessPath;
34     private String JavaDoc classpathAppend = null;
35     
36     public void run(IAction action) {
37         super.run(action);
38         classpathAppend = null;
39         try {
40             setProcess_path(platform_location+getSootSelection().getJavaProject().getOutputLocation().toOSString());
41             IPackageFragmentRoot [] roots = getSootSelection().getJavaProject().getAllPackageFragmentRoots();
42             
43             for (int i = 0; i < roots.length; i++){
44                 if (!roots[i].isArchive() && roots[i].getKind() == IPackageFragmentRoot.K_SOURCE){
45                 
46                     String JavaDoc next = platform_location+roots[i].getPath();
47                     
48                     if (getJavaProcessPath() == null){
49                         setJavaProcessPath(new ArrayList());
50                     }
51                     
52                     getJavaProcessPath().add(next);
53                 }
54             }
55             
56             addJars();
57         }
58         catch(Exception JavaDoc e1) {
59             System.out.println(e1.getMessage());
60         }
61     }
62     
63     /**
64      * Sets the classpathAppend.
65      * @param classpathAppend The classpathAppend to set
66      */

67     public void setClasspathAppend(String JavaDoc ca) {
68         if (this.classpathAppend == null){
69             this.classpathAppend = ca;
70         }
71         else {
72             this.classpathAppend = this.classpathAppend+getSootClasspath().getSeparator()+ca;
73         }
74     }
75
76
77     /**
78      * Returns the process_path.
79      * @return String
80      */

81     public String JavaDoc getProcess_path() {
82         return process_path;
83     }
84
85
86     /**
87      * Sets the process_path.
88      * @param process_path The process_path to set
89      */

90     public void setProcess_path(String JavaDoc process_path) {
91         this.process_path = process_path;
92     }
93
94     /**
95      * @return
96      */

97     public String JavaDoc getClasspathAppend() {
98         return classpathAppend;
99     }
100
101     /**
102      * @return
103      */

104     public ArrayList getJavaProcessPath() {
105         return javaProcessPath;
106     }
107
108     /**
109      * @param string
110      */

111     public void setJavaProcessPath(ArrayList list) {
112         javaProcessPath = list;
113     }
114
115 }
116
Popular Tags