|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| package org.w3c.tidy; |
|
55 |
| |
|
56 |
| import java.io.FileInputStream; |
|
57 |
| import java.io.IOException; |
|
58 |
| import java.io.Serializable; |
|
59 |
| import java.io.Writer; |
|
60 |
| import java.lang.reflect.Field; |
|
61 |
| import java.util.ArrayList; |
|
62 |
| import java.util.Collections; |
|
63 |
| import java.util.Enumeration; |
|
64 |
| import java.util.HashMap; |
|
65 |
| import java.util.Iterator; |
|
66 |
| import java.util.List; |
|
67 |
| import java.util.Map; |
|
68 |
| import java.util.Properties; |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
| |
|
77 |
| |
|
78 |
| |
|
79 |
| public class Configuration implements Serializable |
|
80 |
| { |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| public static final int RAW = 0; |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| public static final int ASCII = 1; |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| public static final int LATIN1 = 2; |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| public static final int UTF8 = 3; |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| public static final int ISO2022 = 4; |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| public static final int MACROMAN = 5; |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| public static final int UTF16LE = 6; |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| public static final int UTF16BE = 7; |
|
129 |
| |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
| public static final int UTF16 = 8; |
|
135 |
| |
|
136 |
| |
|
137 |
| |
|
138 |
| |
|
139 |
| |
|
140 |
| public static final int WIN1252 = 9; |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
| |
|
145 |
| |
|
146 |
| public static final int BIG5 = 10; |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| public static final int SHIFTJIS = 11; |
|
153 |
| |
|
154 |
| |
|
155 |
| |
|
156 |
| |
|
157 |
| private final String[] ENCODING_NAMES = new String[]{"raw", |
|
158 |
| "ASCII", |
|
159 |
| "ISO8859_1", |
|
160 |
| "UTF8", |
|
161 |
| "JIS", |
|
162 |
| "MacRoman", |
|
163 |
| "UnicodeLittle", |
|
164 |
| "UnicodeBig", |
|
165 |
| "Unicode", |
|
166 |
| "Cp1252", |
|
167 |
| "Big5", |
|
168 |
| "SJIS"}; |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| public static final int DOCTYPE_OMIT = 0; |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
| public static final int DOCTYPE_AUTO = 1; |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| public static final int DOCTYPE_STRICT = 2; |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
| public static final int DOCTYPE_LOOSE = 3; |
|
190 |
| |
|
191 |
| |
|
192 |
| |
|
193 |
| |
|
194 |
| public static final int DOCTYPE_USER = 4; |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
| |
|
199 |
| |
|
200 |
| public static final int KEEP_LAST = 0; |
|
201 |
| |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| public static final int KEEP_FIRST = 1; |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
| |
|
210 |
| |
|
211 |
| private static final Map OPTIONS = new HashMap(); |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
| |
|
216 |
| private static final long serialVersionUID = -4955155037138560842L; |
|
217 |
| |
|
218 |
| static |
|
219 |
| { |
|
220 |
1
| addConfigOption(new Flag("indent-spaces", "spaces", ParsePropertyImpl.INT));
|
|
221 |
1
| addConfigOption(new Flag("wrap", "wraplen", ParsePropertyImpl.INT));
|
|
222 |
1
| addConfigOption(new Flag("show-errors", "showErrors", ParsePropertyImpl.INT));
|
|
223 |
1
| addConfigOption(new Flag("tab-size", "tabsize", ParsePropertyImpl.INT));
|
|
224 |
| |
|
225 |
1
| addConfigOption(new Flag("wrap-attributes", "wrapAttVals", ParsePropertyImpl.BOOL));
|
|
226 |
1
| addConfigOption(new Flag("wrap-script-literals", "wrapScriptlets", ParsePropertyImpl.BOOL));
|
|
227 |
1
| addConfigOption(new Flag("wrap-sections", "wrapSection", ParsePropertyImpl.BOOL));
|
|
228 |
1
| addConfigOption(new Flag("wrap-asp", "wrapAsp", ParsePropertyImpl.BOOL));
|
|
229 |
1
| addConfigOption(new Flag("wrap-jste", "wrapJste", ParsePropertyImpl.BOOL));
|
|
230 |
1
| addConfigOption(new Flag("wrap-php", "wrapPhp", ParsePropertyImpl.BOOL));
|
|
231 |
1
| addConfigOption(new Flag("literal-attributes", "literalAttribs", ParsePropertyImpl.BOOL));
|
|
232 |
1
| addConfigOption(new Flag("show-body-only", "bodyOnly", ParsePropertyImpl.BOOL));
|
|
233 |
1
| addConfigOption(new Flag("fix-uri", "fixUri", ParsePropertyImpl.BOOL));
|
|
234 |
1
| addConfigOption(new Flag("lower-literals", "lowerLiterals", ParsePropertyImpl.BOOL));
|
|
235 |
1
| addConfigOption(new Flag("hide-comments", "hideComments", ParsePropertyImpl.BOOL));
|
|
236 |
1
| addConfigOption(new Flag("indent-cdata", "indentCdata", ParsePropertyImpl.BOOL));
|
|
237 |
1
| addConfigOption(new Flag("force-output", "forceOutput", ParsePropertyImpl.BOOL));
|
|
238 |
1
| addConfigOption(new Flag("ascii-chars", "asciiChars", ParsePropertyImpl.BOOL));
|
|
239 |
1
| addConfigOption(new Flag("join-classes", "joinClasses", ParsePropertyImpl.BOOL));
|
|
240 |
1
| addConfigOption(new Flag("join-styles", "joinStyles", ParsePropertyImpl.BOOL));
|
|
241 |
1
| addConfigOption(new Flag("escape-cdata", "escapeCdata", ParsePropertyImpl.BOOL));
|
|
242 |
1
| addConfigOption(new Flag("replace-color", "replaceColor", ParsePropertyImpl.BOOL));
|
|
243 |
1
| addConfigOption(new Flag("quiet", "quiet", ParsePropertyImpl.BOOL));
|
|
244 |
1
| addConfigOption(new Flag("tidy-mark", "tidyMark", ParsePropertyImpl.BOOL));
|
|
245 |
1
| addConfigOption(new Flag("indent-attributes", "indentAttributes", ParsePropertyImpl.BOOL));
|
|
246 |
1
| addConfigOption(new Flag("hide-endtags", "hideEndTags", ParsePropertyImpl.BOOL));
|
|
247 |
1
| addConfigOption(new Flag("input-xml", "xmlTags", ParsePropertyImpl.BOOL));
|
|
248 |
1
| addConfigOption(new Flag("output-xml", "xmlOut", ParsePropertyImpl.BOOL));
|
|
249 |
1
| addConfigOption(new Flag("output-html", "htmlOut", ParsePropertyImpl.BOOL));
|
|
250 |
1
| addConfigOption(new Flag("output-xhtml", "xHTML", ParsePropertyImpl.BOOL));
|
|
251 |
1
| addConfigOption(new Flag("add-xml-pi", "xmlPi", ParsePropertyImpl.BOOL));
|
|
252 |
1
| addConfigOption(new Flag("add-xml-decl", "xmlPi", ParsePropertyImpl.BOOL));
|
|
253 |
1
| addConfigOption(new Flag("assume-xml-procins", "xmlPIs", ParsePropertyImpl.BOOL));
|
|
254 |
1
| addConfigOption(new Flag("uppercase-tags", "upperCaseTags", ParsePropertyImpl.BOOL));
|
|
255 |
1
| addConfigOption(new Flag("uppercase-attributes", "upperCaseAttrs", ParsePropertyImpl.BOOL));
|
|
256 |
1
| addConfigOption(new Flag("bare", "makeBare", ParsePropertyImpl.BOOL));
|
|
257 |
1
| addConfigOption(new Flag("clean", "makeClean", ParsePropertyImpl.BOOL));
|
|
258 |
1
| addConfigOption(new Flag("logical-emphasis", "logicalEmphasis", ParsePropertyImpl.BOOL));
|
|
259 |
1
| addConfigOption(new Flag("word-2000", "word2000", ParsePropertyImpl.BOOL));
|
|
260 |
1
| addConfigOption(new Flag("drop-empty-paras", "dropEmptyParas", ParsePropertyImpl.BOOL));
|
|
261 |
1
| addConfigOption(new Flag("drop-font-tags", "dropFontTags", ParsePropertyImpl.BOOL));
|
|
262 |
1
| addConfigOption(new Flag("drop-proprietary-attributes", "dropProprietaryAttributes", ParsePropertyImpl.BOOL));
|
|
263 |
1
| addConfigOption(new Flag("enclose-text", "encloseBodyText", ParsePropertyImpl.BOOL));
|
|
264 |
1
| addConfigOption(new Flag("enclose-block-text", "encloseBlockText", ParsePropertyImpl.BOOL));
|
|
265 |
1
| addConfigOption(new Flag("add-xml-space", "xmlSpace", ParsePropertyImpl.BOOL));
|
|
266 |
1
| addConfigOption(new Flag("fix-bad-comments", "fixComments", ParsePropertyImpl.BOOL));
|
|
267 |
1
| addConfigOption(new Flag("split", "burstSlides", ParsePropertyImpl.BOOL));
|
|
268 |
1
| addConfigOption(new Flag("break-before-br", "breakBeforeBR", ParsePropertyImpl.BOOL));
|
|
269 |
1
| addConfigOption(new Flag("numeric-entities", "numEntities", ParsePropertyImpl.BOOL));
|
|
270 |
1
| addConfigOption(new Flag("quote-marks", "quoteMarks", ParsePropertyImpl.BOOL));
|
|
271 |
1
| addConfigOption(new Flag("quote-nbsp", "quoteNbsp", ParsePropertyImpl.BOOL));
|
|
272 |
1
| addConfigOption(new Flag("quote-ampersand", "quoteAmpersand", ParsePropertyImpl.BOOL));
|
|
273 |
1
| addConfigOption(new Flag("write-back", "writeback", ParsePropertyImpl.BOOL));
|
|
274 |
1
| addConfigOption(new Flag("keep-time", "keepFileTimes", ParsePropertyImpl.BOOL));
|
|
275 |
1
| addConfigOption(new Flag("show-warnings", "showWarnings", ParsePropertyImpl.BOOL));
|
|
276 |
1
| addConfigOption(new Flag("ncr", "ncr", ParsePropertyImpl.BOOL));
|
|
277 |
1
| addConfigOption(new Flag("fix-backslash", "fixBackslash", ParsePropertyImpl.BOOL));
|
|
278 |
1
| addConfigOption(new Flag("gnu-emacs", "emacs", ParsePropertyImpl.BOOL));
|
|
279 |
1
| addConfigOption(new Flag("only-errors", "onlyErrors", ParsePropertyImpl.BOOL));
|
|
280 |
1
| addConfigOption(new Flag("output-raw", "rawOut", ParsePropertyImpl.BOOL));
|
|
281 |
1
| addConfigOption(new Flag("trim-empty-elements", "trimEmpty", ParsePropertyImpl.BOOL));
|
|
282 |
| |
|
283 |
1
| addConfigOption(new Flag("markup", "onlyErrors", ParsePropertyImpl.INVBOOL));
|
|
284 |
| |
|
285 |
1
| addConfigOption(new Flag("char-encoding", null, ParsePropertyImpl.CHAR_ENCODING));
|
|
286 |
1
| addConfigOption(new Flag("input-encoding", null, ParsePropertyImpl.CHAR_ENCODING));
|
|
287 |
1
| addConfigOption(new Flag("output-encoding", null, ParsePropertyImpl.CHAR_ENCODING));
|
|
288 |
| |
|
289 |
1
| addConfigOption(new Flag("error-file", "errfile", ParsePropertyImpl.NAME));
|
|
290 |
1
| addConfigOption(new Flag("slide-style", "slidestyle", ParsePropertyImpl.NAME));
|
|
291 |
1
| addConfigOption(new Flag("language", "language", ParsePropertyImpl.NAME));
|
|
292 |
| |
|
293 |
1
| addConfigOption(new Flag("new-inline-tags", null, ParsePropertyImpl.TAGNAMES));
|
|
294 |
1
| addConfigOption(new Flag("new-blocklevel-tags", null, ParsePropertyImpl.TAGNAMES));
|
|
295 |
1
| addConfigOption(new Flag("new-empty-tags", null, ParsePropertyImpl.TAGNAMES));
|
|
296 |
1
| addConfigOption(new Flag("new-pre-tags", null, ParsePropertyImpl.TAGNAMES));
|
|
297 |
| |
|
298 |
1
| addConfigOption(new Flag("doctype", "docTypeStr", ParsePropertyImpl.DOCTYPE));
|
|
299 |
| |
|
300 |
1
| addConfigOption(new Flag("repeated-attributes", "duplicateAttrs", ParsePropertyImpl.REPEATED_ATTRIBUTES));
|
|
301 |
| |
|
302 |
1
| addConfigOption(new Flag("alt-text", "altText", ParsePropertyImpl.STRING));
|
|
303 |
| |
|
304 |
1
| addConfigOption(new Flag("indent", "indentContent", ParsePropertyImpl.INDENT));
|
|
305 |
| |
|
306 |
1
| addConfigOption(new Flag("css-prefix", "cssPrefix", ParsePropertyImpl.CSS1SELECTOR));
|
|
307 |
| |
|
308 |
1
| addConfigOption(new Flag("newline", null, ParsePropertyImpl.NEWLINE));
|
|
309 |
| } |
|
310 |
| |
|
311 |
| |
|
312 |
| |
|
313 |
| |
|
314 |
| protected int spaces = 2; |
|
315 |
| |
|
316 |
| |
|
317 |
| |
|
318 |
| |
|
319 |
| protected int wraplen = 68; |
|
320 |
| |
|
321 |
| |
|
322 |
| |
|
323 |
| |
|
324 |
| protected int tabsize = 8; |
|
325 |
| |
|
326 |
| |
|
327 |
| |
|
328 |
| |
|
329 |
| protected int docTypeMode = DOCTYPE_AUTO; |
|
330 |
| |
|
331 |
| |
|
332 |
| |
|
333 |
| |
|
334 |
| protected int duplicateAttrs = KEEP_LAST; |
|
335 |
| |
|
336 |
| |
|
337 |
| |
|
338 |
| |
|
339 |
| protected String altText; |
|
340 |
| |
|
341 |
| |
|
342 |
| |
|
343 |
| |
|
344 |
| |
|
345 |
| protected String slidestyle; |
|
346 |
| |
|
347 |
| |
|
348 |
| |
|
349 |
| |
|
350 |
| protected String language; |
|
351 |
| |
|
352 |
| |
|
353 |
| |
|
354 |
| |
|
355 |
| protected String docTypeStr; |
|
356 |
| |
|
357 |
| |
|
358 |
| |
|
359 |
| |
|
360 |
| protected String errfile; |
|
361 |
| |
|
362 |
| |
|
363 |
| |
|
364 |
| |
|
365 |
| protected boolean writeback; |
|
366 |
| |
|
367 |
| |
|
368 |
| |
|
369 |
| |
|
370 |
| protected boolean onlyErrors; |
|
371 |
| |
|
372 |
| |
|
373 |
| |
|
374 |
| |
|
375 |
| protected boolean showWarnings = true; |
|
376 |
| |
|
377 |
| |
|
378 |
| |
|
379 |
| |
|
380 |
| protected boolean quiet; |
|
381 |
| |
|
382 |
| |
|
383 |
| |
|
384 |
| |
|
385 |
| protected boolean indentContent; |
|
386 |
| |
|
387 |
| |
|
388 |
| |
|
389 |
| |
|
390 |
| protected boolean smartIndent; |
|
391 |
| |
|
392 |
| |
|
393 |
| |
|
394 |
| |
|
395 |
| protected boolean hideEndTags; |
|
396 |
| |
|
397 |
| |
|
398 |
| |
|
399 |
| |
|
400 |
| protected boolean xmlTags; |
|
401 |
| |
|
402 |
| |
|
403 |
| |
|
404 |
| |
|
405 |
| protected boolean xmlOut; |
|
406 |
| |
|
407 |
| |
|
408 |
| |
|
409 |
| |
|
410 |
| protected boolean xHTML; |
|
411 |
| |
|
412 |
| |
|
413 |
| |
|
414 |
| |
|
415 |
| protected boolean htmlOut; |
|
416 |
| |
|
417 |
| |
|
418 |
| |
|
419 |
| |
|
420 |
| protected boolean xmlPi; |
|
421 |
| |
|
422 |
| |
|
423 |
| |
|
424 |
| |
|
425 |
| protected boolean upperCaseTags; |
|
426 |
| |
|
427 |
| |
|
428 |
| |
|
429 |
| |
|
430 |
| protected boolean upperCaseAttrs; |
|
431 |
| |
|
432 |
| |
|
433 |
| |
|
434 |
| |
|
435 |
| protected boolean makeClean; |
|
436 |
| |
|
437 |
| |
|
438 |
| |
|
439 |
| |
|
440 |
| protected boolean makeBare; |
|
441 |
| |
|
442 |
| |
|
443 |
| |
|
444 |
| |
|
445 |
| protected boolean logicalEmphasis; |
|
446 |
| |
|
447 |
| |
|
448 |
| |
|
449 |
| |
|
450 |
| protected boolean dropFontTags; |
|
451 |
| |
|
452 |
| |
|
453 |
| |
|
454 |
| |
|
455 |
| protected boolean dropProprietaryAttributes; |
|
456 |
| |
|
457 |
| |
|
458 |
| |
|
459 |
| |
|
460 |
| protected boolean dropEmptyParas = true; |
|
461 |
| |
|
462 |
| |
|
463 |
| |
|
464 |
| |
|
465 |
| protected boolean fixComments = true; |
|
466 |
| |
|
467 |
| |
|
468 |
| |
|
469 |
| |
|
470 |
| protected boolean trimEmpty = true; |
|
471 |
| |
|
472 |
| |
|
473 |
| |
|
474 |
| |
|
475 |
| protected boolean breakBeforeBR; |
|
476 |
| |
|
477 |
| |
|
478 |
| |
|
479 |
| |
|
480 |
| protected boolean burstSlides; |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
| protected boolean numEntities; |
|
486 |
| |
|
487 |
| |
|
488 |
| |
|
489 |
| |
|
490 |
| protected boolean quoteMarks; |
|
491 |
| |
|
492 |
| |
|
493 |
| |
|
494 |
| |
|
495 |
| protected boolean quoteNbsp = true; |
|
496 |
| |
|
497 |
| |
|
498 |
| |
|
499 |
| |
|
500 |
| protected boolean quoteAmpersand = true; |
|
501 |
| |
|
502 |
| |
|
503 |
| |
|
504 |
| |
|
505 |
| protected boolean wrapAttVals; |
|
506 |
| |
|
507 |
| |
|
508 |
| |
|
509 |
| |
|
510 |
| protected boolean wrapScriptlets; |
|
511 |
| |
|
512 |
| |
|
513 |
| |
|
514 |
| |
|
515 |
| protected boolean wrapSection = true; |
|
516 |
| |
|
517 |
| |
|
518 |
| |
|
519 |
| |
|
520 |
| protected boolean wrapAsp = true; |
|
521 |
| |
|
522 |
| |
|
523 |
| |
|
524 |
| |
|
525 |
| protected boolean wrapJste = true; |
|
526 |
| |
|
527 |
| |
|
528 |
| |
|
529 |
| |
|
530 |
| protected boolean wrapPhp = true; |
|
531 |
| |
|
532 |
| |
|
533 |
| |
|
534 |
| |
|
535 |
| protected boolean fixBackslash = true; |
|
536 |
| |
|
537 |
| |
|
538 |
| |
|
539 |
| |
|
540 |
| protected boolean indentAttributes; |
|
541 |
| |
|
542 |
| |
|
543 |
| |
|
544 |
| |
|
545 |
| protected boolean xmlPIs; |
|
546 |
| |
|
547 |
| |
|
548 |
| |
|
549 |
| |
|
550 |
| protected boolean xmlSpace; |
|
551 |
| |
|
552 |
| |
|
553 |
| |
|
554 |
| |
|
555 |
| protected boolean encloseBodyText; |
|
556 |
| |
|
557 |
| |
|
558 |
| |
|
559 |
| |
|
560 |
| protected boolean encloseBlockText; |
|
561 |
| |
|
562 |
| |
|
563 |
| |
|
564 |
| |
|
565 |
| protected boolean keepFileTimes = true; |
|
566 |
| |
|
567 |
| |
|
568 |
| |
|
569 |
| |
|
570 |
| protected boolean word2000; |
|
571 |
| |
|
572 |
| |
|
573 |
| |
|
574 |
| |
|
575 |
| protected boolean tidyMark = true; |
|
576 |
| |
|
577 |
| |
|
578 |
| |
|
579 |
| |
|
580 |
| protected boolean emacs; |
|
581 |
| |
|
582 |
| |
|
583 |
| |
|
584 |
| |
|
585 |
| protected boolean literalAttribs; |
|
586 |
| |
|
587 |
| |
|
588 |
| |
|
589 |
| |
|
590 |
| protected boolean bodyOnly; |
|
591 |
| |
|
592 |
| |
|
593 |
| |
|
594 |
| |
|
595 |
| protected boolean fixUri = true; |
|
596 |
| |
|
597 |
| |
|
598 |
| |
|
599 |
| |
|
600 |
| protected boolean lowerLiterals = true; |
|
601 |
| |
|
602 |
| |
|
603 |
| |
|
604 |
| |
|
605 |
| protected boolean replaceColor; |
|
606 |
| |
|
607 |
| |
|
608 |
| |
|
609 |
| |
|
610 |
| protected boolean hideComments; |
|
611 |
| |
|
612 |
| |
|
613 |
| |
|
614 |
| |
|
615 |
| protected boolean indentCdata; |
|
616 |
| |
|
617 |
| |
|
618 |
| |
|
619 |
| |
|
620 |
| protected boolean forceOutput; |
|
621 |
| |
|
622 |
| |
|
623 |
| |
|
624 |
| |
|
625 |
| protected int showErrors = 6; |
|
626 |
| |
|
627 |
| |
|
628 |
| |
|
629 |
| |
|
630 |
| protected boolean asciiChars = true; |
|
631 |
| |
|
632 |
| |
|
633 |
| |
|
634 |
| |
|
635 |
| protected boolean joinClasses; |
|
636 |
| |
|
637 |
| |
|
638 |
| |
|
639 |
| |
|
640 |
| protected boolean joinStyles = true; |
|
641 |
| |
|
642 |
| |
|
643 |
| |
|
644 |
| |
|
645 |
| protected boolean escapeCdata = true; |
|
646 |
| |
|
647 |
| |
|
648 |
| |
|
649 |
| |
|
650 |
| protected boolean ncr = true; |
|
651 |
| |
|
652 |
| |
|
653 |
| |
|
654 |
| |
|
655 |
| protected String cssPrefix; |
|
656 |
| |
|
657 |
| |
|
658 |
| |
|
659 |
| |
|
660 |
| protected String replacementCharEncoding = "WIN1252"; |
|
661 |
| |
|
662 |
| |
|
663 |
| |
|
664 |
| |
|
665 |
| protected TagTable tt; |
|
666 |
| |
|
667 |
| |
|
668 |
| |
|
669 |
| |
|
670 |
| protected Report report; |
|
671 |
| |
|
672 |
| |
|
673 |
| |
|
674 |
| |
|
675 |
| protected int definedTags; |
|
676 |
| |
|
677 |
| |
|
678 |
| |
|
679 |
| |
|
680 |
| protected char[] newline = (System.getProperty("line.separator")).toCharArray(); |
|
681 |
| |
|
682 |
| |
|
683 |
| |
|
684 |
| |
|
685 |
| private String inCharEncoding = "ISO8859_1"; |
|
686 |
| |
|
687 |
| |
|
688 |
| |
|
689 |
| |
|
690 |
| private String outCharEncoding = "ASCII"; |
|
691 |
| |
|
692 |
| |
|
693 |
| |
|
694 |
| |
|
695 |
| protected boolean rawOut; |
|
696 |
| |
|
697 |
| |
|
698 |
| |
|
699 |
| |
|
700 |
| private transient Properties properties = new Properties(); |
|
701 |
| |
|
702 |
| |
|
703 |
| |
|
704 |
| |
|
705 |
| |
|
706 |
299
| protected Configuration(Report report)
|
|
707 |
| { |
|
708 |
299
| this.report = report;
|
|
709 |
| } |
|
710 |
| |
|
711 |
| |
|
712 |
| |
|
713 |
| |
|
714 |
| |
|
715 |
78
| private static void addConfigOption(Flag flag)
|
|
716 |
| { |
|
717 |
78
| OPTIONS.put(flag.getName(), flag);
|
|
718 |
| } |
|
719 |
| |
|
720 |
| |
|
721 |
| |
|
722 |
| |
|
723 |
| |
|
724 |
233
| public void addProps(Properties p)
|
|
725 |
| { |
|
726 |
233
| Enumeration propEnum = p.propertyNames();
|
|
727 |
233
| while (propEnum.hasMoreElements())
|
|
728 |
| { |
|
729 |
622
| String key = (String) propEnum.nextElement();
|
|
730 |
622
| String value = p.getProperty(key);
|
|
731 |
622
| properties.put(key, value);
|
|
732 |
| } |
|
733 |
233
| parseProps();
|
|
734 |
| } |
|
735 |
| |
|
736 |
| |
|
737 |
| |
|
738 |
| |
|
739 |
| |
|
740 |
0
| public void parseFile(String filename)
|
|
741 |
| { |
|
742 |
0
| try
|
|
743 |
| { |
|
744 |
0
| properties.load(new FileInputStream(filename));
|
|
745 |
| } |
|
746 |
| catch (IOException e) |
|
747 |
| { |
|
748 |
0
| System.err.println(filename + " " + e.toString());
|
|
749 |
0
| return;
|
|
750 |
| } |
|
751 |
0
| parseProps();
|
|
752 |
| } |
|
753 |
| |
|
754 |
| |
|
755 |
| |
|
756 |
| |
|
757 |
| |
|
758 |
| |
|
759 |
1
| public static boolean isKnownOption(String name)
|
|
760 |
| { |
|
761 |
1
| return name != null && OPTIONS.containsKey(name);
|
|
762 |
| } |
|
763 |
| |
|
764 |
| |
|
765 |
| |
|
766 |
| |
|
767 |
233
| private void parseProps()
|
|
768 |
| { |
|
769 |
233
| Iterator iterator = properties.keySet().iterator();
|
|
770 |
| |
|
771 |
233
| while (iterator.hasNext())
|
|
772 |
| { |
|
773 |
622
| String key = (String) iterator.next();
|
|
774 |
622
| Flag flag = (Flag) OPTIONS.get(key);
|
|
775 |
622
| if (flag == null)
|
|
776 |
| { |
|
777 |
0
| report.unknownOption(key);
|
|
778 |
0
| continue;
|
|
779 |
| } |
|
780 |
| |
|
781 |
622
| String stringValue = properties.getProperty(key);
|
|
782 |
622
| Object value = flag.getParser().parse(stringValue, key, this);
|
|
783 |
622
| if (flag.getLocation() != null)
|
|
784 |
| { |
|
785 |
594
| try
|
|
786 |
| { |
|
787 |
594
| flag.getLocation().set(this, value);
|
|
788 |
| } |
|
789 |
| catch (IllegalArgumentException e) |
|
790 |
| { |
|
791 |
0
| throw new RuntimeException("IllegalArgumentException during config initialization for field "
|
|
792 |
| + key |
|
793 |
| + "with value [" |
|
794 |
| + value |
|
795 |
| + "]: " |
|
796 |
| + e.getMessage()); |
|
797 |
| } |
|
798 |
| catch (IllegalAccessException e) |
|
799 |
| { |
|
800 |
0
| throw new RuntimeException("IllegalArgumentException during config initialization for field "
|
|
801 |
| + key |
|
802 |
| + "with value [" |
|
803 |
| + value |
|
804 |
| + "]: " |
|
805 |
| + e.getMessage()); |
|
806 |
| } |
|
807 |
| } |
|
808 |
| } |
|
809 |
| } |
|
810 |
| |
|
811 |
| |
|
812 |
| |
|
813 |
| |
|
814 |
239
| public void adjust()
|
|
815 |
| { |
|
816 |
239
| if (encloseBlockText)
|
|
817 |
| { |
|
818 |
2
| encloseBodyText = true;
|
|
819 |
| } |
|
820 |
| |
|
821 |
| |
|
822 |
239
| if (smartIndent)
|
|
823 |
| { |
|
824 |
12
| indentContent = true;
|
|
825 |
| } |
|
826 |
| |
|
827 |
| |
|
828 |
239
| if (wraplen == 0)
|
|
829 |
| { |
|
830 |
165
| wraplen = 0x7FFFFFFF;
|
|
831 |
| } |
|
832 |
| |
|
833 |
| |
|
834 |
239
| if (word2000)
|
|
835 |
| { |
|
836 |
9
| definedTags |= Dict.TAGTYPE_INLINE;
|
|
837 |
9
| tt.defineTag(Dict.TAGTYPE_INLINE, "o:p");
|
|
838 |
| } |
|
839 |
| |
|
840 |
| |
|
841 |
239
| if (xmlTags)
|
|
842 |
| { |
|
843 |
17
| xHTML = false;
|
|
844 |
| } |
|
845 |
| |
|
846 |
| |
|
847 |
239
| if (xHTML)
|
|
848 |
| { |
|
849 |
33
| xmlOut = true;
|
|
850 |
33
| upperCaseTags = false;
|
|
851 |
33
| upperCaseAttrs = false;
|
|
852 |
| } |
|
853 |
| |
|
854 |
| |
|
855 |
239
| if (xmlTags)
|
|
856 |
| { |
|
857 |
17
| xmlOut = true;
|
|
858 |
17
| xmlPIs = true;
|
|
859 |
| } |
|
860 |
| |
|
861 |
| |
|
862 |
| |
|
863 |
239
| if (!"UTF8".equals(getOutCharEncodingName()) && !"ASCII".equals(getOutCharEncodingName()) && xmlOut)
|
|
864 |
| { |
|
865 |
9
| xmlPi = true;
|
|
866 |
| } |
|
867 |
| |
|
868 |
| |
|
869 |
239
| if (xmlOut)
|
|
870 |
| { |
|
871 |
54
| quoteAmpersand = true;
|
|
872 |
54
| hideEndTags = false;
|
|
873 |
| } |
|
874 |
| } |
|
875 |
| |
|
876 |
| |
|
877 |
| |
|
878 |
| |
|
879 |
| |
|
880 |
| |
|
881 |
2
| void printConfigOptions(Writer errout, boolean showActualConfiguration)
|
|
882 |
| { |
|
883 |
2
| String pad = " ";
|
|
884 |
2
| try
|
|
885 |
| { |
|
886 |
2
| errout.write("\nConfiguration File Settings:\n\n");
|
|
887 |
| |
|
888 |
2
| if (showActualConfiguration)
|
|
889 |
| { |
|
890 |
1
| errout.write("Name Type Current Value\n");
|
|
891 |
| } |
|
892 |
| else |
|
893 |
| { |
|
894 |
1
| errout.write("Name Type Allowable values\n");
|
|
895 |
| } |
|
896 |
| |
|
897 |
2
| errout.write("=========================== ========= ========================================\n");
|
|
898 |
| |
|
899 |
2
| Flag configItem;
|
|
900 |
| |
|
901 |
| |
|
902 |
2
| List values = new ArrayList(OPTIONS.values());
|
|
903 |
2
| Collections.sort(values);
|
|
904 |
| |
|
905 |
2
| Iterator iterator = values.iterator();
|
|
906 |
| |
|
907 |
2
| while (iterator.hasNext())
|
|
908 |
| { |
|
909 |
156
| configItem = (Flag) iterator.next();
|
|
910 |
| |
|
911 |
156
| errout.write(configItem.getName());
|
|
912 |
156
| errout.write(pad, 0, 28 - configItem.getName().length());
|
|
913 |
| |
|
914 |
156
| errout.write(configItem.getParser().getType());
|
|
915 |
156
| errout.write(pad, 0, 11 - configItem.getParser().getType().length());
|
|
916 |
| |
|
917 |
156
| if (showActualConfiguration)
|
|
918 |
| { |
|
919 |
78
| Field field = configItem.getLocation();
|
|
920 |
78
| Object actualValue = null;
|
|
921 |
| |
|
922 |
78
| if (field != null)
|
|
923 |
| { |
|
924 |
70
| try
|
|
925 |
| { |
|
926 |
70
| actualValue = field.get(this);
|
|
927 |
| } |
|
928 |
| catch (IllegalArgumentException e1) |
|
929 |
| { |
|
930 |
| |
|
931 |
0
| throw new RuntimeException("IllegalArgument when reading field " + field.getName());
|
|
932 |
| } |
|
933 |
| catch (IllegalAccessException e1) |
|
934 |
| { |
|
935 |
| |
|
936 |
0
| throw new RuntimeException("IllegalAccess when reading field " + field.getName());
|
|
937 |
| } |
|
938 |
| } |
|
939 |
| |
|
940 |
78
| errout.write(configItem.getParser().getFriendlyName(configItem.getName(), actualValue, this));
|
|
941 |
| } |
|
942 |
| else |
|
943 |
| { |
|
944 |
78
| errout.write(configItem.getParser().getOptionValues());
|
|
945 |
| } |
|
946 |
| |
|
947 |
156
| errout.write("\n");
|
|
948 |
| |
|
949 |
| } |
|
950 |
2
| errout.flush();
|
|
951 |
| } |
|
952 |
| catch (IOException e) |
|
953 |
| { |
|
954 |
0
| throw new RuntimeException(e.getMessage());
|
|
955 |
| } |
|
956 |
| |
|
957 |
| } |
|
958 |
| |
|
959 |
| |
|
960 |
| |
|
961 |
| |
|
962 |
| static class Flag implements Comparable |
|
963 |
| { |
|
964 |
| |
|
965 |
| |
|
966 |
| |
|
967 |
| |
|
968 |
| private String name; |
|
969 |
| |
|
970 |
| |
|
971 |
| |
|
972 |
| |
|
973 |
| private String fieldName; |
|
974 |
| |
|
975 |
| |
|
976 |
| |
|
977 |
| |
|
978 |
| private Field location; |
|
979 |
| |
|
980 |
| |
|
981 |
| |
|
982 |
| |
|
983 |
| private ParseProperty parser; |
|
984 |
| |
|
985 |
| |
|
986 |
| |
|
987 |
| |
|
988 |
| |
|
989 |
| |
|
990 |
| |
|
991 |
78
| Flag(String name, String fieldName, ParseProperty parser)
|
|
992 |
| { |
|
993 |
| |
|
994 |
78
| this.fieldName = fieldName;
|
|
995 |
78
| this.name = name;
|
|
996 |
78
| this.parser = parser;
|
|
997 |
| } |
|
998 |
| |
|
999 |
| |
|
1000 |
| |
|
1001 |
| |
|
1002 |
| |
|
1003 |
1294
| public Field getLocation()
|
|
1004 |
| { |
|
1005 |
| |
|
1006 |
1294
| if (fieldName != null && this.location == null)
|
|
1007 |
| { |
|
1008 |
70
| try
|
|
1009 |
| { |
|
1010 |
70
| this.location = Configuration.class.getDeclaredField(fieldName);
|
|
1011 |
| } |
|
1012 |
| catch (NoSuchFieldException e) |
|
1013 |
| { |
|
1014 |
0
| throw new RuntimeException("NoSuchField exception during config initialization for field "
|
|
1015 |
| + fieldName); |
|
1016 |
| } |
|
1017 |
| catch (SecurityException e) |
|
1018 |
| { |
|
1019 |
0
| throw new RuntimeException("Security exception during config initialization for field "
|
|
1020 |
| + fieldName |
|
1021 |
| + ": " |
|
1022 |
| + e.getMessage()); |
|
1023 |
| } |
|
1024 |
| } |
|
1025 |
| |
|
1026 |
1294
| return this.location;
|
|
1027 |
| } |
|
1028 |
| |
|
1029 |
| |
|
1030 |
| |
|
1031 |
| |
|
1032 |
| |
|
1033 |
468
| public String getName()
|
|
1034 |
| { |
|
1035 |
468
| return this.name;
|
|
1036 |
| } |
|
1037 |
| |
|
1038 |
| |
|
1039 |
| |
|
1040 |
| |
|
1041 |
| |
|
1042 |
1090
| public ParseProperty getParser()
|
|
1043 |
| { |
|
1044 |
1090
| return this.parser;
|
|
1045 |
| } |
|
1046 |
| |
|
1047 |
| |
|
1048 |
| |
|
1049 |
| |
|
1050 |
0
| public boolean equals(Object obj)
|
|
1051 |
| { |
|
1052 |
0
| return this.name.equals(((Flag) obj).name);
|
|
1053 |
| } |
|
1054 |
| |
|
1055 |
| |
|
1056 |
| |
|
1057 |
| |
|
1058 |
0
| public int hashCode()
|
|
1059 |
| { |
|
1060 |
| |
|
1061 |
0
| return this.name.hashCode();
|
|
1062 |
| } |
|
1063 |
| |
|
1064 |
| |
|
1065 |
| |
|
1066 |
| |
|
1067 |
830
| public int compareTo(Object o)
|
|
1068 |
| { |
|
1069 |
830
| return this.name.compareTo(((Flag) o).name);
|
|
1070 |
| } |
|
1071 |
| |
|
1072 |
| } |
|
1073 |
| |
|
1074 |
| |
|
1075 |
| |
|
1076 |
| |
|
1077 |
| |
|
1078 |
895
| protected String getInCharEncodingName()
|
|
1079 |
| { |
|
1080 |
895
| return this.inCharEncoding;
|
|
1081 |
| } |
|
1082 |
| |
|
1083 |
| |
|
1084 |
| |
|
1085 |
| |
|
1086 |
| |
|
1087 |
16
| protected void setInCharEncodingName(String encoding)
|
|
1088 |
| { |
|
1089 |
16
| String javaEncoding = EncodingNameMapper.toJava(encoding);
|
|
1090 |
16
| if (javaEncoding != null)
|
|
1091 |
| { |
|
1092 |
16
| this.inCharEncoding = javaEncoding;
|
|
1093 |
| } |
|
1094 |
| } |
|
1095 |
| |
|
1096 |
| |
|
1097 |
| |
|
1098 |
| |
|
1099 |
| |
|
1100 |
318479
| protected String getOutCharEncodingName()
|
|
1101 |
| { |
|
1102 |
318479
| return this.outCharEncoding;
|
|
1103 |
| } |
|
1104 |
| |
|
1105 |
| |
|
1106 |
| |
|
1107 |
| |
|
1108 |
| |
|
1109 |
16
| protected void setOutCharEncodingName(String encoding)
|
|
1110 |
| { |
|
1111 |
16
| String javaEncoding = EncodingNameMapper.toJava(encoding);
|
|
1112 |
16
| if (javaEncoding != null)
|
|
1113 |
| { |
|
1114 |
16
| this.outCharEncoding = javaEncoding;
|
|
1115 |
| } |
|
1116 |
| } |
|
1117 |
| |
|
1118 |
| |
|
1119 |
| |
|
1120 |
| |
|
1121 |
| |
|
1122 |
0
| protected void setInOutEncodingName(String encoding)
|
|
1123 |
| { |
|
1124 |
0
| setInCharEncodingName(encoding);
|
|
1125 |
0
| setOutCharEncodingName(encoding);
|
|
1126 |
| } |
|
1127 |
| |
|
1128 |
| |
|
1129 |
| |
|
1130 |
| |
|
1131 |
| |
|
1132 |
| |
|
1133 |
0
| protected void setOutCharEncoding(int encoding)
|
|
1134 |
| { |
|
1135 |
0
| setOutCharEncodingName(convertCharEncoding(encoding));
|
|
1136 |
| } |
|
1137 |
| |
|
1138 |
| |
|
1139 |
| |
|
1140 |
| |
|
1141 |
| |
|
1142 |
| |
|
1143 |
0
| protected void setInCharEncoding(int encoding)
|
|
1144 |
| { |
|
1145 |
0
| setInCharEncodingName(convertCharEncoding(encoding));
|
|
1146 |
| } |
|
1147 |
| |
|
1148 |
| |
|
1149 |
| |
|
1150 |
| |
|
1151 |
| |
|
1152 |
| |
|
1153 |
0
| protected String convertCharEncoding(int code)
|
|
1154 |
| { |
|
1155 |
0
| if (code != 0 && code < ENCODING_NAMES.length)
|
|
1156 |
| { |
|
1157 |
0
| return ENCODING_NAMES[code];
|
|
1158 |
| } |
|
1159 |
0
| return null;
|
|
1160 |
| } |
|
1161 |
| |
|
1162 |
| } |