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.util.Iterator; |
57 |
| import java.util.List; |
58 |
| import java.util.StringTokenizer; |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| public final class ParsePropertyImpl |
67 |
| { |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| static final ParseProperty INT = new ParseInt(); |
73 |
| |
74 |
| |
75 |
| |
76 |
| |
77 |
| static final ParseProperty BOOL = new ParseBoolean(); |
78 |
| |
79 |
| |
80 |
| |
81 |
| |
82 |
| static final ParseProperty INVBOOL = new ParseInvBoolean(); |
83 |
| |
84 |
| |
85 |
| |
86 |
| |
87 |
| static final ParseProperty CHAR_ENCODING = new ParseCharEncoding(); |
88 |
| |
89 |
| |
90 |
| |
91 |
| |
92 |
| static final ParseProperty NAME = new ParseName(); |
93 |
| |
94 |
| |
95 |
| |
96 |
| |
97 |
| static final ParseProperty TAGNAMES = new ParseTagNames(); |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| static final ParseProperty DOCTYPE = new ParseDocType(); |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
| static final ParseProperty REPEATED_ATTRIBUTES = new ParseRepeatedAttribute(); |
108 |
| |
109 |
| |
110 |
| |
111 |
| |
112 |
| static final ParseProperty STRING = new ParseString(); |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
| static final ParseProperty INDENT = new ParseIndent(); |
118 |
| |
119 |
| |
120 |
| |
121 |
| |
122 |
| static final ParseProperty CSS1SELECTOR = new ParseCSS1Selector(); |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| static final ParseProperty NEWLINE = new ParseNewLine(); |
128 |
| |
129 |
| |
130 |
| |
131 |
| |
132 |
0
| private ParsePropertyImpl()
|
133 |
| { |
134 |
| |
135 |
| } |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
| static class ParseInt implements ParseProperty |
141 |
| { |
142 |
| |
143 |
| |
144 |
| |
145 |
| |
146 |
189
| public Object parse(String value, String option, Configuration configuration)
|
147 |
| { |
148 |
189
| int i = 0;
|
149 |
189
| try
|
150 |
| { |
151 |
189
| i = Integer.parseInt(value);
|
152 |
| } |
153 |
| catch (NumberFormatException e) |
154 |
| { |
155 |
0
| configuration.report.badArgument(value, option);
|
156 |
0
| i = -1;
|
157 |
| } |
158 |
189
| return new Integer(i);
|
159 |
| } |
160 |
| |
161 |
| |
162 |
| |
163 |
| |
164 |
16
| public String getType()
|
165 |
| { |
166 |
16
| return "Integer";
|
167 |
| } |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
4
| public String getOptionValues()
|
173 |
| { |
174 |
4
| return "0, 1, 2, ...";
|
175 |
| } |
176 |
| |
177 |
| |
178 |
| |
179 |
| |
180 |
4
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
181 |
| { |
182 |
4
| return value == null ? "" : value.toString();
|
183 |
| } |
184 |
| } |
185 |
| |
186 |
| |
187 |
| |
188 |
| |
189 |
| static class ParseBoolean implements ParseProperty |
190 |
| { |
191 |
| |
192 |
| |
193 |
| |
194 |
| |
195 |
379
| public Object parse(String value, String option, Configuration configuration)
|
196 |
| { |
197 |
379
| Boolean b = Boolean.TRUE;
|
198 |
379
| if (value != null && value.length() > 0)
|
199 |
| { |
200 |
379
| char c = value.charAt(0);
|
201 |
379
| if ((c == 't') || (c == 'T') || (c == 'Y') || (c == 'y') || (c == '1'))
|
202 |
| { |
203 |
141
| b = Boolean.TRUE;
|
204 |
| } |
205 |
238
| else if ((c == 'f') || (c == 'F') || (c == 'N') || (c == 'n') || (c == '0'))
|
206 |
| { |
207 |
238
| b = Boolean.FALSE;
|
208 |
| } |
209 |
| else |
210 |
| { |
211 |
0
| configuration.report.badArgument(value, option);
|
212 |
| } |
213 |
| } |
214 |
379
| return b;
|
215 |
| } |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
228
| public String getType()
|
221 |
| { |
222 |
228
| return "Boolean";
|
223 |
| } |
224 |
| |
225 |
| |
226 |
| |
227 |
| |
228 |
57
| public String getOptionValues()
|
229 |
| { |
230 |
57
| return "y/n, yes/no, t/f, true/false, 1/0";
|
231 |
| } |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
57
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
237 |
| { |
238 |
57
| if (value == null)
|
239 |
| { |
240 |
0
| return "";
|
241 |
| } |
242 |
| |
243 |
57
| return ((Boolean) value).booleanValue() ? "yes" : "no";
|
244 |
| } |
245 |
| } |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| static class ParseInvBoolean implements ParseProperty |
251 |
| { |
252 |
| |
253 |
| |
254 |
| |
255 |
| |
256 |
0
| public Object parse(String value, String option, Configuration configuration)
|
257 |
| { |
258 |
0
| return (((Boolean) BOOL.parse(value, option, configuration)).booleanValue() ? Boolean.FALSE : Boolean.TRUE);
|
259 |
| } |
260 |
| |
261 |
| |
262 |
| |
263 |
| |
264 |
4
| public String getType()
|
265 |
| { |
266 |
4
| return "Boolean";
|
267 |
| } |
268 |
| |
269 |
| |
270 |
| |
271 |
| |
272 |
1
| public String getOptionValues()
|
273 |
| { |
274 |
1
| return "yes, no, true, false";
|
275 |
| } |
276 |
| |
277 |
| |
278 |
| |
279 |
| |
280 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
281 |
| { |
282 |
1
| if (value == null)
|
283 |
| { |
284 |
0
| return "";
|
285 |
| } |
286 |
| |
287 |
1
| return ((Boolean) value).booleanValue() ? "no" : "yes";
|
288 |
| } |
289 |
| } |
290 |
| |
291 |
| |
292 |
| |
293 |
| |
294 |
| static class ParseCharEncoding implements ParseProperty |
295 |
| { |
296 |
| |
297 |
| |
298 |
| |
299 |
| |
300 |
15
| public Object parse(String value, String option, Configuration configuration)
|
301 |
| { |
302 |
| |
303 |
15
| if ("raw".equalsIgnoreCase(value))
|
304 |
| { |
305 |
| |
306 |
0
| configuration.rawOut = true;
|
307 |
| } |
308 |
15
| else if (!TidyUtils.isCharEncodingSupported(value))
|
309 |
| { |
310 |
0
| configuration.report.badArgument(value, option);
|
311 |
| } |
312 |
15
| else if ("input-encoding".equalsIgnoreCase(option))
|
313 |
| { |
314 |
0
| configuration.setInCharEncodingName(value);
|
315 |
| } |
316 |
15
| else if ("output-encoding".equalsIgnoreCase(option))
|
317 |
| { |
318 |
0
| configuration.setOutCharEncodingName(value);
|
319 |
| } |
320 |
15
| else if ("char-encoding".equalsIgnoreCase(option))
|
321 |
| { |
322 |
15
| configuration.setInCharEncodingName(value);
|
323 |
15
| configuration.setOutCharEncodingName(value);
|
324 |
| } |
325 |
| |
326 |
15
| return null;
|
327 |
| } |
328 |
| |
329 |
| |
330 |
| |
331 |
| |
332 |
12
| public String getType()
|
333 |
| { |
334 |
12
| return "Encoding";
|
335 |
| } |
336 |
| |
337 |
| |
338 |
| |
339 |
| |
340 |
3
| public String getOptionValues()
|
341 |
| { |
342 |
| |
343 |
3
| return "Any valid java char encoding name";
|
344 |
| } |
345 |
| |
346 |
| |
347 |
| |
348 |
| |
349 |
3
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
350 |
| { |
351 |
3
| if ("output-encoding".equalsIgnoreCase(option))
|
352 |
| { |
353 |
1
| return configuration.getOutCharEncodingName();
|
354 |
| } |
355 |
| |
356 |
| |
357 |
2
| return configuration.getInCharEncodingName();
|
358 |
| } |
359 |
| } |
360 |
| |
361 |
| |
362 |
| |
363 |
| |
364 |
| static class ParseName implements ParseProperty |
365 |
| { |
366 |
| |
367 |
| |
368 |
| |
369 |
| |
370 |
0
| public Object parse(String value, String option, Configuration configuration)
|
371 |
| { |
372 |
0
| StringTokenizer t = new StringTokenizer(value);
|
373 |
0
| String rs = null;
|
374 |
0
| if (t.countTokens() >= 1)
|
375 |
| { |
376 |
0
| rs = t.nextToken();
|
377 |
| } |
378 |
| else |
379 |
| { |
380 |
0
| configuration.report.badArgument(value, option);
|
381 |
| } |
382 |
0
| return rs;
|
383 |
| } |
384 |
| |
385 |
| |
386 |
| |
387 |
| |
388 |
12
| public String getType()
|
389 |
| { |
390 |
12
| return "Name";
|
391 |
| } |
392 |
| |
393 |
| |
394 |
| |
395 |
| |
396 |
3
| public String getOptionValues()
|
397 |
| { |
398 |
3
| return "-";
|
399 |
| } |
400 |
| |
401 |
| |
402 |
| |
403 |
| |
404 |
3
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
405 |
| { |
406 |
3
| return value == null ? "" : value.toString();
|
407 |
| } |
408 |
| } |
409 |
| |
410 |
| |
411 |
| |
412 |
| |
413 |
| static class ParseTagNames implements ParseProperty |
414 |
| { |
415 |
| |
416 |
| |
417 |
| |
418 |
| |
419 |
11
| public Object parse(String value, String option, Configuration configuration)
|
420 |
| { |
421 |
11
| short tagType = Dict.TAGTYPE_INLINE;
|
422 |
| |
423 |
11
| if ("new-inline-tags".equals(option))
|
424 |
| { |
425 |
6
| tagType = Dict.TAGTYPE_INLINE;
|
426 |
| } |
427 |
5
| else if ("new-blocklevel-tags".equals(option))
|
428 |
| { |
429 |
2
| tagType = Dict.TAGTYPE_BLOCK;
|
430 |
| } |
431 |
3
| else if ("new-empty-tags".equals(option))
|
432 |
| { |
433 |
1
| tagType = Dict.TAGTYPE_EMPTY;
|
434 |
| } |
435 |
2
| else if ("new-pre-tags".equals(option))
|
436 |
| { |
437 |
2
| tagType = Dict.TAGTYPE_PRE;
|
438 |
| } |
439 |
| |
440 |
11
| StringTokenizer t = new StringTokenizer(value, " \t\n\r,");
|
441 |
11
| while (t.hasMoreTokens())
|
442 |
| { |
443 |
20
| configuration.definedTags |= tagType;
|
444 |
20
| configuration.tt.defineTag(tagType, t.nextToken());
|
445 |
| } |
446 |
11
| return null;
|
447 |
| } |
448 |
| |
449 |
| |
450 |
| |
451 |
| |
452 |
16
| public String getType()
|
453 |
| { |
454 |
16
| return "Tag names";
|
455 |
| } |
456 |
| |
457 |
| |
458 |
| |
459 |
| |
460 |
4
| public String getOptionValues()
|
461 |
| { |
462 |
4
| return "tagX, tagY, ...";
|
463 |
| } |
464 |
| |
465 |
| |
466 |
| |
467 |
| |
468 |
4
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
469 |
| { |
470 |
4
| short tagType;
|
471 |
4
| if ("new-inline-tags".equals(option))
|
472 |
| { |
473 |
1
| tagType = Dict.TAGTYPE_INLINE;
|
474 |
| } |
475 |
3
| else if ("new-blocklevel-tags".equals(option))
|
476 |
| { |
477 |
1
| tagType = Dict.TAGTYPE_BLOCK;
|
478 |
| } |
479 |
2
| else if ("new-empty-tags".equals(option))
|
480 |
| { |
481 |
1
| tagType = Dict.TAGTYPE_EMPTY;
|
482 |
| } |
483 |
1
| else if ("new-pre-tags".equals(option))
|
484 |
| { |
485 |
1
| tagType = Dict.TAGTYPE_PRE;
|
486 |
| } |
487 |
| else |
488 |
| { |
489 |
0
| return "";
|
490 |
| } |
491 |
| |
492 |
4
| List tagList = configuration.tt.findAllDefinedTag(tagType);
|
493 |
4
| if (tagList.isEmpty())
|
494 |
| { |
495 |
3
| return "";
|
496 |
| } |
497 |
| |
498 |
1
| StringBuffer buffer = new StringBuffer();
|
499 |
1
| Iterator iterator = tagList.iterator();
|
500 |
1
| while (iterator.hasNext())
|
501 |
| { |
502 |
2
| buffer.append(iterator.next());
|
503 |
2
| buffer.append(" ");
|
504 |
| } |
505 |
| |
506 |
1
| return buffer.toString();
|
507 |
| } |
508 |
| } |
509 |
| |
510 |
| |
511 |
| |
512 |
| |
513 |
| |
514 |
| static class ParseDocType implements ParseProperty |
515 |
| { |
516 |
| |
517 |
| |
518 |
| |
519 |
| |
520 |
6
| public Object parse(String value, String option, Configuration configuration)
|
521 |
| { |
522 |
6
| value = value.trim();
|
523 |
| |
524 |
| |
525 |
| |
526 |
6
| if (value.startsWith("\""))
|
527 |
| { |
528 |
2
| configuration.docTypeMode = Configuration.DOCTYPE_USER;
|
529 |
2
| return value;
|
530 |
| } |
531 |
| |
532 |
| |
533 |
4
| String word = "";
|
534 |
4
| StringTokenizer t = new StringTokenizer(value, " \t\n\r,");
|
535 |
4
| if (t.hasMoreTokens())
|
536 |
| { |
537 |
4
| word = t.nextToken();
|
538 |
| } |
539 |
| |
540 |
4
| if ("auto".equalsIgnoreCase(word))
|
541 |
| { |
542 |
1
| configuration.docTypeMode = Configuration.DOCTYPE_AUTO;
|
543 |
| } |
544 |
3
| else if ("omit".equalsIgnoreCase(word))
|
545 |
| { |
546 |
2
| configuration.docTypeMode = Configuration.DOCTYPE_OMIT;
|
547 |
| } |
548 |
1
| else if ("strict".equalsIgnoreCase(word))
|
549 |
| { |
550 |
1
| configuration.docTypeMode = Configuration.DOCTYPE_STRICT;
|
551 |
| } |
552 |
0
| else if ("loose".equalsIgnoreCase(word) || "transitional".equalsIgnoreCase(word))
|
553 |
| { |
554 |
0
| configuration.docTypeMode = Configuration.DOCTYPE_LOOSE;
|
555 |
| } |
556 |
| else |
557 |
| { |
558 |
0
| configuration.report.badArgument(value, option);
|
559 |
| } |
560 |
4
| return null;
|
561 |
| } |
562 |
| |
563 |
| |
564 |
| |
565 |
| |
566 |
4
| public String getType()
|
567 |
| { |
568 |
4
| return "DocType";
|
569 |
| } |
570 |
| |
571 |
| |
572 |
| |
573 |
| |
574 |
1
| public String getOptionValues()
|
575 |
| { |
576 |
1
| return "omit | auto | strict | loose | [fpi]";
|
577 |
| } |
578 |
| |
579 |
| |
580 |
| |
581 |
| |
582 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
583 |
| { |
584 |
| |
585 |
1
| String stringValue;
|
586 |
| |
587 |
1
| switch (configuration.docTypeMode)
|
588 |
| { |
589 |
1
| case Configuration.DOCTYPE_AUTO :
|
590 |
1
| stringValue = "auto";
|
591 |
1
| break;
|
592 |
| |
593 |
0
| case Configuration.DOCTYPE_OMIT :
|
594 |
0
| stringValue = "omit";
|
595 |
0
| break;
|
596 |
| |
597 |
0
| case Configuration.DOCTYPE_STRICT :
|
598 |
0
| stringValue = "strict";
|
599 |
0
| break;
|
600 |
| |
601 |
0
| case Configuration.DOCTYPE_LOOSE :
|
602 |
0
| stringValue = "transitional";
|
603 |
0
| break;
|
604 |
| |
605 |
0
| case Configuration.DOCTYPE_USER :
|
606 |
0
| stringValue = configuration.docTypeStr;
|
607 |
0
| break;
|
608 |
| |
609 |
0
| default :
|
610 |
0
| stringValue = "unknown";
|
611 |
0
| break;
|
612 |
| } |
613 |
| |
614 |
1
| return stringValue;
|
615 |
| } |
616 |
| } |
617 |
| |
618 |
| |
619 |
| |
620 |
| |
621 |
| static class ParseRepeatedAttribute implements ParseProperty |
622 |
| { |
623 |
| |
624 |
| |
625 |
| |
626 |
| |
627 |
1
| public Object parse(String value, String option, Configuration configuration)
|
628 |
| { |
629 |
1
| int dupAttr;
|
630 |
| |
631 |
1
| if ("keep-first".equalsIgnoreCase(value))
|
632 |
| { |
633 |
0
| dupAttr = Configuration.KEEP_FIRST;
|
634 |
| } |
635 |
1
| else if ("keep-last".equalsIgnoreCase(value))
|
636 |
| { |
637 |
1
| dupAttr = Configuration.KEEP_LAST;
|
638 |
| } |
639 |
| else |
640 |
| { |
641 |
0
| configuration.report.badArgument(value, option);
|
642 |
0
| dupAttr = -1;
|
643 |
| } |
644 |
1
| return new Integer(dupAttr);
|
645 |
| } |
646 |
| |
647 |
| |
648 |
| |
649 |
| |
650 |
4
| public String getType()
|
651 |
| { |
652 |
4
| return "Enum";
|
653 |
| } |
654 |
| |
655 |
| |
656 |
| |
657 |
| |
658 |
1
| public String getOptionValues()
|
659 |
| { |
660 |
1
| return "keep-first, keep-last";
|
661 |
| } |
662 |
| |
663 |
| |
664 |
| |
665 |
| |
666 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
667 |
| { |
668 |
1
| if (value == null)
|
669 |
| { |
670 |
0
| return "";
|
671 |
| } |
672 |
| |
673 |
1
| int intValue = ((Integer) value).intValue();
|
674 |
1
| String stringValue;
|
675 |
| |
676 |
1
| switch (intValue)
|
677 |
| { |
678 |
0
| case Configuration.KEEP_FIRST :
|
679 |
0
| stringValue = "keep-first";
|
680 |
0
| break;
|
681 |
| |
682 |
1
| case Configuration.KEEP_LAST :
|
683 |
1
| stringValue = "keep-last";
|
684 |
1
| break;
|
685 |
| |
686 |
0
| default :
|
687 |
0
| stringValue = "unknown";
|
688 |
0
| break;
|
689 |
| } |
690 |
| |
691 |
1
| return stringValue;
|
692 |
| } |
693 |
| } |
694 |
| |
695 |
| |
696 |
| |
697 |
| |
698 |
| static class ParseString implements ParseProperty |
699 |
| { |
700 |
| |
701 |
| |
702 |
| |
703 |
| |
704 |
4
| public Object parse(String value, String option, Configuration configuration)
|
705 |
| { |
706 |
4
| return value;
|
707 |
| } |
708 |
| |
709 |
| |
710 |
| |
711 |
| |
712 |
4
| public String getType()
|
713 |
| { |
714 |
4
| return "String";
|
715 |
| } |
716 |
| |
717 |
| |
718 |
| |
719 |
| |
720 |
1
| public String getOptionValues()
|
721 |
| { |
722 |
1
| return "-";
|
723 |
| } |
724 |
| |
725 |
| |
726 |
| |
727 |
| |
728 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
729 |
| { |
730 |
1
| return value == null ? "" : (String) value;
|
731 |
| } |
732 |
| } |
733 |
| |
734 |
| |
735 |
| |
736 |
| |
737 |
| static class ParseIndent implements ParseProperty |
738 |
| { |
739 |
| |
740 |
| |
741 |
| |
742 |
| |
743 |
15
| public Object parse(String value, String option, Configuration configuration)
|
744 |
| { |
745 |
15
| boolean b = configuration.indentContent;
|
746 |
| |
747 |
15
| if ("yes".equalsIgnoreCase(value))
|
748 |
| { |
749 |
1
| b = true;
|
750 |
1
| configuration.smartIndent = false;
|
751 |
| } |
752 |
14
| else if ("true".equalsIgnoreCase(value))
|
753 |
| { |
754 |
0
| b = true;
|
755 |
0
| configuration.smartIndent = false;
|
756 |
| } |
757 |
14
| else if ("no".equalsIgnoreCase(value))
|
758 |
| { |
759 |
2
| b = false;
|
760 |
2
| configuration.smartIndent = false;
|
761 |
| } |
762 |
12
| else if ("false".equalsIgnoreCase(value))
|
763 |
| { |
764 |
0
| b = false;
|
765 |
0
| configuration.smartIndent = false;
|
766 |
| } |
767 |
12
| else if ("auto".equalsIgnoreCase(value))
|
768 |
| { |
769 |
12
| b = true;
|
770 |
12
| configuration.smartIndent = true;
|
771 |
| } |
772 |
| else |
773 |
| { |
774 |
0
| configuration.report.badArgument(value, option);
|
775 |
| } |
776 |
15
| return b ? Boolean.TRUE : Boolean.FALSE;
|
777 |
| } |
778 |
| |
779 |
| |
780 |
| |
781 |
| |
782 |
4
| public String getType()
|
783 |
| { |
784 |
4
| return "Indent";
|
785 |
| } |
786 |
| |
787 |
| |
788 |
| |
789 |
| |
790 |
1
| public String getOptionValues()
|
791 |
| { |
792 |
1
| return "auto, y/n, yes/no, t/f, true/false, 1/0";
|
793 |
| } |
794 |
| |
795 |
| |
796 |
| |
797 |
| |
798 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
799 |
| { |
800 |
1
| return value == null ? "" : value.toString();
|
801 |
| } |
802 |
| } |
803 |
| |
804 |
| |
805 |
| |
806 |
| |
807 |
| static class ParseCSS1Selector implements ParseProperty |
808 |
| { |
809 |
| |
810 |
| |
811 |
| |
812 |
| |
813 |
1
| public Object parse(String value, String option, Configuration configuration)
|
814 |
| { |
815 |
1
| StringTokenizer t = new StringTokenizer(value);
|
816 |
1
| String buf = null;
|
817 |
1
| if (t.countTokens() >= 1)
|
818 |
| { |
819 |
1
| buf = t.nextToken() + "-";
|
820 |
| |
821 |
| } |
822 |
| else |
823 |
| { |
824 |
0
| configuration.report.badArgument(value, option);
|
825 |
| } |
826 |
| |
827 |
1
| if (!Lexer.isCSS1Selector(value))
|
828 |
| { |
829 |
0
| configuration.report.badArgument(value, option);
|
830 |
| } |
831 |
| |
832 |
1
| return buf;
|
833 |
| } |
834 |
| |
835 |
| |
836 |
| |
837 |
| |
838 |
4
| public String getType()
|
839 |
| { |
840 |
4
| return "Name";
|
841 |
| } |
842 |
| |
843 |
| |
844 |
| |
845 |
| |
846 |
1
| public String getOptionValues()
|
847 |
| { |
848 |
1
| return "CSS1 selector";
|
849 |
| } |
850 |
| |
851 |
| |
852 |
| |
853 |
| |
854 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
855 |
| { |
856 |
1
| return value == null ? "" : (String) value;
|
857 |
| } |
858 |
| } |
859 |
| |
860 |
| |
861 |
| |
862 |
| |
863 |
| static class ParseNewLine implements ParseProperty |
864 |
| { |
865 |
| |
866 |
| |
867 |
| |
868 |
| |
869 |
2
| public Object parse(String value, String option, Configuration configuration)
|
870 |
| { |
871 |
| |
872 |
2
| if ("lf".equalsIgnoreCase(value))
|
873 |
| { |
874 |
1
| configuration.newline = new char[]{'\n'};
|
875 |
| } |
876 |
1
| else if ("cr".equalsIgnoreCase(value))
|
877 |
| { |
878 |
1
| configuration.newline = new char[]{'\r'};
|
879 |
| } |
880 |
0
| else if ("crlf".equalsIgnoreCase(value))
|
881 |
| { |
882 |
0
| configuration.newline = new char[]{'\r', '\n'};
|
883 |
| } |
884 |
| else |
885 |
| { |
886 |
0
| configuration.report.badArgument(value, option);
|
887 |
| } |
888 |
2
| return null;
|
889 |
| } |
890 |
| |
891 |
| |
892 |
| |
893 |
| |
894 |
4
| public String getType()
|
895 |
| { |
896 |
4
| return "Enum";
|
897 |
| } |
898 |
| |
899 |
| |
900 |
| |
901 |
| |
902 |
1
| public String getOptionValues()
|
903 |
| { |
904 |
1
| return "lf, crlf, cr";
|
905 |
| } |
906 |
| |
907 |
| |
908 |
| |
909 |
| |
910 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
911 |
| { |
912 |
1
| if (configuration.newline.length == 1)
|
913 |
| { |
914 |
0
| return (configuration.newline[0] == '\n') ? "lf" : "cr";
|
915 |
| } |
916 |
1
| return "crlf";
|
917 |
| } |
918 |
| } |
919 |
| |
920 |
| } |