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 |
185
| public Object parse(String value, String option, Configuration configuration)
|
147 |
| { |
148 |
185
| int i = 0;
|
149 |
185
| try
|
150 |
| { |
151 |
185
| i = Integer.parseInt(value);
|
152 |
| } |
153 |
| catch (NumberFormatException e) |
154 |
| { |
155 |
0
| configuration.report.badArgument(value, option);
|
156 |
0
| i = -1;
|
157 |
| } |
158 |
185
| 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 |
375
| public Object parse(String value, String option, Configuration configuration)
|
196 |
| { |
197 |
375
| Boolean b = Boolean.TRUE;
|
198 |
375
| if (value != null && value.length() > 0)
|
199 |
| { |
200 |
375
| char c = value.charAt(0);
|
201 |
375
| if ((c == 't') || (c == 'T') || (c == 'Y') || (c == 'y') || (c == '1'))
|
202 |
| { |
203 |
140
| b = Boolean.TRUE;
|
204 |
| } |
205 |
235
| else if ((c == 'f') || (c == 'F') || (c == 'N') || (c == 'n') || (c == '0'))
|
206 |
| { |
207 |
235
| b = Boolean.FALSE;
|
208 |
| } |
209 |
| else |
210 |
| { |
211 |
0
| configuration.report.badArgument(value, option);
|
212 |
| } |
213 |
| } |
214 |
375
| 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 |
| |
295 |
| static class ParseCharEncoding implements ParseProperty |
296 |
| { |
297 |
| |
298 |
| |
299 |
| |
300 |
| |
301 |
16
| public Object parse(String value, String option, Configuration configuration)
|
302 |
| { |
303 |
| |
304 |
16
| if ("raw".equalsIgnoreCase(value))
|
305 |
| { |
306 |
| |
307 |
0
| configuration.rawOut = true;
|
308 |
| } |
309 |
16
| else if (!TidyUtils.isCharEncodingSupported(value))
|
310 |
| { |
311 |
0
| configuration.report.badArgument(value, option);
|
312 |
| } |
313 |
16
| else if ("input-encoding".equalsIgnoreCase(option))
|
314 |
| { |
315 |
0
| configuration.setInCharEncodingName(value);
|
316 |
| } |
317 |
16
| else if ("output-encoding".equalsIgnoreCase(option))
|
318 |
| { |
319 |
0
| configuration.setOutCharEncodingName(value);
|
320 |
| } |
321 |
16
| else if ("char-encoding".equalsIgnoreCase(option))
|
322 |
| { |
323 |
16
| configuration.setInCharEncodingName(value);
|
324 |
16
| configuration.setOutCharEncodingName(value);
|
325 |
| } |
326 |
| |
327 |
16
| return null;
|
328 |
| } |
329 |
| |
330 |
| |
331 |
| |
332 |
| |
333 |
12
| public String getType()
|
334 |
| { |
335 |
12
| return "Encoding";
|
336 |
| } |
337 |
| |
338 |
| |
339 |
| |
340 |
| |
341 |
3
| public String getOptionValues()
|
342 |
| { |
343 |
| |
344 |
3
| return "Any valid java char encoding name";
|
345 |
| } |
346 |
| |
347 |
| |
348 |
| |
349 |
| |
350 |
3
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
351 |
| { |
352 |
3
| if ("output-encoding".equalsIgnoreCase(option))
|
353 |
| { |
354 |
1
| return configuration.getOutCharEncodingName();
|
355 |
| } |
356 |
| |
357 |
| |
358 |
2
| return configuration.getInCharEncodingName();
|
359 |
| } |
360 |
| } |
361 |
| |
362 |
| |
363 |
| |
364 |
| |
365 |
| static class ParseName implements ParseProperty |
366 |
| { |
367 |
| |
368 |
| |
369 |
| |
370 |
| |
371 |
0
| public Object parse(String value, String option, Configuration configuration)
|
372 |
| { |
373 |
0
| StringTokenizer t = new StringTokenizer(value);
|
374 |
0
| String rs = null;
|
375 |
0
| if (t.countTokens() >= 1)
|
376 |
| { |
377 |
0
| rs = t.nextToken();
|
378 |
| } |
379 |
| else |
380 |
| { |
381 |
0
| configuration.report.badArgument(value, option);
|
382 |
| } |
383 |
0
| return rs;
|
384 |
| } |
385 |
| |
386 |
| |
387 |
| |
388 |
| |
389 |
12
| public String getType()
|
390 |
| { |
391 |
12
| return "Name";
|
392 |
| } |
393 |
| |
394 |
| |
395 |
| |
396 |
| |
397 |
3
| public String getOptionValues()
|
398 |
| { |
399 |
3
| return "-";
|
400 |
| } |
401 |
| |
402 |
| |
403 |
| |
404 |
| |
405 |
3
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
406 |
| { |
407 |
3
| return value == null ? "" : value.toString();
|
408 |
| } |
409 |
| } |
410 |
| |
411 |
| |
412 |
| |
413 |
| |
414 |
| static class ParseTagNames implements ParseProperty |
415 |
| { |
416 |
| |
417 |
| |
418 |
| |
419 |
| |
420 |
11
| public Object parse(String value, String option, Configuration configuration)
|
421 |
| { |
422 |
11
| short tagType = Dict.TAGTYPE_INLINE;
|
423 |
| |
424 |
11
| if ("new-inline-tags".equals(option))
|
425 |
| { |
426 |
6
| tagType = Dict.TAGTYPE_INLINE;
|
427 |
| } |
428 |
5
| else if ("new-blocklevel-tags".equals(option))
|
429 |
| { |
430 |
2
| tagType = Dict.TAGTYPE_BLOCK;
|
431 |
| } |
432 |
3
| else if ("new-empty-tags".equals(option))
|
433 |
| { |
434 |
1
| tagType = Dict.TAGTYPE_EMPTY;
|
435 |
| } |
436 |
2
| else if ("new-pre-tags".equals(option))
|
437 |
| { |
438 |
2
| tagType = Dict.TAGTYPE_PRE;
|
439 |
| } |
440 |
| |
441 |
11
| StringTokenizer t = new StringTokenizer(value, " \t\n\r,");
|
442 |
11
| while (t.hasMoreTokens())
|
443 |
| { |
444 |
20
| configuration.definedTags |= tagType;
|
445 |
20
| configuration.tt.defineTag(tagType, t.nextToken());
|
446 |
| } |
447 |
11
| return null;
|
448 |
| } |
449 |
| |
450 |
| |
451 |
| |
452 |
| |
453 |
16
| public String getType()
|
454 |
| { |
455 |
16
| return "Tag names";
|
456 |
| } |
457 |
| |
458 |
| |
459 |
| |
460 |
| |
461 |
4
| public String getOptionValues()
|
462 |
| { |
463 |
4
| return "tagX, tagY, ...";
|
464 |
| } |
465 |
| |
466 |
| |
467 |
| |
468 |
| |
469 |
4
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
470 |
| { |
471 |
4
| short tagType;
|
472 |
4
| if ("new-inline-tags".equals(option))
|
473 |
| { |
474 |
1
| tagType = Dict.TAGTYPE_INLINE;
|
475 |
| } |
476 |
3
| else if ("new-blocklevel-tags".equals(option))
|
477 |
| { |
478 |
1
| tagType = Dict.TAGTYPE_BLOCK;
|
479 |
| } |
480 |
2
| else if ("new-empty-tags".equals(option))
|
481 |
| { |
482 |
1
| tagType = Dict.TAGTYPE_EMPTY;
|
483 |
| } |
484 |
1
| else if ("new-pre-tags".equals(option))
|
485 |
| { |
486 |
1
| tagType = Dict.TAGTYPE_PRE;
|
487 |
| } |
488 |
| else |
489 |
| { |
490 |
0
| return "";
|
491 |
| } |
492 |
| |
493 |
4
| List tagList = configuration.tt.findAllDefinedTag(tagType);
|
494 |
4
| if (tagList.isEmpty())
|
495 |
| { |
496 |
3
| return "";
|
497 |
| } |
498 |
| |
499 |
1
| StringBuffer buffer = new StringBuffer();
|
500 |
1
| Iterator iterator = tagList.iterator();
|
501 |
1
| while (iterator.hasNext())
|
502 |
| { |
503 |
2
| buffer.append(iterator.next());
|
504 |
2
| buffer.append(" ");
|
505 |
| } |
506 |
| |
507 |
1
| return buffer.toString();
|
508 |
| } |
509 |
| } |
510 |
| |
511 |
| |
512 |
| |
513 |
| |
514 |
| |
515 |
| static class ParseDocType implements ParseProperty |
516 |
| { |
517 |
| |
518 |
| |
519 |
| |
520 |
| |
521 |
6
| public Object parse(String value, String option, Configuration configuration)
|
522 |
| { |
523 |
6
| value = value.trim();
|
524 |
| |
525 |
| |
526 |
| |
527 |
6
| if (value.startsWith("\""))
|
528 |
| { |
529 |
2
| configuration.docTypeMode = Configuration.DOCTYPE_USER;
|
530 |
2
| return value;
|
531 |
| } |
532 |
| |
533 |
| |
534 |
4
| String word = "";
|
535 |
4
| StringTokenizer t = new StringTokenizer(value, " \t\n\r,");
|
536 |
4
| if (t.hasMoreTokens())
|
537 |
| { |
538 |
4
| word = t.nextToken();
|
539 |
| } |
540 |
| |
541 |
4
| if ("auto".equalsIgnoreCase(word))
|
542 |
| { |
543 |
1
| configuration.docTypeMode = Configuration.DOCTYPE_AUTO;
|
544 |
| } |
545 |
3
| else if ("omit".equalsIgnoreCase(word))
|
546 |
| { |
547 |
2
| configuration.docTypeMode = Configuration.DOCTYPE_OMIT;
|
548 |
| } |
549 |
1
| else if ("strict".equalsIgnoreCase(word))
|
550 |
| { |
551 |
1
| configuration.docTypeMode = Configuration.DOCTYPE_STRICT;
|
552 |
| } |
553 |
0
| else if ("loose".equalsIgnoreCase(word) || "transitional".equalsIgnoreCase(word))
|
554 |
| { |
555 |
0
| configuration.docTypeMode = Configuration.DOCTYPE_LOOSE;
|
556 |
| } |
557 |
| else |
558 |
| { |
559 |
0
| configuration.report.badArgument(value, option);
|
560 |
| } |
561 |
4
| return null;
|
562 |
| } |
563 |
| |
564 |
| |
565 |
| |
566 |
| |
567 |
4
| public String getType()
|
568 |
| { |
569 |
4
| return "DocType";
|
570 |
| } |
571 |
| |
572 |
| |
573 |
| |
574 |
| |
575 |
1
| public String getOptionValues()
|
576 |
| { |
577 |
1
| return "omit | auto | strict | loose | [fpi]";
|
578 |
| } |
579 |
| |
580 |
| |
581 |
| |
582 |
| |
583 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
584 |
| { |
585 |
| |
586 |
1
| String stringValue;
|
587 |
| |
588 |
1
| switch (configuration.docTypeMode)
|
589 |
| { |
590 |
1
| case Configuration.DOCTYPE_AUTO :
|
591 |
1
| stringValue = "auto";
|
592 |
1
| break;
|
593 |
| |
594 |
0
| case Configuration.DOCTYPE_OMIT :
|
595 |
0
| stringValue = "omit";
|
596 |
0
| break;
|
597 |
| |
598 |
0
| case Configuration.DOCTYPE_STRICT :
|
599 |
0
| stringValue = "strict";
|
600 |
0
| break;
|
601 |
| |
602 |
0
| case Configuration.DOCTYPE_LOOSE :
|
603 |
0
| stringValue = "transitional";
|
604 |
0
| break;
|
605 |
| |
606 |
0
| case Configuration.DOCTYPE_USER :
|
607 |
0
| stringValue = configuration.docTypeStr;
|
608 |
0
| break;
|
609 |
| |
610 |
0
| default :
|
611 |
0
| stringValue = "unknown";
|
612 |
0
| break;
|
613 |
| } |
614 |
| |
615 |
1
| return stringValue;
|
616 |
| } |
617 |
| } |
618 |
| |
619 |
| |
620 |
| |
621 |
| |
622 |
| static class ParseRepeatedAttribute implements ParseProperty |
623 |
| { |
624 |
| |
625 |
| |
626 |
| |
627 |
| |
628 |
1
| public Object parse(String value, String option, Configuration configuration)
|
629 |
| { |
630 |
1
| int dupAttr;
|
631 |
| |
632 |
1
| if ("keep-first".equalsIgnoreCase(value))
|
633 |
| { |
634 |
0
| dupAttr = Configuration.KEEP_FIRST;
|
635 |
| } |
636 |
1
| else if ("keep-last".equalsIgnoreCase(value))
|
637 |
| { |
638 |
1
| dupAttr = Configuration.KEEP_LAST;
|
639 |
| } |
640 |
| else |
641 |
| { |
642 |
0
| configuration.report.badArgument(value, option);
|
643 |
0
| dupAttr = -1;
|
644 |
| } |
645 |
1
| return new Integer(dupAttr);
|
646 |
| } |
647 |
| |
648 |
| |
649 |
| |
650 |
| |
651 |
4
| public String getType()
|
652 |
| { |
653 |
4
| return "Enum";
|
654 |
| } |
655 |
| |
656 |
| |
657 |
| |
658 |
| |
659 |
1
| public String getOptionValues()
|
660 |
| { |
661 |
1
| return "keep-first, keep-last";
|
662 |
| } |
663 |
| |
664 |
| |
665 |
| |
666 |
| |
667 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
668 |
| { |
669 |
1
| if (value == null)
|
670 |
| { |
671 |
0
| return "";
|
672 |
| } |
673 |
| |
674 |
1
| int intValue = ((Integer) value).intValue();
|
675 |
1
| String stringValue;
|
676 |
| |
677 |
1
| switch (intValue)
|
678 |
| { |
679 |
0
| case Configuration.KEEP_FIRST :
|
680 |
0
| stringValue = "keep-first";
|
681 |
0
| break;
|
682 |
| |
683 |
1
| case Configuration.KEEP_LAST :
|
684 |
1
| stringValue = "keep-last";
|
685 |
1
| break;
|
686 |
| |
687 |
0
| default :
|
688 |
0
| stringValue = "unknown";
|
689 |
0
| break;
|
690 |
| } |
691 |
| |
692 |
1
| return stringValue;
|
693 |
| } |
694 |
| } |
695 |
| |
696 |
| |
697 |
| |
698 |
| |
699 |
| static class ParseString implements ParseProperty |
700 |
| { |
701 |
| |
702 |
| |
703 |
| |
704 |
| |
705 |
4
| public Object parse(String value, String option, Configuration configuration)
|
706 |
| { |
707 |
4
| return value;
|
708 |
| } |
709 |
| |
710 |
| |
711 |
| |
712 |
| |
713 |
4
| public String getType()
|
714 |
| { |
715 |
4
| return "String";
|
716 |
| } |
717 |
| |
718 |
| |
719 |
| |
720 |
| |
721 |
1
| public String getOptionValues()
|
722 |
| { |
723 |
1
| return "-";
|
724 |
| } |
725 |
| |
726 |
| |
727 |
| |
728 |
| |
729 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
730 |
| { |
731 |
1
| return value == null ? "" : (String) value;
|
732 |
| } |
733 |
| } |
734 |
| |
735 |
| |
736 |
| |
737 |
| |
738 |
| static class ParseIndent implements ParseProperty |
739 |
| { |
740 |
| |
741 |
| |
742 |
| |
743 |
| |
744 |
15
| public Object parse(String value, String option, Configuration configuration)
|
745 |
| { |
746 |
15
| boolean b = configuration.indentContent;
|
747 |
| |
748 |
15
| if ("yes".equalsIgnoreCase(value))
|
749 |
| { |
750 |
1
| b = true;
|
751 |
1
| configuration.smartIndent = false;
|
752 |
| } |
753 |
14
| else if ("true".equalsIgnoreCase(value))
|
754 |
| { |
755 |
0
| b = true;
|
756 |
0
| configuration.smartIndent = false;
|
757 |
| } |
758 |
14
| else if ("no".equalsIgnoreCase(value))
|
759 |
| { |
760 |
2
| b = false;
|
761 |
2
| configuration.smartIndent = false;
|
762 |
| } |
763 |
12
| else if ("false".equalsIgnoreCase(value))
|
764 |
| { |
765 |
0
| b = false;
|
766 |
0
| configuration.smartIndent = false;
|
767 |
| } |
768 |
12
| else if ("auto".equalsIgnoreCase(value))
|
769 |
| { |
770 |
12
| b = true;
|
771 |
12
| configuration.smartIndent = true;
|
772 |
| } |
773 |
| else |
774 |
| { |
775 |
0
| configuration.report.badArgument(value, option);
|
776 |
| } |
777 |
15
| return b ? Boolean.TRUE : Boolean.FALSE;
|
778 |
| } |
779 |
| |
780 |
| |
781 |
| |
782 |
| |
783 |
4
| public String getType()
|
784 |
| { |
785 |
4
| return "Indent";
|
786 |
| } |
787 |
| |
788 |
| |
789 |
| |
790 |
| |
791 |
1
| public String getOptionValues()
|
792 |
| { |
793 |
1
| return "auto, y/n, yes/no, t/f, true/false, 1/0";
|
794 |
| } |
795 |
| |
796 |
| |
797 |
| |
798 |
| |
799 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
800 |
| { |
801 |
1
| return value == null ? "" : value.toString();
|
802 |
| } |
803 |
| } |
804 |
| |
805 |
| |
806 |
| |
807 |
| |
808 |
| static class ParseCSS1Selector implements ParseProperty |
809 |
| { |
810 |
| |
811 |
| |
812 |
| |
813 |
| |
814 |
1
| public Object parse(String value, String option, Configuration configuration)
|
815 |
| { |
816 |
1
| StringTokenizer t = new StringTokenizer(value);
|
817 |
1
| String buf = null;
|
818 |
1
| if (t.countTokens() >= 1)
|
819 |
| { |
820 |
1
| buf = t.nextToken() + "-";
|
821 |
| |
822 |
| } |
823 |
| else |
824 |
| { |
825 |
0
| configuration.report.badArgument(value, option);
|
826 |
| } |
827 |
| |
828 |
1
| if (!Lexer.isCSS1Selector(value))
|
829 |
| { |
830 |
0
| configuration.report.badArgument(value, option);
|
831 |
| } |
832 |
| |
833 |
1
| return buf;
|
834 |
| } |
835 |
| |
836 |
| |
837 |
| |
838 |
| |
839 |
4
| public String getType()
|
840 |
| { |
841 |
4
| return "Name";
|
842 |
| } |
843 |
| |
844 |
| |
845 |
| |
846 |
| |
847 |
1
| public String getOptionValues()
|
848 |
| { |
849 |
1
| return "CSS1 selector";
|
850 |
| } |
851 |
| |
852 |
| |
853 |
| |
854 |
| |
855 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
856 |
| { |
857 |
1
| return value == null ? "" : (String) value;
|
858 |
| } |
859 |
| } |
860 |
| |
861 |
| |
862 |
| |
863 |
| |
864 |
| static class ParseNewLine implements ParseProperty |
865 |
| { |
866 |
| |
867 |
| |
868 |
| |
869 |
| |
870 |
2
| public Object parse(String value, String option, Configuration configuration)
|
871 |
| { |
872 |
| |
873 |
2
| if ("lf".equalsIgnoreCase(value))
|
874 |
| { |
875 |
1
| configuration.newline = new char[]{'\n'};
|
876 |
| } |
877 |
1
| else if ("cr".equalsIgnoreCase(value))
|
878 |
| { |
879 |
1
| configuration.newline = new char[]{'\r'};
|
880 |
| } |
881 |
0
| else if ("crlf".equalsIgnoreCase(value))
|
882 |
| { |
883 |
0
| configuration.newline = new char[]{'\r', '\n'};
|
884 |
| } |
885 |
| else |
886 |
| { |
887 |
0
| configuration.report.badArgument(value, option);
|
888 |
| } |
889 |
2
| return null;
|
890 |
| } |
891 |
| |
892 |
| |
893 |
| |
894 |
| |
895 |
4
| public String getType()
|
896 |
| { |
897 |
4
| return "Enum";
|
898 |
| } |
899 |
| |
900 |
| |
901 |
| |
902 |
| |
903 |
1
| public String getOptionValues()
|
904 |
| { |
905 |
1
| return "lf, crlf, cr";
|
906 |
| } |
907 |
| |
908 |
| |
909 |
| |
910 |
| |
911 |
1
| public String getFriendlyName(String option, Object value, Configuration configuration)
|
912 |
| { |
913 |
1
| if (configuration.newline.length == 1)
|
914 |
| { |
915 |
1
| return (configuration.newline[0] == '\n') ? "lf" : "cr";
|
916 |
| } |
917 |
0
| return "crlf";
|
918 |
| } |
919 |
| } |
920 |
| |
921 |
| } |