KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > javaguard > ScriptEntry


1 /**
2  * JavaGuard -- an obfuscation package for Java classfiles.
3  *
4  * Copyright (c) 2002 Thorsten Heit (theit@gmx.de)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * The author may be contacted at theit@gmx.de.
21  *
22  *
23  * $Id: ScriptEntry.java,v 1.1.1.1 2002/04/03 13:49:45 glurk Exp $
24  */

25 package net.sf.javaguard;
26
27
28
29
30 /** Representation of a script file entry.
31  *
32  * @author <a HREF="mailto:theit@gmx.de">Thorsten Heit</a>
33  */

34 public class ScriptEntry {
35   /** The <code>int</code> value representing the <code>public</code> modifier. */
36   public static final int PUBLIC = 1;
37   /** The <code>int</code> value representing the <code>public</code> modifier. */
38   public static final int PROTECTED = 2;
39   /** The <code>int</code> value representing the <code>public</code> modifier. */
40   public static final int PRIVATE = 4;
41   /** The <code>int</code> value representing the <code>public</code> modifier. */
42   public static final int FIELD = 8;
43   /** The <code>int</code> value representing the <code>public</code> modifier. */
44   public static final int METHOD = 16;
45   
46   
47   /** Holds the type of the entry.
48    * @see ScriptConstants
49    */

50   private int type;
51   
52   /** Holds the name.
53    * @see #info
54    */

55   private String JavaDoc name;
56   
57   /** Holds a Java descriptor for the class/field/method name. */
58   private String JavaDoc descriptor;
59   
60   /** Holds the mapped output name of a class, field or method entry.
61    * @see #name
62    */

63   private String JavaDoc mappedName;
64   
65   /** Holds additional attributes if the entry is a class entry.
66    */

67   private int attrs;
68   
69   /** Holds an additional info string if the entry is an attribute entry.
70    */

71   private String JavaDoc info;
72   
73   
74   
75   
76   /** Creates a new entry that only consists of a type and a name.
77    * @param type the entry type
78    * @param name the name of the entry; may not be null
79    */

80   public ScriptEntry(int type, String JavaDoc name) {
81     this(type, name, null);
82   }
83   
84   
85   /** Creates a new entry that has a type, a name and an additional descriptor.
86    * @param type the entry type
87    * @param name the name of the entry; may not be null
88    * @param descriptor a descriptor for the entry name
89    */

90   public ScriptEntry(int type, String JavaDoc name, String JavaDoc descriptor) {
91     this(type, name, descriptor, null);
92   }
93   
94   
95   /** Creates a new entry that has a type, a name, an additional descriptor and
96    * an additional info string.
97    * @param type the entry type
98    * @param name the name of the entry; may not be null
99    * @param descriptor a descriptor for the entry name
100    * @param mappedName the mapped name
101    */

102   public ScriptEntry(int type, String JavaDoc name, String JavaDoc descriptor, String JavaDoc mappedName) {
103     this(type, name, descriptor, mappedName, 0);
104   }
105   
106   
107   /** Creates a new entry that has a type, a name, an additional descriptor, an
108    * optional mapped name and additional attributes.
109    * @param type the entry type
110    * @param name the name of the entry; may not be null
111    * @param descriptor a descriptor for the entry name
112    * @param mappedName the mapped name
113    * @param attrs additional attributes of the entry
114    */

115   public ScriptEntry(int type, String JavaDoc name, String JavaDoc descriptor, String JavaDoc mappedName, int attrs) {
116     this(type, name, descriptor, mappedName, attrs, null);
117   }
118   
119   
120   /** Creates a new entry that has a type, a name, an additional descriptor, an
121    * optional mapped name and additional attributes.
122    * @param type the entry type
123    * @param name the name of the entry; may not be null
124    * @param descriptor a descriptor for the entry name
125    * @param mappedName the mapped name
126    * @param attrs additional attributes of the entry
127    * @param info an additiona info string for the entry
128    */

129   public ScriptEntry(int type, String JavaDoc name, String JavaDoc descriptor, String JavaDoc mappedName,
130   int attrs, String JavaDoc info) {
131     setType(type);
132     setName(name);
133     setDescriptor(descriptor);
134     setMappedName(mappedName);
135     setAttrs(attrs);
136     setInfo(info);
137   }
138   
139   
140   
141   
142   /** Sets the type of the entry.
143    * @param aType the type of the entry
144    * @see #getType
145    */

146   public void setType(int aType) {
147     this.type = aType;
148   }
149   
150   
151   /** Returns the type of the current entry.
152    * @return type of the entry
153    * @see #setType
154    */

155   public int getType() {
156     return type;
157   }
158   
159   
160   
161   
162   /** Sets the name property of the entry.
163    * @param name New value of property name.
164    * @see #getName
165    */

166   public void setName(String JavaDoc aName) {
167     this.name = aName;
168   }
169   
170   
171   /** Returns the name property of the entry.
172    * @return Value of property name.
173    * @see #setName
174    */

175   public String JavaDoc getName() {
176     return name;
177   }
178   
179   
180   
181   
182   /** Sets the descriptor property of the entry.
183    * @param descriptor New value of property descriptor.
184    * @see #getDescriptor
185    */

186   public void setDescriptor(String JavaDoc descriptor) {
187     this.descriptor = descriptor;
188   }
189   
190   
191   /** Returns the descriptor property of the entry.
192    * @return Value of property descriptor.
193    * @see #setDescriptor
194    */

195   public String JavaDoc getDescriptor() {
196     return descriptor;
197   }
198   
199   
200   
201   
202   /** Sets the mapped name for the current entry.
203    * @param name a string that contains the mapped name
204    * @see #getMappedName
205    */

206   public void setMappedName(String JavaDoc name) {
207     this.mappedName = name;
208   }
209   
210   
211   /** Returns the mapped name of the current entry.
212    * @return the mapped name
213    * @see #setMappedName
214    */

215   public String JavaDoc getMappedName() {
216     return mappedName;
217   }
218   
219   
220   
221   
222   /** Setter for property attrs.
223    * @param attrs New value of property attrs.
224    */

225   public void setAttrs(int attrs) {
226     this.attrs = attrs;
227   }
228   
229   
230   /** Getter for property attrs.
231    * @return Value of property attrs.
232    */

233   public int getAttrs() {
234     return attrs;
235   }
236   
237   
238   
239   
240   /** Sets whether the entry wants its public elements to be retained.
241    * @param canRetain true if the public elements are retained; false else
242    * @see #canRetainPublic
243    */

244   public void setRetainPublic(boolean canRetain) {
245     if (canRetain) {
246       setAttrs(getAttrs() | PUBLIC);
247     } else {
248       setAttrs(getAttrs() & ~PUBLIC);
249     }
250   }
251   
252   
253   /** Returns whether the entry wants its public elements to be retained.
254    * @return true if the public elements are retained; false else
255    * @see #setRetainPublic
256    */

257   public boolean canRetainPublic() {
258     return true == ((getAttrs() & PUBLIC) != 0);
259   }
260   
261   
262
263   
264   /** Sets whether the entry wants its protected elements to be retained.
265    * @param canRetain true if the protected elements are retained; false else
266    * @see #canRetainProtected
267    */

268   public void setRetainProtected(boolean canRetain) {
269     if (canRetain) {
270       setAttrs(getAttrs() | PROTECTED);
271     } else {
272       setAttrs(getAttrs() & ~PROTECTED);
273     }
274   }
275   
276   
277   /** Returns whether the entry wants its protected elements to be retained.
278    * @return true if the protected elements are retained; false else
279    * @see #setRetainProtected
280    */

281   public boolean canRetainProtected() {
282     return true == ((getAttrs() & PROTECTED) != 0);
283   }
284   
285   
286   
287   
288   /** Sets whether the entry wants its fields to be retained.
289    * @param canRetain true if the fields are retained; false else
290    * @see #canRetainFields
291    */

292   public void setRetainFields(boolean canRetain) {
293     if (canRetain) {
294       setAttrs(getAttrs() | FIELD);
295     } else {
296       setAttrs(getAttrs() & ~FIELD);
297     }
298   }
299   
300   
301   /** Returns whether the entry wants its fields to be retained.
302    * @return true if the fields are retained; false else
303    * @see #setRetainFields
304    */

305   public boolean canRetainFields() {
306     return true == ((getAttrs() & FIELD) != 0);
307   }
308   
309   
310   
311
312   /** Sets whether the entry wants its methods to be retained.
313    * @param canRetain true if the methods are retained; false else
314    * @see #canRetainMethods
315    */

316   public void setRetainMethods(boolean canRetain) {
317     if (canRetain) {
318       setAttrs(getAttrs() | METHOD);
319     } else {
320       setAttrs(getAttrs() & ~METHOD);
321     }
322   }
323   
324   
325   /** Returns whether the entry wants its methods to be retained.
326    * @return true if the methods are retained; false else
327    * @see #setRetainMethods
328    */

329   public boolean canRetainMethods() {
330     return true == ((getAttrs() & METHOD) != 0);
331   }
332   
333   
334   
335   
336   /** Sets an additional info string for the entry.
337    * @param info additional info string; may be null
338    * @see #getInfo
339    */

340   public void setInfo(String JavaDoc info) {
341     this.info = info;
342   }
343   
344   
345   /** Returns the additional info string assigned to the entry.
346    * @return additional info string
347    * @see #setInfo
348    */

349   public String JavaDoc getInfo() {
350     return info;
351   }
352 }
353
Popular Tags