KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
25  * Handles command list by making Strings separated by spaces into
26  * list
27  */

28 public class SootCommandList {
29
30     private ArrayList list;
31     private static final String JavaDoc SPACE = " ";
32     
33     /**
34      * Constructor for SootCommandList.
35      */

36     public SootCommandList() {
37         setList(new ArrayList());
38     }
39     
40     /**
41      * @param key
42      */

43     public void addSingleOpt(ArrayList key){
44         getList().addAll(key);
45     }
46     
47     /**
48      * Method addSingleOpt.
49      * @param key
50      */

51     public void addSingleOpt(String JavaDoc key) {
52         StringTokenizer st = new StringTokenizer(key);
53         while (st.hasMoreTokens()) {
54             String JavaDoc token = st.nextToken();
55             getList().add(token);
56         }
57     }
58     
59     /**
60      * Method addDoubleOpt.
61      * @param key
62      * @param val
63      */

64     public void addDoubleOpt(String JavaDoc key, String JavaDoc val) {
65         addSingleOpt(key);
66         addSingleOpt(val);
67     }
68     
69     public void addDashes(){
70     
71         ArrayList withDashes = new ArrayList();
72             
73         Iterator it = getList().iterator();
74         while (it.hasNext()) {
75             String JavaDoc temp = (String JavaDoc)it.next();
76             temp = "-- "+temp;
77             withDashes.add(temp);
78         }
79         
80         setList(withDashes);
81     }
82
83     public void printList(){
84         Iterator it = list.iterator();
85         while (it.hasNext()){
86             System.out.println(it.next());
87         }
88     }
89     /**
90      * Returns the list.
91      * @return ArrayList
92      */

93     public ArrayList getList() {
94         return list;
95     }
96
97     /**
98      * Sets the list.
99      * @param list The list to set
100      */

101     public void setList(ArrayList list) {
102         this.list = list;
103     }
104
105 }
106
Popular Tags