Clover coverage report - Maven Clover report
Coverage timestamp: Tue Aug 1 2006 15:09:51 CEST
file stats: LOC: 920   Methods: 49
NCLOC: 525   Classes: 13
 
 Source file Conditionals Statements Methods TOTAL
ParsePropertyImpl.java 63.2% 72.7% 93.9% 72.8%
coverage coverage
 1    /*
 2    * Java HTML Tidy - JTidy
 3    * HTML parser and pretty printer
 4    *
 5    * Copyright (c) 1998-2000 World Wide Web Consortium (Massachusetts
 6    * Institute of Technology, Institut National de Recherche en
 7    * Informatique et en Automatique, Keio University). All Rights
 8    * Reserved.
 9    *
 10    * Contributing Author(s):
 11    *
 12    * Dave Raggett <dsr@w3.org>
 13    * Andy Quick <ac.quick@sympatico.ca> (translation to Java)
 14    * Gary L Peskin <garyp@firstech.com> (Java development)
 15    * Sami Lempinen <sami@lempinen.net> (release management)
 16    * Fabrizio Giustina <fgiust at users.sourceforge.net>
 17    *
 18    * The contributing author(s) would like to thank all those who
 19    * helped with testing, bug fixes, and patience. This wouldn't
 20    * have been possible without all of you.
 21    *
 22    * COPYRIGHT NOTICE:
 23    *
 24    * This software and documentation is provided "as is," and
 25    * the copyright holders and contributing author(s) make no
 26    * representations or warranties, express or implied, including
 27    * but not limited to, warranties of merchantability or fitness
 28    * for any particular purpose or that the use of the software or
 29    * documentation will not infringe any third party patents,
 30    * copyrights, trademarks or other rights.
 31    *
 32    * The copyright holders and contributing author(s) will not be
 33    * liable for any direct, indirect, special or consequential damages
 34    * arising out of any use of the software or documentation, even if
 35    * advised of the possibility of such damage.
 36    *
 37    * Permission is hereby granted to use, copy, modify, and distribute
 38    * this source code, or portions hereof, documentation and executables,
 39    * for any purpose, without fee, subject to the following restrictions:
 40    *
 41    * 1. The origin of this source code must not be misrepresented.
 42    * 2. Altered versions must be plainly marked as such and must
 43    * not be misrepresented as being the original source.
 44    * 3. This Copyright notice may not be removed or altered from any
 45    * source or altered source distribution.
 46    *
 47    * The copyright holders and contributing author(s) specifically
 48    * permit, without fee, and encourage the use of this source code
 49    * as a component for supporting the Hypertext Markup Language in
 50    * commercial products. If you use this source code in a product,
 51    * acknowledgment is not required but would be appreciated.
 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    * Property parser instances.
 63    * @author Fabrizio Giustina
 64    * @version $Revision $ ($Author $)
 65    */
 66    public final class ParsePropertyImpl
 67    {
 68   
 69    /**
 70    * configuration parser for int values.
 71    */
 72    static final ParseProperty INT = new ParseInt();
 73   
 74    /**
 75    * configuration parser for boolean values.
 76    */
 77    static final ParseProperty BOOL = new ParseBoolean();
 78   
 79    /**
 80    * configuration parser for inverted boolean values.
 81    */
 82    static final ParseProperty INVBOOL = new ParseInvBoolean();
 83   
 84    /**
 85    * configuration parser for char encoding values.
 86    */
 87    static final ParseProperty CHAR_ENCODING = new ParseCharEncoding();
 88   
 89    /**
 90    * configuration parser for name values.
 91    */
 92    static final ParseProperty NAME = new ParseName();
 93   
 94    /**
 95    * configuration parser for tag names.
 96    */
 97    static final ParseProperty TAGNAMES = new ParseTagNames();
 98   
 99    /**
 100    * configuration parser for doctype property.
 101    */
 102    static final ParseProperty DOCTYPE = new ParseDocType();
 103   
 104    /**
 105    * configuration parser for repetated attribute property.
 106    */
 107    static final ParseProperty REPEATED_ATTRIBUTES = new ParseRepeatedAttribute();
 108   
 109    /**
 110    * configuration parser for String values.
 111    */
 112    static final ParseProperty STRING = new ParseString();
 113   
 114    /**
 115    * configuration parser for indent property.
 116    */
 117    static final ParseProperty INDENT = new ParseIndent();
 118   
 119    /**
 120    * configuration parser for css selectors.
 121    */
 122    static final ParseProperty CSS1SELECTOR = new ParseCSS1Selector();
 123   
 124    /**
 125    * configuration parser for new line bytes.
 126    */
 127    static final ParseProperty NEWLINE = new ParseNewLine();
 128   
 129    /**
 130    * don't instantiate.
 131    */
 132  0 private ParsePropertyImpl()
 133    {
 134    // unused
 135    }
 136   
 137    /**
 138    * parser for integer values.
 139    */
 140    static class ParseInt implements ParseProperty
 141    {
 142   
 143    /**
 144    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 163    */
 164  16 public String getType()
 165    {
 166  16 return "Integer";
 167    }
 168   
 169    /**
 170    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 171    */
 172  4 public String getOptionValues()
 173    {
 174  4 return "0, 1, 2, ...";
 175    }
 176   
 177    /**
 178    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * parser for boolean values.
 188    */
 189    static class ParseBoolean implements ParseProperty
 190    {
 191   
 192    /**
 193    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 219    */
 220  228 public String getType()
 221    {
 222  228 return "Boolean";
 223    }
 224   
 225    /**
 226    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 227    */
 228  57 public String getOptionValues()
 229    {
 230  57 return "y/n, yes/no, t/f, true/false, 1/0";
 231    }
 232   
 233    /**
 234    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * parser for boolean values.
 249    */
 250    static class ParseInvBoolean implements ParseProperty
 251    {
 252   
 253    /**
 254    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 263    */
 264  4 public String getType()
 265    {
 266  4 return "Boolean";
 267    }
 268   
 269    /**
 270    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 271    */
 272  1 public String getOptionValues()
 273    {
 274  1 return "yes, no, true, false";
 275    }
 276   
 277    /**
 278    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * parse character encoding option. Can be any java encoding name supported by the runtime platform.
 293    */
 294    static class ParseCharEncoding implements ParseProperty
 295    {
 296   
 297    /**
 298    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 299    */
 300  15 public Object parse(String value, String option, Configuration configuration)
 301    {
 302   
 303  15 if ("raw".equalsIgnoreCase(value))
 304    {
 305    // special value for compatibility with tidy c
 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    * @see org.w3c.tidy.ParseProperty#getType()
 331    */
 332  12 public String getType()
 333    {
 334  12 return "Encoding";
 335    }
 336   
 337    /**
 338    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 339    */
 340  3 public String getOptionValues()
 341    {
 342    // ascii, latin1, raw, utf-8, iso2022, mac, utf-16, utf-16be, utf-16le, big5, shiftjis
 343  3 return "Any valid java char encoding name";
 344    }
 345   
 346    /**
 347    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    // for input-encoding or char-encoding
 357  2 return configuration.getInCharEncodingName();
 358    }
 359    }
 360   
 361    /**
 362    * parser for name values (a string excluding whitespace).
 363    */
 364    static class ParseName implements ParseProperty
 365    {
 366   
 367    /**
 368    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 387    */
 388  12 public String getType()
 389    {
 390  12 return "Name";
 391    }
 392   
 393    /**
 394    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 395    */
 396  3 public String getOptionValues()
 397    {
 398  3 return "-";
 399    }
 400   
 401    /**
 402    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * parser for name values.
 412    */
 413    static class ParseTagNames implements ParseProperty
 414    {
 415   
 416    /**
 417    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 451    */
 452  16 public String getType()
 453    {
 454  16 return "Tag names";
 455    }
 456   
 457    /**
 458    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 459    */
 460  4 public String getOptionValues()
 461    {
 462  4 return "tagX, tagY, ...";
 463    }
 464   
 465    /**
 466    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * Parse doctype preference. doctype: <code>omit | auto | strict | loose | [fpi]</code> where the fpi is a string
 512    * similar to <code>"-//ACME//DTD HTML 3.14159//EN"</code>.
 513    */
 514    static class ParseDocType implements ParseProperty
 515    {
 516   
 517    /**
 518    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 519    */
 520  6 public Object parse(String value, String option, Configuration configuration)
 521    {
 522  6 value = value.trim();
 523   
 524    /* "-//ACME//DTD HTML 3.14159//EN" or similar */
 525   
 526  6 if (value.startsWith("\""))
 527    {
 528  2 configuration.docTypeMode = Configuration.DOCTYPE_USER;
 529  2 return value;
 530    }
 531   
 532    /* read first word */
 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    // #443663 - fix by Terry Teague 23 Jul 01
 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    * @see org.w3c.tidy.ParseProperty#getType()
 565    */
 566  4 public String getType()
 567    {
 568  4 return "DocType";
 569    }
 570   
 571    /**
 572    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 573    */
 574  1 public String getOptionValues()
 575    {
 576  1 return "omit | auto | strict | loose | [fpi]";
 577    }
 578   
 579    /**
 580    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * keep-first or keep-last?
 620    */
 621    static class ParseRepeatedAttribute implements ParseProperty
 622    {
 623   
 624    /**
 625    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 649    */
 650  4 public String getType()
 651    {
 652  4 return "Enum";
 653    }
 654   
 655    /**
 656    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 657    */
 658  1 public String getOptionValues()
 659    {
 660  1 return "keep-first, keep-last";
 661    }
 662   
 663    /**
 664    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * Parser for String values.
 697    */
 698    static class ParseString implements ParseProperty
 699    {
 700   
 701    /**
 702    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 703    */
 704  4 public Object parse(String value, String option, Configuration configuration)
 705    {
 706  4 return value;
 707    }
 708   
 709    /**
 710    * @see org.w3c.tidy.ParseProperty#getType()
 711    */
 712  4 public String getType()
 713    {
 714  4 return "String";
 715    }
 716   
 717    /**
 718    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 719    */
 720  1 public String getOptionValues()
 721    {
 722  1 return "-";
 723    }
 724   
 725    /**
 726    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * Parser for indent values.
 736    */
 737    static class ParseIndent implements ParseProperty
 738    {
 739   
 740    /**
 741    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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    * @see org.w3c.tidy.ParseProperty#getType()
 781    */
 782  4 public String getType()
 783    {
 784  4 return "Indent";
 785    }
 786   
 787    /**
 788    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 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    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * Parser for css selectors.
 806    */
 807    static class ParseCSS1Selector implements ParseProperty
 808    {
 809   
 810    /**
 811    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 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() + "-"; // Make sure any escaped Unicode is terminated so valid class names are
 820    // generated after Tidy appends last digits.
 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    * @see org.w3c.tidy.ParseProperty#getType()
 837    */
 838  4 public String getType()
 839    {
 840  4 return "Name";
 841    }
 842   
 843    /**
 844    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 845    */
 846  1 public String getOptionValues()
 847    {
 848  1 return "CSS1 selector";
 849    }
 850   
 851    /**
 852    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    * Parser for newline bytes. Allows lf|crlf|cr.
 862    */
 863    static class ParseNewLine implements ParseProperty
 864    {
 865   
 866    /**
 867    * @see org.w3c.tidy.ParseProperty#parse(java.lang.String, java.lang.String, org.w3c.tidy.Configuration)
 868    */
 869  2 public Object parse(String value, String option, Configuration configuration)
 870    {
 871    // lf|crlf|cr
 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    * @see org.w3c.tidy.ParseProperty#getType()
 893    */
 894  4 public String getType()
 895    {
 896  4 return "Enum";
 897    }
 898   
 899    /**
 900    * @see org.w3c.tidy.ParseProperty#getOptionValues()
 901    */
 902  1 public String getOptionValues()
 903    {
 904  1 return "lf, crlf, cr";
 905    }
 906   
 907    /**
 908    * @see org.w3c.tidy.ParseProperty#getFriendlyName(java.lang.String, java.lang.Object, Configuration)
 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    }