KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > proguard > ant > KeepAttributeElement


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.ant;
22
23 import org.apache.tools.ant.types.*;
24
25 import java.util.*;
26
27 /**
28  * This DataType represents a named attribute in Ant.
29  *
30  * @author Eric Lafortune
31  */

32 public class KeepAttributeElement extends DataType
33 {
34     private String JavaDoc name;
35
36
37     /**
38      * Adds the contents of this element to the given list of attributes.
39      * @param keepAttributes the list of attributes to be extended.
40      */

41     public void appendTo(List keepAttributes)
42     {
43         // Get the referenced element, or else this one.
44
KeepAttributeElement keepAttributeElement = isReference() ?
45             (KeepAttributeElement)getCheckedRef(this.getClass(),
46                                                 this.getClass().getName()) :
47             this;
48
49         String JavaDoc name = keepAttributeElement.name;
50
51         if (name == null)
52         {
53             // Clear the list to keep all attributes.
54
keepAttributes.clear();
55         }
56         else
57         {
58             // Add the attibute name to the list.
59
keepAttributes.add(name);
60         }
61     }
62
63
64     // Ant task attributes.
65

66     public void setName(String JavaDoc name)
67     {
68         this.name = name;
69     }
70 }
71
Popular Tags