001: /*
002: * ProGuard -- shrinking, optimization, obfuscation, and preverification
003: * of Java bytecode.
004: *
005: * Copyright (c) 2002-2007 Eric Lafortune (eric@graphics.cornell.edu)
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the Free
009: * Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful, but WITHOUT
013: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
014: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
015: * more details.
016: *
017: * You should have received a copy of the GNU General Public License along
018: * with this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: package proguard;
022:
023: import java.io.*;
024:
025: /**
026: * This class represents an entry from a class path: a jar, a war, a zip, an
027: * ear, or a directory, with a name and a flag to indicates whether the entry is
028: * an input entry or an output entry. Optional filters can be specified for the
029: * names of the contained resource/classes, jars, wars, ears, and zips.
030: *
031: * @author Eric Lafortune
032: */
033: public class ClassPathEntry {
034: private File file;
035: private boolean output;
036: private String filter;
037: private String jarFilter;
038: private String warFilter;
039: private String earFilter;
040: private String zipFilter;
041:
042: /**
043: * Creates a new ClassPathEntry with the given name and type.
044: */
045: public ClassPathEntry(File file, boolean isOutput) {
046: this .file = file;
047: this .output = isOutput;
048: }
049:
050: /**
051: * Returns the path name of the entry.
052: */
053: public String getName() {
054: try {
055: return file.getCanonicalPath();
056: } catch (IOException ex) {
057: return file.getPath();
058: }
059: }
060:
061: public File getFile() {
062: return file;
063: }
064:
065: public void setFile(File file) {
066: this .file = file;
067: }
068:
069: public boolean isOutput() {
070: return output;
071: }
072:
073: public void setOutput(boolean output) {
074: this .output = output;
075: }
076:
077: public String getFilter() {
078: return filter;
079: }
080:
081: public void setFilter(String filter) {
082: this .filter = filter == null || filter.length() == 0 ? null
083: : filter;
084: }
085:
086: public String getJarFilter() {
087: return jarFilter;
088: }
089:
090: public void setJarFilter(String filter) {
091: this .jarFilter = filter == null || filter.length() == 0 ? null
092: : filter;
093: }
094:
095: public String getWarFilter() {
096: return warFilter;
097: }
098:
099: public void setWarFilter(String filter) {
100: this .warFilter = filter == null || filter.length() == 0 ? null
101: : filter;
102: }
103:
104: public String getEarFilter() {
105: return earFilter;
106: }
107:
108: public void setEarFilter(String filter) {
109: this .earFilter = filter == null || filter.length() == 0 ? null
110: : filter;
111: }
112:
113: public String getZipFilter() {
114: return zipFilter;
115: }
116:
117: public void setZipFilter(String filter) {
118: this .zipFilter = filter == null || filter.length() == 0 ? null
119: : filter;
120: }
121:
122: public String toString() {
123: String string = getName();
124:
125: if (filter != null || jarFilter != null || warFilter != null
126: || earFilter != null || zipFilter != null) {
127: string += ConfigurationConstants.OPEN_ARGUMENTS_KEYWORD
128: + (zipFilter != null ? zipFilter : "")
129: + ConfigurationConstants.SEPARATOR_KEYWORD
130: + (earFilter != null ? earFilter : "")
131: + ConfigurationConstants.SEPARATOR_KEYWORD
132: + (warFilter != null ? warFilter : "")
133: + ConfigurationConstants.SEPARATOR_KEYWORD
134: + (jarFilter != null ? jarFilter : "")
135: + ConfigurationConstants.SEPARATOR_KEYWORD
136: + (filter != null ? filter : "")
137: + ConfigurationConstants.CLOSE_ARGUMENTS_KEYWORD;
138: }
139:
140: return string;
141: }
142: }
|