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.ant; 22 23 import proguard.KeepClassSpecification; 24 25 import java.util.List; 26 27 /** 28 * This DataType represents a class specification in Ant. 29 * 30 * @author Eric Lafortune 31 */ 32 public class KeepSpecificationElement extends ClassSpecificationElement 33 { 34 private boolean markDescriptorClasses; 35 private boolean allowShrinking; 36 private boolean allowOptimization; 37 private boolean allowObfuscation; 38 39 40 /** 41 * Adds the contents of this class specification element to the given list. 42 * @param keepSpecifications the class specifications to be extended. 43 * @param markClasses specifies whether to mark the classes. 44 * @param markConditionally specifies whether to mark the classes 45 * and class members conditionally. 46 */ appendTo(List keepSpecifications, boolean markClasses, boolean markConditionally)47 public void appendTo(List keepSpecifications, 48 boolean markClasses, 49 boolean markConditionally) 50 { 51 // Get the referenced file set, or else this one. 52 KeepSpecificationElement keepSpecificationElement = isReference() ? 53 (KeepSpecificationElement)getCheckedRef(this.getClass(), 54 this.getClass().getName()) : 55 this; 56 57 KeepClassSpecification keepClassSpecification = 58 new KeepClassSpecification(markClasses, 59 markConditionally, 60 markDescriptorClasses, 61 allowShrinking, 62 allowOptimization, 63 allowObfuscation, 64 createClassSpecification(keepSpecificationElement)); 65 66 // Add it to the list. 67 keepSpecifications.add(keepClassSpecification); 68 } 69 70 71 // Ant task attributes. 72 setIncludedescriptorclasses(boolean markDescriptorClasses)73 public void setIncludedescriptorclasses(boolean markDescriptorClasses) 74 { 75 this.markDescriptorClasses = markDescriptorClasses; 76 } 77 78 setAllowshrinking(boolean allowShrinking)79 public void setAllowshrinking(boolean allowShrinking) 80 { 81 this.allowShrinking = allowShrinking; 82 } 83 84 setAllowoptimization(boolean allowOptimization)85 public void setAllowoptimization(boolean allowOptimization) 86 { 87 this.allowOptimization = allowOptimization; 88 } 89 90 setAllowobfuscation(boolean allowObfuscation)91 public void setAllowobfuscation(boolean allowObfuscation) 92 { 93 this.allowObfuscation = allowObfuscation; 94 } 95 } 96