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