intial version
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / impl / CompilerOptions.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.impl;
12
13 import java.io.ByteArrayInputStream;
14 import java.io.InputStreamReader;
15 import java.io.UnsupportedEncodingException;
16 import java.util.Map;
17
18 import net.sourceforge.phpdt.internal.compiler.Compiler;
19 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
20 import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
21
22
23 public class CompilerOptions implements ProblemReasons, ProblemSeverities {
24         
25         /**
26          * Option IDs
27          */
28         public static final String OPTION_LocalVariableAttribute = "org.eclipse.jdt.core.compiler.debug.localVariable"; //$NON-NLS-1$
29         public static final String OPTION_LineNumberAttribute = "org.eclipse.jdt.core.compiler.debug.lineNumber"; //$NON-NLS-1$
30         public static final String OPTION_SourceFileAttribute = "org.eclipse.jdt.core.compiler.debug.sourceFile"; //$NON-NLS-1$
31         public static final String OPTION_PreserveUnusedLocal = "org.eclipse.jdt.core.compiler.codegen.unusedLocal"; //$NON-NLS-1$
32         public static final String OPTION_ReportUnreachableCode = "org.eclipse.jdt.core.compiler.problem.unreachableCode"; //$NON-NLS-1$
33         public static final String OPTION_ReportInvalidImport = "org.eclipse.jdt.core.compiler.problem.invalidImport"; //$NON-NLS-1$
34         public static final String OPTION_ReportMethodWithConstructorName = "org.eclipse.jdt.core.compiler.problem.methodWithConstructorName"; //$NON-NLS-1$
35         public static final String OPTION_ReportOverridingPackageDefaultMethod = "org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod"; //$NON-NLS-1$
36         public static final String OPTION_ReportDeprecation = "org.eclipse.jdt.core.compiler.problem.deprecation"; //$NON-NLS-1$
37         public static final String OPTION_ReportHiddenCatchBlock = "org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock"; //$NON-NLS-1$
38         public static final String OPTION_ReportUnusedLocal = "org.eclipse.jdt.core.compiler.problem.unusedLocal"; //$NON-NLS-1$
39         public static final String OPTION_ReportUnusedParameter = "org.eclipse.jdt.core.compiler.problem.unusedParameter"; //$NON-NLS-1$
40         public static final String OPTION_ReportUnusedImport = "org.eclipse.jdt.core.compiler.problem.unusedImport"; //$NON-NLS-1$
41         public static final String OPTION_ReportSyntheticAccessEmulation = "org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation"; //$NON-NLS-1$
42         public static final String OPTION_ReportNonExternalizedStringLiteral = "org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral"; //$NON-NLS-1$
43         public static final String OPTION_Source = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
44         public static final String OPTION_TargetPlatform = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$
45         public static final String OPTION_ReportAssertIdentifier = "org.eclipse.jdt.core.compiler.problem.assertIdentifier"; //$NON-NLS-1$
46         public static final String OPTION_Compliance = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
47         public static final String OPTION_Encoding = "org.eclipse.jdt.core.encoding"; //$NON-NLS-1$
48         public static final String OPTION_MaxProblemPerUnit = "org.eclipse.jdt.core.compiler.maxProblemPerUnit"; //$NON-NLS-1$
49
50         /* should surface ??? */
51         public static final String OPTION_PrivateConstructorAccess = "org.eclipse.jdt.core.compiler.codegen.constructorAccessEmulation"; //$NON-NLS-1$
52
53         /**
54          * Possible values for configurable options
55          */
56         public static final String GENERATE = "generate";//$NON-NLS-1$
57         public static final String DO_NOT_GENERATE = "do not generate"; //$NON-NLS-1$
58         public static final String PRESERVE = "preserve"; //$NON-NLS-1$
59         public static final String OPTIMIZE_OUT = "optimize out"; //$NON-NLS-1$
60         public static final String VERSION_1_1 = "1.1"; //$NON-NLS-1$
61         public static final String VERSION_1_2 = "1.2"; //$NON-NLS-1$
62         public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
63         public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
64         public static final String ERROR = "error"; //$NON-NLS-1$
65         public static final String WARNING = "warning"; //$NON-NLS-1$
66         public static final String IGNORE = "ignore"; //$NON-NLS-1$
67         
68         /**
69          * Bit mask for configurable problems (error/warning threshold)
70          */
71         public static final int UnreachableCode = 0x100;
72         public static final int ImportProblem = 0x400;
73         public static final int MethodWithConstructorName = 0x1000;
74         public static final int OverriddenPackageDefaultMethod = 0x2000;
75         public static final int UsingDeprecatedAPI = 0x4000;
76         public static final int MaskedCatchBlock = 0x8000;
77         public static final int UnusedLocalVariable = 0x10000;
78         public static final int UnusedArgument = 0x20000;
79         public static final int NoImplicitStringConversion = 0x40000;
80         public static final int AccessEmulation = 0x80000;
81         public static final int NonExternalizedString = 0x100000;
82         public static final int AssertUsedAsAnIdentifier = 0x200000;
83         public static final int UnusedImport = 0x400000;
84                 
85         // Default severity level for handlers
86         public int errorThreshold = UnreachableCode | ImportProblem;
87         public int warningThreshold = 
88                 MethodWithConstructorName | OverriddenPackageDefaultMethod
89                 | UsingDeprecatedAPI | MaskedCatchBlock 
90                 | AssertUsedAsAnIdentifier | NoImplicitStringConversion;
91
92         // Debug attributes
93         public static final int Source = 1; // SourceFileAttribute
94         public static final int Lines = 2; // LineNumberAttribute
95         public static final int Vars = 4; // LocalVariableTableAttribute
96
97         // By default only lines and source attributes are generated.
98         public int produceDebugAttributes = Lines | Source;
99
100
101         // JDK 1.1, 1.2, 1.3 or 1.4
102         public static final int JDK1_1 = 0;
103         public static final int JDK1_2 = 1;
104         public static final int JDK1_3 = 2;
105         public static final int JDK1_4 = 3;
106         
107         public int targetJDK = JDK1_1; // default generates for JVM1.1
108         public int complianceLevel = JDK1_3; // by default be compliant with 1.3
109
110         // toggle private access emulation for 1.2 (constr. accessor has extra arg on constructor) or 1.3 (make private constructor default access when access needed)
111         public boolean isPrivateConstructorAccessChangingVisibility = false; // by default, follows 1.2
112
113         // 1.4 feature
114         public boolean assertMode = false; //1.3 behavior by default
115         
116         // source encoding format
117         public String defaultEncoding = null; // will use the platform default encoding
118         
119         // print what unit is being processed
120         public boolean verbose = Compiler.DEBUG;
121
122         // indicates if reference info is desired
123         public boolean produceReferenceInfo = true;
124
125         // indicates if unused/optimizable local variables need to be preserved (debugging purpose)
126         public boolean preserveAllLocalVariables = false;
127
128         // indicates whether literal expressions are inlined at parse-time or not
129         public boolean parseLiteralExpressionsAsConstants = true;
130
131         // exception raised for unresolved compile errors
132         public String runtimeExceptionNameForCompileError = "java.lang.Error"; //$NON-NLS-1$
133
134         // max problems per compilation unit
135         public int maxProblemsPerUnit = 100; // no more than 100 problems per default
136         
137         /** 
138          * Initializing the compiler options with defaults
139          */
140         public CompilerOptions(){
141         }
142
143         /** 
144          * Initializing the compiler options with external settings
145          */
146         public CompilerOptions(Map settings){
147
148                 if (settings == null) return;
149                 
150                 // filter options which are related to the compiler component
151                 Object[] entries = settings.entrySet().toArray();
152                 for (int i = 0, max = entries.length; i < max; i++){
153                         Map.Entry entry = (Map.Entry)entries[i];
154                         if (!(entry.getKey() instanceof String)) continue;
155                         if (!(entry.getValue() instanceof String)) continue;
156                         String optionID = (String) entry.getKey();
157                         String optionValue = (String) entry.getValue();
158                         
159                         // Local variable attribute
160                         if(optionID.equals(OPTION_LocalVariableAttribute)){
161                                 if (optionValue.equals(GENERATE)) {
162                                         this.produceDebugAttributes |= Vars;
163                                 } else if (optionValue.equals(DO_NOT_GENERATE)){
164                                         this.produceDebugAttributes &= ~Vars;
165                                 }
166                                 continue;
167                         }  
168                         // Line number attribute        
169                         if(optionID.equals(OPTION_LineNumberAttribute)) {
170                                 if (optionValue.equals(GENERATE)) {
171                                         this.produceDebugAttributes |= Lines;
172                                 } else if (optionValue.equals(DO_NOT_GENERATE)) {
173                                         this.produceDebugAttributes &= ~Lines;
174                                 }
175                                 continue;
176                         } 
177                         // Source file attribute        
178                         if(optionID.equals(OPTION_SourceFileAttribute)) {
179                                 if (optionValue.equals(GENERATE)) {
180                                         this.produceDebugAttributes |= Source;
181                                 } else if (optionValue.equals(DO_NOT_GENERATE)) {
182                                         this.produceDebugAttributes &= ~Source;
183                                 }
184                                 continue;
185                         } 
186                         // Preserve unused local        
187                         if(optionID.equals(OPTION_PreserveUnusedLocal)){
188                                 if (optionValue.equals(PRESERVE)) {
189                                         this.preserveAllLocalVariables = true;
190                                 } else if (optionValue.equals(OPTIMIZE_OUT)) {
191                                         this.preserveAllLocalVariables = false;
192                                 }
193                                 continue;
194                         } 
195                         // Report unreachable code                              
196                         if(optionID.equals(OPTION_ReportUnreachableCode)){
197                                 if (optionValue.equals(ERROR)) {
198                                         this.errorThreshold |= UnreachableCode;
199                                         this.warningThreshold &= ~UnreachableCode;
200                                 } else if (optionValue.equals(WARNING)) {
201                                         this.errorThreshold &= ~UnreachableCode;
202                                         this.warningThreshold |= UnreachableCode;
203                                 } else if (optionValue.equals(IGNORE)) {
204                                         this.errorThreshold &= ~UnreachableCode;
205                                         this.warningThreshold &= ~UnreachableCode;
206                                 }
207                                 continue;
208                         } 
209                         // Report invalid import        
210                         if(optionID.equals(OPTION_ReportInvalidImport)){
211                                 if (optionValue.equals(ERROR)) {
212                                         this.errorThreshold |= ImportProblem;
213                                         this.warningThreshold &= ~ImportProblem;
214                                 } else if (optionValue.equals(WARNING)) {
215                                         this.errorThreshold &= ~ImportProblem;
216                                         this.warningThreshold |= ImportProblem;
217                                 } else if (optionValue.equals(IGNORE)) {
218                                         this.errorThreshold &= ~ImportProblem;
219                                         this.warningThreshold &= ~ImportProblem;
220                                 }
221                                 continue;
222                         } 
223                         // Define the target JDK tag for .classfiles
224                         if(optionID.equals(OPTION_TargetPlatform)){
225                                 if (optionValue.equals(VERSION_1_1)) {
226                                         this.targetJDK = JDK1_1;
227                                 } else if (optionValue.equals(VERSION_1_2)) {
228                                         this.targetJDK = JDK1_2;
229                                 } else if (optionValue.equals(VERSION_1_3)) {
230                                         this.targetJDK = JDK1_3;
231                                 } else if (optionValue.equals(VERSION_1_4)) {
232                                         this.targetJDK = JDK1_4;
233                                 }
234                                 continue;
235                         } 
236                         // Define the JDK compliance level
237                         if(optionID.equals(OPTION_Compliance)){
238                                 if (optionValue.equals(VERSION_1_1)) {
239                                         this.complianceLevel = JDK1_1;
240                                 } else if (optionValue.equals(VERSION_1_2)) {
241                                         this.complianceLevel = JDK1_2;
242                                 } else if (optionValue.equals(VERSION_1_3)) {
243                                         this.complianceLevel = JDK1_3;
244                                 } else if (optionValue.equals(VERSION_1_4)) {
245                                         this.complianceLevel = JDK1_4;
246                                 }
247                                 continue;
248                         } 
249                         // Private constructor access emulation (extra arg vs. visibility change)
250                         if(optionID.equals(OPTION_PrivateConstructorAccess)){
251                                 if (optionValue.equals(VERSION_1_1)) {
252                                         this.isPrivateConstructorAccessChangingVisibility = false;
253                                 } else if (optionValue.equals(VERSION_1_2)) {
254                                         this.isPrivateConstructorAccessChangingVisibility = false;
255                                 } else if (optionValue.equals(VERSION_1_3)) {
256                                         this.isPrivateConstructorAccessChangingVisibility = true;
257                                 } else if (optionValue.equals(VERSION_1_4)) {
258                                         this.isPrivateConstructorAccessChangingVisibility = true;
259                                 }
260                                 continue;
261                         } 
262                         // Report method with constructor name
263                         if(optionID.equals(OPTION_ReportMethodWithConstructorName)){
264                                 if (optionValue.equals(ERROR)) {
265                                         this.errorThreshold |= MethodWithConstructorName;
266                                         this.warningThreshold &= ~MethodWithConstructorName;
267                                 } else if (optionValue.equals(WARNING)) {
268                                         this.errorThreshold &= ~MethodWithConstructorName;
269                                         this.warningThreshold |= MethodWithConstructorName;
270                                 } else if (optionValue.equals(IGNORE)) {
271                                         this.errorThreshold &= ~MethodWithConstructorName;
272                                         this.warningThreshold &= ~MethodWithConstructorName;
273                                 }
274                                 continue;
275                         } 
276                         // Report overriding package default method
277                         if(optionID.equals(OPTION_ReportOverridingPackageDefaultMethod)){
278                                 if (optionValue.equals(ERROR)) {
279                                         this.errorThreshold |= OverriddenPackageDefaultMethod;
280                                         this.warningThreshold &= ~OverriddenPackageDefaultMethod;
281                                 } else if (optionValue.equals(WARNING)) {
282                                         this.errorThreshold &= ~OverriddenPackageDefaultMethod;
283                                         this.warningThreshold |= OverriddenPackageDefaultMethod;
284                                 } else if (optionValue.equals(IGNORE)) {
285                                         this.errorThreshold &= ~OverriddenPackageDefaultMethod;
286                                         this.warningThreshold &= ~OverriddenPackageDefaultMethod;
287                                 }
288                                 continue;
289                         } 
290                         // Report deprecation
291                         if(optionID.equals(OPTION_ReportDeprecation)){
292                                 if (optionValue.equals(ERROR)) {
293                                         this.errorThreshold |= UsingDeprecatedAPI;
294                                         this.warningThreshold &= ~UsingDeprecatedAPI;
295                                 } else if (optionValue.equals(WARNING)) {
296                                         this.errorThreshold &= ~UsingDeprecatedAPI;
297                                         this.warningThreshold |= UsingDeprecatedAPI;
298                                 } else if (optionValue.equals(IGNORE)) {
299                                         this.errorThreshold &= ~UsingDeprecatedAPI;
300                                         this.warningThreshold &= ~UsingDeprecatedAPI;
301                                 }
302                                 continue;
303                         } 
304                         // Report hidden catch block
305                         if(optionID.equals(OPTION_ReportHiddenCatchBlock)){
306                                 if (optionValue.equals(ERROR)) {
307                                         this.errorThreshold |= MaskedCatchBlock;
308                                         this.warningThreshold &= ~MaskedCatchBlock;
309                                 } else if (optionValue.equals(WARNING)) {
310                                         this.errorThreshold &= ~MaskedCatchBlock;
311                                         this.warningThreshold |= MaskedCatchBlock;
312                                 } else if (optionValue.equals(IGNORE)) {
313                                         this.errorThreshold &= ~MaskedCatchBlock;
314                                         this.warningThreshold &= ~MaskedCatchBlock;
315                                 }
316                                 continue;
317                         } 
318                         // Report unused local variable
319                         if(optionID.equals(OPTION_ReportUnusedLocal)){
320                                 if (optionValue.equals(ERROR)) {
321                                         this.errorThreshold |= UnusedLocalVariable;
322                                         this.warningThreshold &= ~UnusedLocalVariable;
323                                 } else if (optionValue.equals(WARNING)) {
324                                         this.errorThreshold &= ~UnusedLocalVariable;
325                                         this.warningThreshold |= UnusedLocalVariable;
326                                 } else if (optionValue.equals(IGNORE)) {
327                                         this.errorThreshold &= ~UnusedLocalVariable;
328                                         this.warningThreshold &= ~UnusedLocalVariable;
329                                 }
330                                 continue;
331                         } 
332                         // Report unused parameter
333                         if(optionID.equals(OPTION_ReportUnusedParameter)){
334                                 if (optionValue.equals(ERROR)) {
335                                         this.errorThreshold |= UnusedArgument;
336                                         this.warningThreshold &= ~UnusedArgument;
337                                 } else if (optionValue.equals(WARNING)) {
338                                         this.errorThreshold &= ~UnusedArgument;
339                                         this.warningThreshold |= UnusedArgument;
340                                 } else if (optionValue.equals(IGNORE)) {
341                                         this.errorThreshold &= ~UnusedArgument;
342                                         this.warningThreshold &= ~UnusedArgument;
343                                 }
344                                 continue;
345                         } 
346                         // Report unused parameter
347                         if(optionID.equals(OPTION_ReportUnusedImport)){
348                                 if (optionValue.equals(ERROR)) {
349                                         this.errorThreshold |= UnusedImport;
350                                         this.warningThreshold &= ~UnusedImport;
351                                 } else if (optionValue.equals(WARNING)) {
352                                         this.errorThreshold &= ~UnusedImport;
353                                         this.warningThreshold |= UnusedImport;
354                                 } else if (optionValue.equals(IGNORE)) {
355                                         this.errorThreshold &= ~UnusedImport;
356                                         this.warningThreshold &= ~UnusedImport;
357                                 }
358                                 continue;
359                         } 
360                         // Report synthetic access emulation
361                         if(optionID.equals(OPTION_ReportSyntheticAccessEmulation)){
362                                 if (optionValue.equals(ERROR)) {
363                                         this.errorThreshold |= AccessEmulation;
364                                         this.warningThreshold &= ~AccessEmulation;
365                                 } else if (optionValue.equals(WARNING)) {
366                                         this.errorThreshold &= ~AccessEmulation;
367                                         this.warningThreshold |= AccessEmulation;
368                                 } else if (optionValue.equals(IGNORE)) {
369                                         this.errorThreshold &= ~AccessEmulation;
370                                         this.warningThreshold &= ~AccessEmulation;
371                                 }
372                                 continue;
373                         }
374                         // Report non-externalized string literals
375                         if(optionID.equals(OPTION_ReportNonExternalizedStringLiteral)){
376                                 if (optionValue.equals(ERROR)) {
377                                         this.errorThreshold |= NonExternalizedString;
378                                         this.warningThreshold &= ~NonExternalizedString;
379                                 } else if (optionValue.equals(WARNING)) {
380                                         this.errorThreshold &= ~NonExternalizedString;
381                                         this.warningThreshold |= NonExternalizedString;
382                                 } else if (optionValue.equals(IGNORE)) {
383                                         this.errorThreshold &= ~NonExternalizedString;
384                                         this.warningThreshold &= ~NonExternalizedString;
385                                 }
386                                 continue;
387                         }
388                         // Report usage of 'assert' as an identifier
389                         if(optionID.equals(OPTION_ReportAssertIdentifier)){
390                                 if (optionValue.equals(ERROR)) {
391                                         this.errorThreshold |= AssertUsedAsAnIdentifier;
392                                         this.warningThreshold &= ~AssertUsedAsAnIdentifier;
393                                 } else if (optionValue.equals(WARNING)) {
394                                         this.errorThreshold &= ~AssertUsedAsAnIdentifier;
395                                         this.warningThreshold |= AssertUsedAsAnIdentifier;
396                                 } else if (optionValue.equals(IGNORE)) {
397                                         this.errorThreshold &= ~AssertUsedAsAnIdentifier;
398                                         this.warningThreshold &= ~AssertUsedAsAnIdentifier;
399                                 }
400                                 continue;
401                         }
402                         // Set the source compatibility mode (assertions)
403                         if(optionID.equals(OPTION_Source)){
404                                 if (optionValue.equals(VERSION_1_3)) {
405                                         this.assertMode = false;
406                                 } else if (optionValue.equals(VERSION_1_4)) {
407                                         this.assertMode = true;
408                                 }
409                                 continue;
410                         }
411                         // Set the default encoding format
412                         if(optionID.equals(OPTION_Encoding)){
413                                 if (optionValue.length() == 0){
414                                         this.defaultEncoding = null;
415                                 } else {
416                                         try { // ignore unsupported encoding
417                                                 new InputStreamReader(new ByteArrayInputStream(new byte[0]), optionValue);
418                                                 this.defaultEncoding = optionValue;
419                                         } catch(UnsupportedEncodingException e){
420                                         }
421                                 }
422                                 continue;
423                         }
424                         // Set the threshold for problems per unit
425                         if(optionID.equals(OPTION_MaxProblemPerUnit)){
426                                 try {
427                                         int val = Integer.parseInt(optionValue);
428                                         if (val >= 0) this.maxProblemsPerUnit = val;
429                                 } catch(NumberFormatException e){
430                                 }                               
431                                 continue;
432                         }
433                 }
434         }
435         
436         public int getTargetJDK() {
437                 return this.targetJDK;
438         }
439
440         public int getNonExternalizedStringLiteralSeverity() {
441                 if((warningThreshold & NonExternalizedString) != 0)
442                         return Warning;
443                 if((errorThreshold & NonExternalizedString) != 0)
444                         return Error;
445                 return Ignore;
446         }
447
448         public void produceReferenceInfo(boolean flag) {
449                 this.produceReferenceInfo = flag;
450         }
451
452         public void setVerboseMode(boolean flag) {
453                 this.verbose = flag;
454         }
455
456         public String toString() {
457         
458
459                 StringBuffer buf = new StringBuffer("CompilerOptions:"); //$NON-NLS-1$
460                 if ((produceDebugAttributes & Vars) != 0){
461                         buf.append("\n-local variables debug attributes: ON"); //$NON-NLS-1$
462                 } else {
463                         buf.append("\n-local variables debug attributes: OFF"); //$NON-NLS-1$
464                 }
465                 if ((produceDebugAttributes & Lines) != 0){
466                         buf.append("\n-line number debug attributes: ON"); //$NON-NLS-1$
467                 } else {
468                         buf.append("\n-line number debug attributes: OFF"); //$NON-NLS-1$
469                 }
470                 if ((produceDebugAttributes & Source) != 0){
471                         buf.append("\n-source debug attributes: ON"); //$NON-NLS-1$
472                 } else {
473                         buf.append("\n-source debug attributes: OFF"); //$NON-NLS-1$
474                 }
475                 if (preserveAllLocalVariables){
476                         buf.append("\n-preserve all local variables: ON"); //$NON-NLS-1$
477                 } else {
478                         buf.append("\n-preserve all local variables: OFF"); //$NON-NLS-1$
479                 }
480                 if ((errorThreshold & UnreachableCode) != 0){
481                         buf.append("\n-unreachable code: ERROR"); //$NON-NLS-1$
482                 } else {
483                         if ((warningThreshold & UnreachableCode) != 0){
484                                 buf.append("\n-unreachable code: WARNING"); //$NON-NLS-1$
485                         } else {
486                                 buf.append("\n-unreachable code: IGNORE"); //$NON-NLS-1$
487                         }
488                 }
489                 if ((errorThreshold & ImportProblem) != 0){
490                         buf.append("\n-import problem: ERROR"); //$NON-NLS-1$
491                 } else {
492                         if ((warningThreshold & ImportProblem) != 0){
493                                 buf.append("\n-import problem: WARNING"); //$NON-NLS-1$
494                         } else {
495                                 buf.append("\n-import problem: IGNORE"); //$NON-NLS-1$
496                         }
497                 }
498                 if ((errorThreshold & MethodWithConstructorName) != 0){
499                         buf.append("\n-method with constructor name: ERROR");            //$NON-NLS-1$
500                 } else {
501                         if ((warningThreshold & MethodWithConstructorName) != 0){
502                                 buf.append("\n-method with constructor name: WARNING"); //$NON-NLS-1$
503                         } else {
504                                 buf.append("\n-method with constructor name: IGNORE"); //$NON-NLS-1$
505                         }
506                 }
507                 if ((errorThreshold & OverriddenPackageDefaultMethod) != 0){
508                         buf.append("\n-overridden package default method: ERROR"); //$NON-NLS-1$
509                 } else {
510                         if ((warningThreshold & OverriddenPackageDefaultMethod) != 0){
511                                 buf.append("\n-overridden package default method: WARNING"); //$NON-NLS-1$
512                         } else {
513                                 buf.append("\n-overridden package default method: IGNORE"); //$NON-NLS-1$
514                         }
515                 }
516                 if ((errorThreshold & UsingDeprecatedAPI) != 0){
517                         buf.append("\n-deprecation: ERROR"); //$NON-NLS-1$
518                 } else {
519                         if ((warningThreshold & UsingDeprecatedAPI) != 0){
520                                 buf.append("\n-deprecation: WARNING"); //$NON-NLS-1$
521                         } else {
522                                 buf.append("\n-deprecation: IGNORE"); //$NON-NLS-1$
523                         }
524                 }
525                 if ((errorThreshold & MaskedCatchBlock) != 0){
526                         buf.append("\n-masked catch block: ERROR"); //$NON-NLS-1$
527                 } else {
528                         if ((warningThreshold & MaskedCatchBlock) != 0){
529                                 buf.append("\n-masked catch block: WARNING"); //$NON-NLS-1$
530                         } else {
531                                 buf.append("\n-masked catch block: IGNORE"); //$NON-NLS-1$
532                         }
533                 }
534                 if ((errorThreshold & UnusedLocalVariable) != 0){
535                         buf.append("\n-unused local variable: ERROR"); //$NON-NLS-1$
536                 } else {
537                         if ((warningThreshold & UnusedLocalVariable) != 0){
538                                 buf.append("\n-unused local variable: WARNING"); //$NON-NLS-1$
539                         } else {
540                                 buf.append("\n-unused local variable: IGNORE"); //$NON-NLS-1$
541                         }
542                 }
543                 if ((errorThreshold & UnusedArgument) != 0){
544                         buf.append("\n-unused parameter: ERROR"); //$NON-NLS-1$
545                 } else {
546                         if ((warningThreshold & UnusedArgument) != 0){
547                                 buf.append("\n-unused parameter: WARNING"); //$NON-NLS-1$
548                         } else {
549                                 buf.append("\n-unused parameter: IGNORE"); //$NON-NLS-1$
550                         }
551                 }
552                 if ((errorThreshold & UnusedImport) != 0){
553                         buf.append("\n-unused import: ERROR"); //$NON-NLS-1$
554                 } else {
555                         if ((warningThreshold & UnusedImport) != 0){
556                                 buf.append("\n-unused import: WARNING"); //$NON-NLS-1$
557                         } else {
558                                 buf.append("\n-unused import: IGNORE"); //$NON-NLS-1$
559                         }
560                 }
561                 if ((errorThreshold & AccessEmulation) != 0){
562                         buf.append("\n-synthetic access emulation: ERROR"); //$NON-NLS-1$
563                 } else {
564                         if ((warningThreshold & AccessEmulation) != 0){
565                                 buf.append("\n-synthetic access emulation: WARNING"); //$NON-NLS-1$
566                         } else {
567                                 buf.append("\n-synthetic access emulation: IGNORE"); //$NON-NLS-1$
568                         }
569                 }
570                 if ((errorThreshold & NonExternalizedString) != 0){
571                         buf.append("\n-non externalized string: ERROR"); //$NON-NLS-1$
572                 } else {
573                         if ((warningThreshold & NonExternalizedString) != 0){
574                                 buf.append("\n-non externalized string: WARNING"); //$NON-NLS-1$
575                         } else {
576                                 buf.append("\n-non externalized string: IGNORE"); //$NON-NLS-1$
577                         }
578                 }
579                 switch(targetJDK){
580                         case JDK1_1 :
581                                 buf.append("\n-target JDK: 1.1"); //$NON-NLS-1$
582                                 break;
583                         case JDK1_2 :
584                                 buf.append("\n-target JDK: 1.2"); //$NON-NLS-1$
585                                 break;
586                         case JDK1_3 :
587                                 buf.append("\n-target JDK: 1.3"); //$NON-NLS-1$
588                                 break;
589                         case JDK1_4 :
590                                 buf.append("\n-target JDK: 1.4"); //$NON-NLS-1$
591                                 break;
592                 }
593                 switch(complianceLevel){
594                         case JDK1_1 :
595                                 buf.append("\n-compliance JDK: 1.1"); //$NON-NLS-1$
596                                 break;
597                         case JDK1_2 :
598                                 buf.append("\n-compliance JDK: 1.2"); //$NON-NLS-1$
599                                 break;
600                         case JDK1_3 :
601                                 buf.append("\n-compliance JDK: 1.3"); //$NON-NLS-1$
602                                 break;
603                         case JDK1_4 :
604                                 buf.append("\n-compliance JDK: 1.4"); //$NON-NLS-1$
605                                 break;
606                 }
607                 if (isPrivateConstructorAccessChangingVisibility){
608                         buf.append("\n-private constructor access emulation: extra argument"); //$NON-NLS-1$
609                 } else {
610                         buf.append("\n-private constructor access emulation: make default access"); //$NON-NLS-1$
611                 }
612                 buf.append("\n-verbose : " + (verbose ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
613                 buf.append("\n-produce reference info : " + (produceReferenceInfo ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
614                 buf.append("\n-parse literal expressions as constants : " + (parseLiteralExpressionsAsConstants ? "ON" : "OFF")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
615                 buf.append("\n-runtime exception name for compile error : " + runtimeExceptionNameForCompileError); //$NON-NLS-1$
616                 buf.append("\n-encoding : " + (defaultEncoding == null ? "<default>" : defaultEncoding)); //$NON-NLS-1$ //$NON-NLS-2$
617                 return buf.toString();
618         }
619 }