KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > KeepSpecification


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.util.*;
24
25 /**
26  * This class stores a specification of keep option, with a purpose and a class
27  * specification.
28  *
29  * @author Eric Lafortune
30  */

31 public class KeepSpecification extends ClassSpecification
32 {
33     public boolean markClasses;
34     public boolean markConditionally;
35     public boolean allowShrinking;
36     public boolean allowOptimization;
37     public boolean allowObfuscation;
38
39
40     /**
41      * Creates a new KeepSpecification for all possible classes.
42      * @param markClasses specifies whether to mark the classes.
43      * If false, only class members are marked.
44      * If true, the classes are marked as well.
45      * @param markConditionally specifies whether to mark the classes and
46      * class members conditionally. If true, classes
47      * and class members are marked, on the condition
48      * that all specified class members are present.
49      * @param allowShrinking specifies whether shrinking is allowed.
50      * @param allowOptimization specifies whether optimization is allowed.
51      * @param allowObfuscation specifies whether obfuscation is allowed.
52      */

53     public KeepSpecification(boolean markClasses,
54                              boolean markConditionally,
55                              boolean allowShrinking,
56                              boolean allowOptimization,
57                              boolean allowObfuscation)
58     {
59         this.markClasses = markClasses;
60         this.markConditionally = markConditionally;
61         this.allowShrinking = allowShrinking;
62         this.allowOptimization = allowOptimization;
63         this.allowObfuscation = allowObfuscation;
64     }
65
66
67     /**
68      * Creates a new KeepSpecification.
69      * @param markClasses specifies whether to mark the classes.
70      * If false, only class members are marked.
71      * If true, the classes are marked as well.
72      * @param markConditionally specifies whether to mark the classes and
73      * class members conditionally. If true, classes
74      * and class members are marked, on the condition
75      * that all specified class members are present.
76      * @param allowShrinking specifies whether shrinking is allowed.
77      * @param allowOptimization specifies whether optimization is allowed.
78      * @param allowObfuscation specifies whether obfuscation is allowed.
79      * @param classSpecification the specification of classes and class members.
80      */

81     public KeepSpecification(boolean markClasses,
82                              boolean markConditionally,
83                              boolean allowShrinking,
84                              boolean allowOptimization,
85                              boolean allowObfuscation,
86                              ClassSpecification classSpecification)
87     {
88         super(classSpecification);
89
90         this.markClasses = markClasses;
91         this.markConditionally = markConditionally;
92         this.allowShrinking = allowShrinking;
93         this.allowOptimization = allowOptimization;
94         this.allowObfuscation = allowObfuscation;
95     }
96
97
98     // Implementations for Object.
99

100     public boolean equals(Object JavaDoc object)
101     {
102         if (object == null ||
103             this.getClass() != object.getClass())
104         {
105             return false;
106         }
107
108         KeepSpecification other = (KeepSpecification)object;
109         return
110             this.markClasses == other.markClasses &&
111             this.markConditionally == other.markConditionally &&
112             this.allowShrinking == other.allowShrinking &&
113             this.allowOptimization == other.allowOptimization &&
114             this.allowObfuscation == other.allowObfuscation &&
115             super.equals(other);
116     }
117
118     public int hashCode()
119     {
120         return
121             (markClasses ? 0 : 1) ^
122             (markConditionally ? 0 : 2) ^
123             (allowShrinking ? 0 : 4) ^
124             (allowOptimization ? 0 : 8) ^
125             (allowObfuscation ? 0 : 16) ^
126             super.hashCode();
127     }
128
129     public Object JavaDoc clone()
130     {
131 // try
132
// {
133
return super.clone();
134 // }
135
// catch (CloneNotSupportedException e)
136
// {
137
// return null;
138
// }
139
}
140 }
141
Popular Tags