KickJava   Java API By Example, From Geeks To Geeks.

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


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: ScriptConstants.java,v 1.3 2002/04/23 22:58:45 glurk Exp $
24  */

25 package net.sf.javaguard;
26
27
28 /** This interface contains all possible constants that may be used inside
29  * the script file.
30  */

31 public interface ScriptConstants {
32   /** Script file directive for additional obfuscator attributes. */
33   public static final String JavaDoc DIRECTIVE_ATTRIBUTE = ".attribute";
34   /** The <code>int</code> value representing the <code>.attribute</code> directive. */
35   public static final int TYPE_ATTRIBUTE = 0;
36   
37   /** Script file directive for additional obfuscator attributes. */
38   public static final String JavaDoc DIRECTIVE_RENAME = ".rename";
39   /** The <code>int</code> value representing the <code>.rename</code> directive. */
40   public static final int TYPE_RENAME = 1;
41   
42   /** Script file directive for additional obfuscator attributes. */
43   public static final String JavaDoc DIRECTIVE_PRESERVE = ".preserve";
44   /** The <code>int</code> value representing the <code>.rename</code> directive. */
45   public static final int TYPE_PRESERVE = 2;
46   
47   
48   
49   /** Script file directive for retaining packages. */
50   public static final String JavaDoc DIRECTIVE_PACKAGE = ".package";
51   /** The <code>int</code> value representing the <code>.package</code> directive. */
52   public static final int TYPE_PACKAGE = 10;
53   
54   /** Script file directive for package mapping. */
55   public static final String JavaDoc DIRECTIVE_PACKAGE_MAP = ".package_map";
56   /** The <code>int</code> value representing the <code>.package_map</code> directive. */
57   public static final int TYPE_PACKAGE_MAP = 11;
58   
59   
60   /** Script file directive for retaining classes. */
61   public static final String JavaDoc DIRECTIVE_CLASS = ".class";
62   /** The <code>int</code> value representing the <code>.class</code> directive. */
63   public static final int TYPE_CLASS = 20;
64   
65   /** Script file directive for class mapping. */
66   public static final String JavaDoc DIRECTIVE_CLASS_MAP = ".class_map";
67   /** The <code>int</code> value representing the <code>.class_map</code> directive. */
68   public static final int TYPE_CLASS_MAP = 21;
69   
70   
71   /** Script file directive for retaining methods. */
72   public static final String JavaDoc DIRECTIVE_METHOD = ".method";
73   /** The <code>int</code> value representing the <code>.method</code> directive. */
74   public static final int TYPE_METHOD = 30;
75   
76   /** Script file directive for method mapping. */
77   public static final String JavaDoc DIRECTIVE_METHOD_MAP = ".method_map";
78   /** The <code>int</code> value representing the <code>.method_map</code> directive. */
79   public static final int TYPE_METHOD_MAP = 31;
80   
81   
82   /** Script file directive for retaining fields. */
83   public static final String JavaDoc DIRECTIVE_FIELD = ".field";
84   /** The <code>int</code> value representing the <code>.field</code> directive. */
85   public static final int TYPE_FIELD = 40;
86   
87   /** Script file directive for field mapping. */
88   public static final String JavaDoc DIRECTIVE_FIELD_MAP = ".field_map";
89   /** The <code>int</code> value representing the <code>.field_map</code> directive. */
90   public static final int TYPE_FIELD_MAP = 41;
91   
92   
93   /** Script file directive for default ignore patterns. */
94   public static final String JavaDoc DIRECTIVE_IGNORE = ".ignore";
95   /** The <code>int</code> value representing the <code>.ignore</code> directive. */
96   public static final int TYPE_IGNORE = 50;
97   
98   /** Script file directive for package ignore patterns. */
99   public static final String JavaDoc DIRECTIVE_IGNORE_PACKAGE = ".ignore_package";
100   /** The <code>int</code> value representing the <code>.ignore_package</code> directive. */
101   public static final int TYPE_IGNORE_PACKAGE = 51;
102   
103   /** Script file directive for class ignore patterns. */
104   public static final String JavaDoc DIRECTIVE_IGNORE_CLASS = ".ignore_class";
105   /** The <code>int</code> value representing the <code>.ignore_class</code> directive. */
106   public static final int TYPE_IGNORE_CLASS = 52;
107   
108   /** Script file directive for method ignore patterns. */
109   public static final String JavaDoc DIRECTIVE_IGNORE_METHOD = ".ignore_method";
110   /** The <code>int</code> value representing the <code>.ignore_method</code> directive. */
111   public static final int TYPE_IGNORE_METHOD = 53;
112   
113   /** Script file directive for field ignore patterns. */
114   public static final String JavaDoc DIRECTIVE_IGNORE_FIELD = ".ignore_field";
115   /** The <code>int</code> value representing the <code>.ignore_field</code> directive. */
116   public static final int TYPE_IGNORE_FIELD = 54;
117   
118   
119   /** Script file directive for default obfuscation patterns. */
120   public static final String JavaDoc DIRECTIVE_OBFUSCATE = ".obfuscate";
121   /** The <code>int</code> value representing the <code>.obfuscate</code> directive. */
122   public static final int TYPE_OBFUSCATE = 60;
123   
124   /** Script file directive for package obfuscation patterns. */
125   public static final String JavaDoc DIRECTIVE_OBFUSCATE_PACKAGE = ".obfuscate_package";
126   /** The <code>int</code> value representing the <code>.obfuscate_package</code> directive. */
127   public static final int TYPE_OBFUSCATE_PACKAGE = 61;
128   
129   /** Script file directive for class obfuscation patterns. */
130   public static final String JavaDoc DIRECTIVE_OBFUSCATE_CLASS = ".obfuscate_class";
131   /** The <code>int</code> value representing the <code>.obfuscate_class</code> directive. */
132   public static final int TYPE_OBFUSCATE_CLASS = 62;
133   
134   /** Script file directive for method obfuscation patterns. */
135   public static final String JavaDoc DIRECTIVE_OBFUSCATE_METHOD = ".obfuscate_method";
136   /** The <code>int</code> value representing the <code>.obfuscate_method</code> directive. */
137   public static final int TYPE_OBFUSCATE_METHOD = 63;
138   
139   /** Script file directive for field obfuscation patterns. */
140   public static final String JavaDoc DIRECTIVE_OBFUSCATE_FIELD = ".obfuscate_field";
141   /** The <code>int</code> value representing the <code>.obfuscate_field</code> directive. */
142   public static final int TYPE_OBFUSCATE_FIELD = 64;
143   
144   
145   /** Holds the array with all possible script file directives. */
146   public static final String JavaDoc[] directives = {
147     DIRECTIVE_ATTRIBUTE,
148     DIRECTIVE_RENAME,
149     DIRECTIVE_PRESERVE,
150     DIRECTIVE_PACKAGE,
151     DIRECTIVE_PACKAGE_MAP,
152     DIRECTIVE_CLASS,
153     DIRECTIVE_CLASS_MAP,
154     DIRECTIVE_METHOD,
155     DIRECTIVE_METHOD_MAP,
156     DIRECTIVE_FIELD,
157     DIRECTIVE_FIELD_MAP,
158     DIRECTIVE_IGNORE,
159     DIRECTIVE_IGNORE_PACKAGE,
160     DIRECTIVE_IGNORE_CLASS,
161     DIRECTIVE_IGNORE_METHOD,
162     DIRECTIVE_IGNORE_FIELD,
163     DIRECTIVE_OBFUSCATE,
164     DIRECTIVE_OBFUSCATE_PACKAGE,
165     DIRECTIVE_OBFUSCATE_CLASS,
166     DIRECTIVE_OBFUSCATE_METHOD,
167     DIRECTIVE_OBFUSCATE_FIELD
168   };
169   
170   
171   /** Holds the array with all possible <code>int</code> values representing
172    * the script file directives.
173    */

174   public static final int[] directiveTypes = {
175     TYPE_ATTRIBUTE,
176     TYPE_RENAME,
177     TYPE_PRESERVE,
178     TYPE_PACKAGE,
179     TYPE_PACKAGE_MAP,
180     TYPE_CLASS,
181     TYPE_CLASS_MAP,
182     TYPE_METHOD,
183     TYPE_METHOD_MAP,
184     TYPE_FIELD,
185     TYPE_FIELD_MAP,
186     TYPE_IGNORE,
187     TYPE_IGNORE_PACKAGE,
188     TYPE_IGNORE_CLASS,
189     TYPE_IGNORE_METHOD,
190     TYPE_IGNORE_FIELD,
191     TYPE_OBFUSCATE,
192     TYPE_OBFUSCATE_PACKAGE,
193     TYPE_OBFUSCATE_CLASS,
194     TYPE_OBFUSCATE_METHOD,
195     TYPE_OBFUSCATE_FIELD,
196   };
197   
198   
199   
200   
201   /** Optional parameter for the <code>.class</code> directive to not obfuscate
202    * public elements.
203    */

204   public static final String JavaDoc OPTION_PUBLIC = "public";
205   /** The <code>int</code> value representing the <code>public</code> option. */
206   public static final int OPTION_TYPE_PUBLIC = 1000;
207   
208   /** Optional parameter for the <code>.class</code> directive to not obfuscate
209    * protected elements.
210    */

211   public static final String JavaDoc OPTION_PROTECTED = "protected";
212   /** The <code>int</code> value representing the <code>protected</code> option. */
213   public static final int OPTION_TYPE_PROTECTED = 1001;
214   
215   /** Optional parameter for the <code>.class</code> directive to not obfuscate
216    * methods.
217    */

218   public static final String JavaDoc OPTION_METHOD = "method";
219   /** The <code>int</code> value representing the <code>method</code> option. */
220   public static final int OPTION_TYPE_METHOD = 1002;
221   
222   /** Optional parameter for the <code>.class</code> directive to not obfuscate
223    * fields.
224    */

225   public static final String JavaDoc OPTION_FIELD = "field";
226   /** The <code>int</code> value representing the <code>field</code> option. */
227   public static final int OPTION_TYPE_FIELD = 1003;
228   
229   
230   
231   
232   /** Holds an array with additional options possible for the <code>.class</code>
233    * directive.
234    */

235   public static final String JavaDoc[] options = {
236     OPTION_PUBLIC,
237     OPTION_PROTECTED,
238     OPTION_METHOD,
239     OPTION_FIELD
240   };
241   
242   
243   /** Holds the array with all possible <code>int</code> values representing
244    * the additional options for the <code>.class</code> directive.
245    */

246   public static final int[] optionTypes = {
247     OPTION_TYPE_PUBLIC,
248     OPTION_TYPE_PROTECTED,
249     OPTION_TYPE_METHOD,
250     OPTION_TYPE_FIELD
251   };
252   
253   
254   
255   
256   // additional attributes for the obfuscator:
257

258   /** Specifies how the obfuscator should work. */
259   public static final String JavaDoc ATTR_Unknown = "Unknown";
260   /** Specifies how the obfuscator should work. */
261   public static final String JavaDoc ATTR_Code = "Code";
262   /** Specifies how the obfuscator should work. */
263   public static final String JavaDoc ATTR_ConstantValue = "ConstantValue";
264   /** Specifies how the obfuscator should work. */
265   public static final String JavaDoc ATTR_Exceptions = "Exceptions";
266   /** Specifies how the obfuscator should work. */
267   public static final String JavaDoc ATTR_LineNumberTable = "LineNumberTable";
268   /** Specifies how the obfuscator should work. */
269   public static final String JavaDoc ATTR_SourceFile = "SourceFile";
270   /** Specifies how the obfuscator should work. */
271   public static final String JavaDoc ATTR_LocalVariableTable = "LocalVariableTable";
272   /** Specifies how the obfuscator should work. */
273   public static final String JavaDoc ATTR_InnerClasses = "InnerClasses";
274   /** Specifies how the obfuscator should work. */
275   public static final String JavaDoc ATTR_Synthetic = "Synthetic";
276   
277   
278   /** An array that contains all valid options for the <code>.attribute</code>
279    * directive.
280    */

281   public static String JavaDoc[] validAttrs = {
282     ATTR_Unknown,
283     ATTR_Code,
284     ATTR_ConstantValue,
285     ATTR_Exceptions,
286     ATTR_LineNumberTable,
287     ATTR_SourceFile,
288     ATTR_LocalVariableTable,
289     ATTR_InnerClasses,
290     ATTR_Synthetic
291   };
292   
293   
294   
295   
296   /** Attribute for the obfuscator to treat RMIC-generated classes in a special
297    * way.
298    */

299   public static final String JavaDoc RENAME_RMIC = "rmic";
300   /** Attribute for the obfuscator to rename resource files according to their
301    * class files.
302    */

303   public static final String JavaDoc RENAME_RESOURCES = "resources";
304   
305   
306   /** An array that contains all valid options for the <code>.rename</code>
307    * directive.
308    */

309   public static String JavaDoc[] renameAttrs = {
310     RENAME_RMIC,
311     RENAME_RESOURCES
312   };
313   
314   
315   
316   
317   /** Attribute for the obfuscator to prevent classes that are used in
318    * hardcoded references from being assigned obfuscated names.
319    */

320   public static final String JavaDoc PRESERVE_REFERENCES = "hardcodedreferences";
321   
322   /** An array that contains all valid options for the <code>.preserve</code>
323    * directive.
324    */

325   public static String JavaDoc[] preserveAttrs = {
326     PRESERVE_REFERENCES
327   };
328 }
329
Popular Tags