• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2014 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 /**
24  * This class represents a keep option with class specification.
25  *
26  * @author Eric Lafortune
27  */
28 public class KeepClassSpecification extends ClassSpecification
29 {
30     public final boolean markClasses;
31     public final boolean markConditionally;
32     public final boolean markDescriptorClasses;
33     public final boolean allowShrinking;
34     public final boolean allowOptimization;
35     public final boolean allowObfuscation;
36 
37 
38     /**
39      * Creates a new KeepClassSpecification for all possible classes.
40      * @param markClasses           specifies whether to mark the classes.
41      *                              If false, only class members are marked.
42      *                              If true, the classes are marked as well.
43      * @param markConditionally     specifies whether to mark the classes and
44      *                              class members conditionally. If true,
45      *                              classes and class members are marked, on
46      *                              the condition that all specified class
47      *                              members are present.
48      * @param markDescriptorClasses specifies whether to mark the classes in
49      *                              the descriptors of the marked class members.
50      * @param allowShrinking        specifies whether shrinking is allowed.
51      * @param allowOptimization     specifies whether optimization is allowed.
52      * @param allowObfuscation      specifies whether obfuscation is allowed.
53      */
KeepClassSpecification(boolean markClasses, boolean markConditionally, boolean markDescriptorClasses, boolean allowShrinking, boolean allowOptimization, boolean allowObfuscation)54     public KeepClassSpecification(boolean markClasses,
55                                   boolean markConditionally,
56                                   boolean markDescriptorClasses,
57                                   boolean allowShrinking,
58                                   boolean allowOptimization,
59                                   boolean allowObfuscation)
60     {
61         this.markClasses           = markClasses;
62         this.markConditionally     = markConditionally;
63         this.markDescriptorClasses = markDescriptorClasses;
64         this.allowShrinking        = allowShrinking;
65         this.allowOptimization     = allowOptimization;
66         this.allowObfuscation      = allowObfuscation;
67     }
68 
69 
70     /**
71      * Creates a new KeepClassSpecification.
72      * @param markClasses           specifies whether to mark the classes.
73      *                              If false, only class members are marked.
74      *                              If true, the classes are marked as well.
75      * @param markConditionally     specifies whether to mark the classes and
76      *                              class members conditionally. If true,
77      *                              classes and class members are marked, on
78      *                              the condition that all specified class
79      *                              members are present.
80      * @param markDescriptorClasses specifies whether to mark the classes in
81      *                              the descriptors of the marked class members.
82      * @param allowShrinking        specifies whether shrinking is allowed.
83      * @param allowOptimization     specifies whether optimization is allowed.
84      * @param allowObfuscation      specifies whether obfuscation is allowed.
85      * @param classSpecification    the specification of classes and class
86      *                              members.
87      */
KeepClassSpecification(boolean markClasses, boolean markConditionally, boolean markDescriptorClasses, boolean allowShrinking, boolean allowOptimization, boolean allowObfuscation, ClassSpecification classSpecification)88     public KeepClassSpecification(boolean            markClasses,
89                                   boolean            markConditionally,
90                                   boolean            markDescriptorClasses,
91                                   boolean            allowShrinking,
92                                   boolean            allowOptimization,
93                                   boolean            allowObfuscation,
94                                   ClassSpecification classSpecification)
95     {
96         super(classSpecification);
97 
98         this.markClasses           = markClasses;
99         this.markConditionally     = markConditionally;
100         this.markDescriptorClasses = markDescriptorClasses;
101         this.allowShrinking        = allowShrinking;
102         this.allowOptimization     = allowOptimization;
103         this.allowObfuscation      = allowObfuscation;
104     }
105 
106 
107     // Implementations for Object.
108 
equals(Object object)109     public boolean equals(Object object)
110     {
111         if (object == null ||
112             this.getClass() != object.getClass())
113         {
114             return false;
115         }
116 
117         KeepClassSpecification other = (KeepClassSpecification)object;
118         return
119             this.markClasses           == other.markClasses           &&
120             this.markConditionally     == other.markConditionally     &&
121             this.markDescriptorClasses == other.markDescriptorClasses &&
122             this.allowShrinking        == other.allowShrinking        &&
123             this.allowOptimization     == other.allowOptimization     &&
124             this.allowObfuscation      == other.allowObfuscation      &&
125             super.equals(other);
126     }
127 
hashCode()128     public int hashCode()
129     {
130         return
131             (markClasses           ? 0 :  1) ^
132             (markConditionally     ? 0 :  2) ^
133             (markDescriptorClasses ? 0 :  4) ^
134             (allowShrinking        ? 0 :  8) ^
135             (allowOptimization     ? 0 : 16) ^
136             (allowObfuscation      ? 0 : 32) ^
137             super.hashCode();
138     }
139 
clone()140     public Object clone()
141     {
142 //        try
143 //        {
144             return super.clone();
145 //        }
146 //        catch (CloneNotSupportedException e)
147 //        {
148 //            return null;
149 //        }
150     }
151 }
152