KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > ClassPathEntry


1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  * of Java bytecode.
4  *
5  * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21 package proguard;
22
23 import java.io.*;
24
25
26 /**
27  * This class represents an entry from a class path: a jar, a war, a zip, an
28  * ear, or a directory, with a name and a flag to indicates whether the entry is
29  * an input entry or an output entry. Optional filters can be specified for the
30  * names of the contained resource/classes, jars, wars, ears, and zips.
31  *
32  * @author Eric Lafortune
33  */

34 public class ClassPathEntry
35 {
36     private File file;
37     private boolean output;
38     private String JavaDoc filter;
39     private String JavaDoc jarFilter;
40     private String JavaDoc warFilter;
41     private String JavaDoc earFilter;
42     private String JavaDoc zipFilter;
43
44
45     /**
46      * Creates a new ClassPathEntry with the given name and type.
47      */

48     public ClassPathEntry(File file, boolean isOutput)
49     {
50         this.file = file;
51         this.output = isOutput;
52     }
53
54
55     /**
56      * Returns the path name of the entry.
57      */

58     public String JavaDoc getName()
59     {
60         try
61         {
62             return file.getCanonicalPath();
63         }
64         catch (IOException ex)
65         {
66             return file.getPath();
67         }
68     }
69
70
71     public File getFile()
72     {
73         return file;
74     }
75
76
77     public void setFile(File file)
78     {
79         this.file = file;
80     }
81
82
83     public boolean isOutput()
84     {
85         return output;
86     }
87
88
89     public void setOutput(boolean output)
90     {
91         this.output = output;
92     }
93
94
95     public String JavaDoc getFilter()
96     {
97         return filter;
98     }
99
100     public void setFilter(String JavaDoc filter)
101     {
102         this.filter = filter == null || filter.length() == 0 ? null : filter;
103     }
104
105
106     public String JavaDoc getJarFilter()
107     {
108         return jarFilter;
109     }
110
111     public void setJarFilter(String JavaDoc filter)
112     {
113         this.jarFilter = filter == null || filter.length() == 0 ? null : filter;
114     }
115
116
117     public String JavaDoc getWarFilter()
118     {
119         return warFilter;
120     }
121
122     public void setWarFilter(String JavaDoc filter)
123     {
124         this.warFilter = filter == null || filter.length() == 0 ? null : filter;
125     }
126
127
128     public String JavaDoc getEarFilter()
129     {
130         return earFilter;
131     }
132
133     public void setEarFilter(String JavaDoc filter)
134     {
135         this.earFilter = filter == null || filter.length() == 0 ? null : filter;
136     }
137
138
139     public String JavaDoc getZipFilter()
140     {
141         return zipFilter;
142     }
143
144     public void setZipFilter(String JavaDoc filter)
145     {
146         this.zipFilter = filter == null || filter.length() == 0 ? null : filter;
147     }
148
149
150     public String JavaDoc toString()
151     {
152         String JavaDoc string = getName();
153
154         if (filter != null ||
155             jarFilter != null ||
156             warFilter != null ||
157             earFilter != null ||
158             zipFilter != null)
159         {
160             string +=
161                 ConfigurationConstants.OPEN_ARGUMENTS_KEYWORD +
162                 (zipFilter != null ? zipFilter : "") +
163                 ConfigurationConstants.SEPARATOR_KEYWORD +
164                 (earFilter != null ? earFilter : "") +
165                 ConfigurationConstants.SEPARATOR_KEYWORD +
166                 (warFilter != null ? warFilter : "") +
167                 ConfigurationConstants.SEPARATOR_KEYWORD +
168                 (jarFilter != null ? jarFilter : "") +
169                 ConfigurationConstants.SEPARATOR_KEYWORD +
170                 (filter != null ? filter : "") +
171                 ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD;
172         }
173
174         return string;
175     }
176 }
177
Popular Tags