Clover coverage report - Maven Clover report
Coverage timestamp: Tue Aug 1 2006 15:09:51 CEST
file stats: LOC: 1,811   Methods: 28
NCLOC: 982   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Report.java 70.4% 70.8% 67.9% 70.6%
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.io.PrintWriter;
 57    import java.text.MessageFormat;
 58    import java.text.SimpleDateFormat;
 59    import java.util.Date;
 60    import java.util.MissingResourceException;
 61    import java.util.ResourceBundle;
 62   
 63    import org.w3c.tidy.TidyMessage.Level;
 64   
 65   
 66    /**
 67    * Error/informational message reporter. You should only need to edit the file TidyMessages.properties to localize HTML
 68    * tidy.
 69    * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
 70    * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
 71    * @author Fabrizio Giustina
 72    * @version $Revision: 779 $ ($Author: fgiust $)
 73    */
 74    public final class Report
 75    {
 76   
 77    /**
 78    * used to point to Web Accessibility Guidelines.
 79    */
 80    public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
 81   
 82    /**
 83    * Release date.
 84    */
 85    public static final Date RELEASE_DATE = new Date(1096227718000L);
 86   
 87    /**
 88    * Release date String.
 89    */
 90    public static final String RELEASE_DATE_STRING = new SimpleDateFormat("dd MMM yyyy").format(RELEASE_DATE);
 91   
 92    /**
 93    * invalid entity: missing semicolon.
 94    */
 95    public static final short MISSING_SEMICOLON = 1;
 96   
 97    /**
 98    * invalid entity: missing semicolon.
 99    */
 100    public static final short MISSING_SEMICOLON_NCR = 2;
 101   
 102    /**
 103    * invalid entity: unknown entity.
 104    */
 105    public static final short UNKNOWN_ENTITY = 3;
 106   
 107    /**
 108    * invalid entity: unescaped ampersand.
 109    */
 110    public static final short UNESCAPED_AMPERSAND = 4;
 111   
 112    /**
 113    * invalid entity: apos undefined in current definition.
 114    */
 115    public static final short APOS_UNDEFINED = 5;
 116   
 117    /**
 118    * missing an end tag.
 119    */
 120    public static final short MISSING_ENDTAG_FOR = 6;
 121   
 122    /**
 123    * missing end tag before.
 124    */
 125    public static final short MISSING_ENDTAG_BEFORE = 7;
 126   
 127    /**
 128    * discarding unexpected element.
 129    */
 130    public static final short DISCARDING_UNEXPECTED = 8;
 131   
 132    /**
 133    * nested emphasis.
 134    */
 135    public static final short NESTED_EMPHASIS = 9;
 136   
 137    /**
 138    * non matching end tag.
 139    */
 140    public static final short NON_MATCHING_ENDTAG = 10;
 141   
 142    /**
 143    * tag not allowed in.
 144    */
 145    public static final short TAG_NOT_ALLOWED_IN = 11;
 146   
 147    /**
 148    * missing start tag.
 149    */
 150    public static final short MISSING_STARTTAG = 12;
 151   
 152    /**
 153    * unexpected end tag.
 154    */
 155    public static final short UNEXPECTED_ENDTAG = 13;
 156   
 157    /**
 158    * unsing br in place of.
 159    */
 160    public static final short USING_BR_INPLACE_OF = 14;
 161   
 162    /**
 163    * inserting tag.
 164    */
 165    public static final short INSERTING_TAG = 15;
 166   
 167    /**
 168    * suspected missing quote.
 169    */
 170    public static final short SUSPECTED_MISSING_QUOTE = 16;
 171   
 172    /**
 173    * missing title element.
 174    */
 175    public static final short MISSING_TITLE_ELEMENT = 17;
 176   
 177    /**
 178    * duplicate frameset.
 179    */
 180    public static final short DUPLICATE_FRAMESET = 18;
 181   
 182    /**
 183    * elments can be nested.
 184    */
 185    public static final short CANT_BE_NESTED = 19;
 186   
 187    /**
 188    * obsolete element.
 189    */
 190    public static final short OBSOLETE_ELEMENT = 20;
 191   
 192    /**
 193    * proprietary element.
 194    */
 195    public static final short PROPRIETARY_ELEMENT = 21;
 196   
 197    /**
 198    * unknown element.
 199    */
 200    public static final short UNKNOWN_ELEMENT = 22;
 201   
 202    /**
 203    * trim empty element.
 204    */
 205    public static final short TRIM_EMPTY_ELEMENT = 23;
 206   
 207    /**
 208    * coerce to end tag.
 209    */
 210    public static final short COERCE_TO_ENDTAG = 24;
 211   
 212    /**
 213    * illegal nesting.
 214    */
 215    public static final short ILLEGAL_NESTING = 25;
 216   
 217    /**
 218    * noframes content.
 219    */
 220    public static final short NOFRAMES_CONTENT = 26;
 221   
 222    /**
 223    * content after body.
 224    */
 225    public static final short CONTENT_AFTER_BODY = 27;
 226   
 227    /**
 228    * inconsistent version.
 229    */
 230    public static final short INCONSISTENT_VERSION = 28;
 231   
 232    /**
 233    * malformed comment.
 234    */
 235    public static final short MALFORMED_COMMENT = 29;
 236   
 237    /**
 238    * bad coment chars.
 239    */
 240    public static final short BAD_COMMENT_CHARS = 30;
 241   
 242    /**
 243    * bad xml comment.
 244    */
 245    public static final short BAD_XML_COMMENT = 31;
 246   
 247    /**
 248    * bad cdata comment.
 249    */
 250    public static final short BAD_CDATA_CONTENT = 32;
 251   
 252    /**
 253    * inconsistent namespace.
 254    */
 255    public static final short INCONSISTENT_NAMESPACE = 33;
 256   
 257    /**
 258    * doctype after tags.
 259    */
 260    public static final short DOCTYPE_AFTER_TAGS = 34;
 261   
 262    /**
 263    * malformed doctype.
 264    */
 265    public static final short MALFORMED_DOCTYPE = 35;
 266   
 267    /**
 268    * unexpected end of file.
 269    */
 270    public static final short UNEXPECTED_END_OF_FILE = 36;
 271   
 272    /**
 273    * doctype not upper case.
 274    */
 275    public static final short DTYPE_NOT_UPPER_CASE = 37;
 276   
 277    /**
 278    * too many element.
 279    */
 280    public static final short TOO_MANY_ELEMENTS = 38;
 281   
 282    /**
 283    * unescaped element.
 284    */
 285    public static final short UNESCAPED_ELEMENT = 39;
 286   
 287    /**
 288    * nested quotation.
 289    */
 290    public static final short NESTED_QUOTATION = 40;
 291   
 292    /**
 293    * element not empty.
 294    */
 295    public static final short ELEMENT_NOT_EMPTY = 41;
 296   
 297    /**
 298    * encoding IO conflict.
 299    */
 300    public static final short ENCODING_IO_CONFLICT = 42;
 301   
 302    /**
 303    * mixed content in block.
 304    */
 305    public static final short MIXED_CONTENT_IN_BLOCK = 43;
 306   
 307    /**
 308    * missing doctype.
 309    */
 310    public static final short MISSING_DOCTYPE = 44;
 311   
 312    /**
 313    * space preceding xml declaration.
 314    */
 315    public static final short SPACE_PRECEDING_XMLDECL = 45;
 316   
 317    /**
 318    * too many elements in.
 319    */
 320    public static final short TOO_MANY_ELEMENTS_IN = 46;
 321   
 322    /**
 323    * unexpected endag in.
 324    */
 325    public static final short UNEXPECTED_ENDTAG_IN = 47;
 326   
 327    /**
 328    * replacing element.
 329    */
 330    public static final short REPLACING_ELEMENT = 83;
 331   
 332    /**
 333    * replacing unexcaped element.
 334    */
 335    public static final short REPLACING_UNEX_ELEMENT = 84;
 336   
 337    /**
 338    * coerce to endtag.
 339    */
 340    public static final short COERCE_TO_ENDTAG_WARN = 85;
 341   
 342    /**
 343    * attribute: unknown attribute.
 344    */
 345    public static final short UNKNOWN_ATTRIBUTE = 48;
 346   
 347    /**
 348    * attribute: missing attribute.
 349    */
 350    public static final short MISSING_ATTRIBUTE = 49;
 351   
 352    /**
 353    * attribute: missing attribute value.
 354    */
 355    public static final short MISSING_ATTR_VALUE = 50;
 356   
 357    /**
 358    * attribute: bad attribute value.
 359    */
 360    public static final short BAD_ATTRIBUTE_VALUE = 51;
 361   
 362    /**
 363    * attribute: unexpected gt.
 364    */
 365    public static final short UNEXPECTED_GT = 52;
 366   
 367    /**
 368    * attribute: proprietary attribute.
 369    */
 370    public static final short PROPRIETARY_ATTRIBUTE = 53;
 371   
 372    /**
 373    * attribute: proprietary attribute value.
 374    */
 375    public static final short PROPRIETARY_ATTR_VALUE = 54;
 376   
 377    /**
 378    * attribute: repeated attribute.
 379    */
 380    public static final short REPEATED_ATTRIBUTE = 55;
 381   
 382    /**
 383    * attribute: missing image map.
 384    */
 385    public static final short MISSING_IMAGEMAP = 56;
 386   
 387    /**
 388    * attribute: xml attribute value.
 389    */
 390    public static final short XML_ATTRIBUTE_VALUE = 57;
 391   
 392    /**
 393    * attribute: missing quotemark.
 394    */
 395    public static final short MISSING_QUOTEMARK = 58;
 396   
 397    /**
 398    * attribute: unexpected quotemark.
 399    */
 400    public static final short UNEXPECTED_QUOTEMARK = 59;
 401   
 402    /**
 403    * attribute: id and name mismatch.
 404    */
 405    public static final short ID_NAME_MISMATCH = 60;
 406   
 407    /**
 408    * attribute: backslash in URI.
 409    */
 410    public static final short BACKSLASH_IN_URI = 61;
 411   
 412    /**
 413    * attribute: fixed backslash.
 414    */
 415    public static final short FIXED_BACKSLASH = 62;
 416   
 417    /**
 418    * attribute: illegal URI reference.
 419    */
 420    public static final short ILLEGAL_URI_REFERENCE = 63;
 421   
 422    /**
 423    * attribute: escaped illegal URI.
 424    */
 425    public static final short ESCAPED_ILLEGAL_URI = 64;
 426   
 427    /**
 428    * attribute: newline in URI.
 429    */
 430    public static final short NEWLINE_IN_URI = 65;
 431   
 432    /**
 433    * attribute: anchor not unique.
 434    */
 435    public static final short ANCHOR_NOT_UNIQUE = 66;
 436   
 437    /**
 438    * attribute: entity in id.
 439    */
 440    public static final short ENTITY_IN_ID = 67;
 441   
 442    /**
 443    * attribute: joining attribute.
 444    */
 445    public static final short JOINING_ATTRIBUTE = 68;
 446   
 447    /**
 448    * attribute: expected equalsign.
 449    */
 450    public static final short UNEXPECTED_EQUALSIGN = 69;
 451   
 452    /**
 453    * attribute: attribute value not lower case.
 454    */
 455    public static final short ATTR_VALUE_NOT_LCASE = 70;
 456   
 457    /**
 458    * attribute: id sintax.
 459    */
 460    public static final short XML_ID_SYNTAX = 71;
 461   
 462    /**
 463    * attribute: invalid attribute.
 464    */
 465    public static final short INVALID_ATTRIBUTE = 72;
 466   
 467    /**
 468    * attribute: bad attribute value replaced.
 469    */
 470    public static final short BAD_ATTRIBUTE_VALUE_REPLACED = 73;
 471   
 472    /**
 473    * attribute: invalid xml id.
 474    */
 475    public static final short INVALID_XML_ID = 74;
 476   
 477    /**
 478    * attribute: unexpected end of file.
 479    */
 480    public static final short UNEXPECTED_END_OF_FILE_ATTR = 75;
 481   
 482    /**
 483    * character encoding: vendor specific chars.
 484    */
 485    public static final short VENDOR_SPECIFIC_CHARS = 76;
 486   
 487    /**
 488    * character encoding: invalid sgml chars.
 489    */
 490    public static final short INVALID_SGML_CHARS = 77;
 491   
 492    /**
 493    * character encoding: invalid utf8.
 494    */
 495    public static final short INVALID_UTF8 = 78;
 496   
 497    /**
 498    * character encoding: invalid utf16.
 499    */
 500    public static final short INVALID_UTF16 = 79;
 501   
 502    /**
 503    * character encoding: encoding mismatch.
 504    */
 505    public static final short ENCODING_MISMATCH = 80;
 506   
 507    /**
 508    * character encoding: nvalid URI.
 509    */
 510    public static final short INVALID_URI = 81;
 511   
 512    /**
 513    * character encoding: invalid NCR.
 514    */
 515    public static final short INVALID_NCR = 82;
 516   
 517    /**
 518    * Constant used for reporting of given doctype.
 519    */
 520    public static final short DOCTYPE_GIVEN_SUMMARY = 110;
 521   
 522    /**
 523    * Constant used for reporting of version summary.
 524    */
 525    public static final short REPORT_VERSION_SUMMARY = 111;
 526   
 527    /**
 528    * Constant used for reporting of bad access summary.
 529    */
 530    public static final short BADACCESS_SUMMARY = 112;
 531   
 532    /**
 533    * Constant used for reporting of bad form summary.
 534    */
 535    public static final short BADFORM_SUMMARY = 113;
 536   
 537    /**
 538    * accessibility flaw: missing image map.
 539    */
 540    public static final short MISSING_IMAGE_ALT = 1;
 541   
 542    /**
 543    * accessibility flaw: missing link alt.
 544    */
 545    public static final short MISSING_LINK_ALT = 2;
 546   
 547    /**
 548    * accessibility flaw: missing summary.
 549    */
 550    public static final short MISSING_SUMMARY = 4;
 551   
 552    /**
 553    * accessibility flaw: missing image map.
 554    */
 555    public static final short MISSING_IMAGE_MAP = 8;
 556   
 557    /**
 558    * accessibility flaw: using frames.
 559    */
 560    public static final short USING_FRAMES = 16;
 561   
 562    /**
 563    * accessibility flaw: using noframes.
 564    */
 565    public static final short USING_NOFRAMES = 32;
 566   
 567    /**
 568    * presentation flaw: using spacer.
 569    */
 570    public static final short USING_SPACER = 1;
 571   
 572    /**
 573    * presentation flaw: using layer.
 574    */
 575    public static final short USING_LAYER = 2;
 576   
 577    /**
 578    * presentation flaw: using nobr.
 579    */
 580    public static final short USING_NOBR = 4;
 581   
 582    /**
 583    * presentation flaw: using font.
 584    */
 585    public static final short USING_FONT = 8;
 586   
 587    /**
 588    * presentation flaw: using body.
 589    */
 590    public static final short USING_BODY = 16;
 591   
 592    /**
 593    * character encoding error: windows chars.
 594    */
 595    public static final short WINDOWS_CHARS = 1;
 596   
 597    /**
 598    * character encoding error: non ascii.
 599    */
 600    public static final short NON_ASCII = 2;
 601   
 602    /**
 603    * character encoding error: found utf16.
 604    */
 605    public static final short FOUND_UTF16 = 4;
 606   
 607    /**
 608    * char has been replaced.
 609    */
 610    public static final short REPLACED_CHAR = 0;
 611   
 612    /**
 613    * char has been discarder.
 614    */
 615    public static final short DISCARDED_CHAR = 1;
 616   
 617    /**
 618    * Resource bundle with messages.
 619    */
 620    private static ResourceBundle res;
 621   
 622    /**
 623    * Printed in GNU Emacs messages.
 624    */
 625    private String currentFile;
 626   
 627    /**
 628    * message listener for error reporting.
 629    */
 630    private TidyMessageListener listener;
 631   
 632    static
 633    {
 634  1 try
 635    {
 636  1 res = ResourceBundle.getBundle("org/w3c/tidy/TidyMessages");
 637    }
 638    catch (MissingResourceException e)
 639    {
 640  0 throw new Error(e.toString());
 641    }
 642    }
 643   
 644    /**
 645    * Instantiated only in Tidy() constructor.
 646    */
 647  299 protected Report()
 648    {
 649  299 super();
 650    }
 651   
 652    /**
 653    * Generates a complete message for the warning/error. The message is composed by:
 654    * <ul>
 655    * <li>position in file</li>
 656    * <li>prefix for the error level (warning: | error:)</li>
 657    * <li>message read from ResourceBundle</li>
 658    * <li>optional parameters added to message using MessageFormat</li>
 659    * </ul>
 660    * @param errorCode tidy error code
 661    * @param lexer Lexer
 662    * @param message key for the ResourceBundle
 663    * @param params optional parameters added with MessageFormat
 664    * @param level message level. One of <code>TidyMessage.LEVEL_ERROR</code>,
 665    * <code>TidyMessage.LEVEL_WARNING</code>,<code>TidyMessage.LEVEL_INFO</code>
 666    * @return formatted message
 667    * @throws MissingResourceException if <code>message</code> key is not available in jtidy resource bundle.
 668    * @see TidyMessage
 669    */
 670  2524 protected String getMessage(int errorCode, Lexer lexer, String message, Object[] params, Level level)
 671    throws MissingResourceException
 672    {
 673  2524 String resource;
 674  2524 resource = res.getString(message);
 675   
 676  2524 String position;
 677   
 678  2524 if (lexer != null && level != Level.SUMMARY)
 679    {
 680  1613 position = getPosition(lexer);
 681    }
 682    else
 683    {
 684  911 position = "";
 685    }
 686   
 687  2524 String prefix;
 688   
 689  2524 if (level == Level.ERROR)
 690    {
 691  39 prefix = res.getString("error");
 692    }
 693  2485 else if (level == Level.WARNING)
 694    {
 695  1547 prefix = res.getString("warning");
 696    }
 697    else
 698    {
 699  938 prefix = "";
 700    }
 701   
 702  2524 String messageString;
 703   
 704  2524 if (params != null)
 705    {
 706  2187 messageString = MessageFormat.format(resource, params);
 707    }
 708    else
 709    {
 710  337 messageString = resource;
 711    }
 712   
 713  2524 if (listener != null)
 714    {
 715  2375 TidyMessage msg = new TidyMessage(errorCode, (lexer != null) ? lexer.lines : 0, (lexer != null)
 716    ? lexer.columns
 717    : 0, level, messageString);
 718  2375 listener.messageReceived(msg);
 719    }
 720   
 721  2524 return position + prefix + messageString;
 722    }
 723   
 724    /**
 725    * Prints a message to lexer.errout after calling getMessage().
 726    * @param errorCode tidy error code
 727    * @param lexer Lexer
 728    * @param message key for the ResourceBundle
 729    * @param params optional parameters added with MessageFormat
 730    * @param level message level. One of <code>TidyMessage.LEVEL_ERROR</code>,
 731    * <code>TidyMessage.LEVEL_WARNING</code>,<code>TidyMessage.LEVEL_INFO</code>
 732    * @see TidyMessage
 733    */
 734  1991 private void printMessage(int errorCode, Lexer lexer, String message, Object[] params, Level level)
 735    {
 736  1991 String resource;
 737  1991 try
 738    {
 739  1991 resource = getMessage(errorCode, lexer, message, params, level);
 740    }
 741    catch (MissingResourceException e)
 742    {
 743  0 lexer.errout.println(e.toString());
 744  0 return;
 745    }
 746   
 747  1991 lexer.errout.println(resource);
 748    }
 749   
 750    /**
 751    * Prints a message to errout after calling getMessage(). Used when lexer is not yet defined.
 752    * @param errout PrintWriter
 753    * @param message key for the ResourceBundle
 754    * @param params optional parameters added with MessageFormat
 755    * @param level message level. One of <code>TidyMessage.LEVEL_ERROR</code>,
 756    * <code>TidyMessage.LEVEL_WARNING</code>,<code>TidyMessage.LEVEL_INFO</code>
 757    * @see TidyMessage
 758    */
 759  481 private void printMessage(PrintWriter errout, String message, Object[] params, Level level)
 760    {
 761  481 String resource;
 762  481 try
 763    {
 764  481 resource = getMessage(-1, null, message, params, level);
 765    }
 766    catch (MissingResourceException e)
 767    {
 768  0 errout.println(e.toString());
 769  0 return;
 770    }
 771  481 errout.println(resource);
 772    }
 773   
 774    /**
 775    * print version information.
 776    * @param p printWriter
 777    */
 778  0 public void showVersion(PrintWriter p)
 779    {
 780  0 printMessage(p, "version_summary", new Object[]{RELEASE_DATE}, Level.SUMMARY);
 781    }
 782   
 783    /**
 784    * Returns a formatted tag name handling start and ent tags, nulls, doctypes, and text.
 785    * @param tag Node
 786    * @return formatted tag name
 787    */
 788  713 private String getTagName(Node tag)
 789    {
 790  713 if (tag != null)
 791    {
 792  713 if (tag.type == Node.START_TAG)
 793    {
 794  603 return "<" + tag.element + ">";
 795    }
 796  110 else if (tag.type == Node.END_TAG)
 797    {
 798  93 return "</" + tag.element + ">";
 799    }
 800  17 else if (tag.type == Node.DOCTYPE_TAG)
 801    {
 802  0 return "<!DOCTYPE>";
 803    }
 804  17 else if (tag.type == Node.TEXT_NODE)
 805    {
 806  4 return "plain text";
 807    }
 808    else
 809    {
 810  13 return tag.element;
 811    }
 812    }
 813  0 return "";
 814    }
 815   
 816    /**
 817    * Prints an "unknown option" error message. Lexer is not defined when this is called.
 818    * @param option unknown option name
 819    */
 820  0 public void unknownOption(String option)
 821    {
 822  0 try
 823    {
 824  0 System.err.println(MessageFormat.format(res.getString("unknown_option"), new Object[]{option}));
 825    }
 826    catch (MissingResourceException e)
 827    {
 828  0 System.err.println(e.toString());
 829    }
 830    }
 831   
 832    /**
 833    * Prints a "bad argument" error message. Lexer is not defined when this is called.
 834    * @param key argument name
 835    * @param value bad argument value
 836    */
 837  0 public void badArgument(String key, String value)
 838    {
 839  0 try
 840    {
 841  0 System.err.println(MessageFormat.format(res.getString("bad_argument"), new Object[]{value, key}));
 842    }
 843    catch (MissingResourceException e)
 844    {
 845  0 System.err.println(e.toString());
 846    }
 847    }
 848   
 849    /**
 850    * Returns a formatted String describing the current position in file.
 851    * @param lexer Lexer
 852    * @return String position ("line:column")
 853    */
 854  1613 private String getPosition(Lexer lexer)
 855    {
 856  1613 try
 857    {
 858    // Change formatting to be parsable by GNU Emacs
 859  1613 if (lexer.configuration.emacs)
 860    {
 861  0 return MessageFormat.format(res.getString("emacs_format"), new Object[]{
 862    this.currentFile,
 863    new Integer(lexer.lines),
 864    new Integer(lexer.columns)})
 865    + " ";
 866    }
 867    // traditional format
 868  1613 return MessageFormat.format(res.getString("line_column"), new Object[]{
 869    new Integer(lexer.lines),
 870    new Integer(lexer.columns)});
 871   
 872    }
 873    catch (MissingResourceException e)
 874    {
 875  0 lexer.errout.println(e.toString());
 876    }
 877  0 return "";
 878    }
 879   
 880    /**
 881    * Prints encoding error messages.
 882    * @param lexer Lexer
 883    * @param code error code
 884    * @param c invalid char
 885    */
 886  0 public void encodingError(Lexer lexer, int code, int c)
 887    {
 888  0 lexer.warnings++;
 889   
 890  0 if (lexer.errors > lexer.configuration.showErrors) // keep quiet after <showErrors> errors
 891    {
 892  0 return;
 893    }
 894   
 895  0 if (lexer.configuration.showWarnings)
 896    {
 897  0 String buf = Integer.toHexString(c);
 898   
 899    // An encoding mismatch is currently treated as a non-fatal error
 900  0 if ((code & ~DISCARDED_CHAR) == ENCODING_MISMATCH)
 901    {
 902    // actual encoding passed in "c"
 903  0 lexer.badChars |= ENCODING_MISMATCH;
 904  0 printMessage(
 905    code,
 906    lexer,
 907    "encoding_mismatch",
 908    new Object[]{
 909    lexer.configuration.getInCharEncodingName(),
 910    ParsePropertyImpl.CHAR_ENCODING.getFriendlyName(null, new Integer(c), lexer.configuration)},
 911    Level.WARNING);
 912    }
 913  0 else if ((code & ~DISCARDED_CHAR) == VENDOR_SPECIFIC_CHARS)
 914    {
 915  0 lexer.badChars |= VENDOR_SPECIFIC_CHARS;
 916  0 printMessage(
 917    code,
 918    lexer,
 919    "invalid_char",
 920    new Object[]{new Integer(code & DISCARDED_CHAR), buf},
 921    Level.WARNING);
 922    }
 923  0 else if ((code & ~DISCARDED_CHAR) == INVALID_SGML_CHARS)
 924    {
 925  0 lexer.badChars |= INVALID_SGML_CHARS;
 926  0 printMessage(
 927    code,
 928    lexer,
 929    "invalid_char",
 930    new Object[]{new Integer(code & DISCARDED_CHAR), buf},
 931    Level.WARNING);
 932    }
 933  0 else if ((code & ~DISCARDED_CHAR) == INVALID_UTF8)
 934    {
 935  0 lexer.badChars |= INVALID_UTF8;
 936  0 printMessage(
 937    code,
 938    lexer,
 939    "invalid_utf8",
 940    new Object[]{new Integer(code & DISCARDED_CHAR), buf},
 941    Level.WARNING);
 942    }
 943   
 944  0 else if ((code & ~DISCARDED_CHAR) == INVALID_UTF16)
 945    {
 946  0 lexer.badChars |= INVALID_UTF16;
 947  0 printMessage(
 948    code,
 949    lexer,
 950    "invalid_utf16",
 951    new Object[]{new Integer(code & DISCARDED_CHAR), buf},
 952    Level.WARNING);
 953   
 954    }
 955   
 956  0 else if ((code & ~DISCARDED_CHAR) == INVALID_NCR)
 957    {
 958  0 lexer.badChars |= INVALID_NCR;
 959  0 printMessage(
 960    code,
 961    lexer,
 962    "invalid_ncr",
 963    new Object[]{new Integer(code & DISCARDED_CHAR), buf},
 964    Level.WARNING);
 965    }
 966   
 967    }
 968    }
 969   
 970    /**
 971    * Prints entity error messages.
 972    * @param lexer Lexer
 973    * @param code error code
 974    * @param entity invalid entity String
 975    * @param c invalid char
 976    */
 977  566 public void entityError(Lexer lexer, short code, String entity, int c)
 978    {
 979  566 lexer.warnings++;
 980   
 981  566 if (lexer.errors > lexer.configuration.showErrors) // keep quiet after <showErrors> errors
 982    {
 983  0 return;
 984    }
 985   
 986  566 if (lexer.configuration.showWarnings)
 987    {
 988  556 switch (code)
 989    {
 990  201 case MISSING_SEMICOLON :
 991  201 printMessage(code, lexer, "missing_semicolon", new Object[]{entity}, Level.WARNING);
 992  201 break;
 993  0 case MISSING_SEMICOLON_NCR :
 994  0 printMessage(code, lexer, "missing_semicolon_ncr", new Object[]{entity}, Level.WARNING);
 995  0 break;
 996  336 case UNKNOWN_ENTITY :
 997  336 printMessage(code, lexer, "unknown_entity", new Object[]{entity}, Level.WARNING);
 998  336 break;
 999  17 case UNESCAPED_AMPERSAND :
 1000  17 printMessage(code, lexer, "unescaped_ampersand", null, Level.WARNING);
 1001  17 break;
 1002  2 case APOS_UNDEFINED :
 1003  2 printMessage(code, lexer, "apos_undefined", null, Level.WARNING);
 1004  2 break;
 1005  0 default :
 1006    // should not reach here
 1007  0 break;
 1008    }
 1009    }
 1010    }
 1011   
 1012    /**
 1013    * Prints error messages for attributes.
 1014    * @param lexer Lexer
 1015    * @param node current tag
 1016    * @param attribute attribute
 1017    * @param code error code
 1018    */
 1019  507 public void attrError(Lexer lexer, Node node, AttVal attribute, short code)
 1020    {
 1021  507 if (code == UNEXPECTED_GT)
 1022    {
 1023  8 lexer.errors++;
 1024    }
 1025    else
 1026    {
 1027  499 lexer.warnings++;
 1028    }
 1029   
 1030  507 if (lexer.errors > lexer.configuration.showErrors) // keep quiet after <showErrors> errors
 1031    {
 1032  139 return;
 1033    }
 1034   
 1035  368 if (code == UNEXPECTED_GT) // error
 1036    {
 1037  6 printMessage(code, lexer, "unexpected_gt", new Object[]{getTagName(node)}, Level.ERROR);
 1038    }
 1039   
 1040  368 if (!lexer.configuration.showWarnings) // warnings
 1041    {
 1042  3 return;
 1043    }
 1044   
 1045  365 switch (code)
 1046    {
 1047  32 case UNKNOWN_ATTRIBUTE :
 1048  32 printMessage(code, lexer, "unknown_attribute", new Object[]{attribute.attribute}, Level.WARNING);
 1049  32 break;
 1050   
 1051  73 case MISSING_ATTRIBUTE :
 1052  73 printMessage(
 1053    code,
 1054    lexer,
 1055    "missing_attribute",
 1056    new Object[]{getTagName(node), attribute.attribute},
 1057    Level.WARNING);
 1058  73 break;
 1059   
 1060  4 case MISSING_ATTR_VALUE :
 1061  4 printMessage(
 1062    code,
 1063    lexer,
 1064    "missing_attr_value",
 1065    new Object[]{getTagName(node), attribute.attribute},
 1066    Level.WARNING);
 1067  4 break;
 1068   
 1069  0 case MISSING_IMAGEMAP :
 1070  0 printMessage(code, lexer, "missing_imagemap", new Object[]{getTagName(node)}, Level.WARNING);
 1071  0 lexer.badAccess |= MISSING_IMAGE_MAP;
 1072  0 break;
 1073   
 1074  30 case BAD_ATTRIBUTE_VALUE :
 1075  30 printMessage(code, lexer, "bad_attribute_value", new Object[]{
 1076    getTagName(node),
 1077    attribute.attribute,
 1078    attribute.value}, Level.WARNING);
 1079  30 break;
 1080   
 1081  2 case XML_ID_SYNTAX :
 1082  2 printMessage(
 1083    code,
 1084    lexer,
 1085    "xml_id_sintax",
 1086    new Object[]{getTagName(node), attribute.attribute},
 1087    Level.WARNING);
 1088  2 break;
 1089   
 1090  1 case XML_ATTRIBUTE_VALUE :
 1091  1 printMessage(
 1092    code,
 1093    lexer,
 1094    "xml_attribute_value",
 1095    new Object[]{getTagName(node), attribute.attribute},
 1096    Level.WARNING);
 1097  1 break;
 1098   
 1099  6 case UNEXPECTED_QUOTEMARK :
 1100  6 printMessage(code, lexer, "unexpected_quotemark", new Object[]{getTagName(node)}, Level.WARNING);
 1101  6 break;
 1102   
 1103  9 case MISSING_QUOTEMARK :
 1104  9 printMessage(code, lexer, "missing_quotemark", new Object[]{getTagName(node)}, Level.WARNING);
 1105  9 break;
 1106   
 1107  4 case REPEATED_ATTRIBUTE :
 1108  4 printMessage(code, lexer, "repeated_attribute", new Object[]{
 1109    getTagName(node),
 1110    attribute.value,
 1111    attribute.attribute}, Level.WARNING);
 1112  4 break;
 1113   
 1114  26 case PROPRIETARY_ATTR_VALUE :
 1115  26 printMessage(
 1116    code,
 1117    lexer,
 1118    "proprietary_attr_value",
 1119    new Object[]{getTagName(node), attribute.value},
 1120    Level.WARNING);
 1121  26 break;
 1122   
 1123  10 case PROPRIETARY_ATTRIBUTE :
 1124  10 printMessage(
 1125    code,
 1126    lexer,
 1127    "proprietary_attribute",
 1128    new Object[]{getTagName(node), attribute.attribute},
 1129    Level.WARNING);
 1130  10 break;
 1131   
 1132  1 case UNEXPECTED_END_OF_FILE :
 1133    // on end of file adjust reported position to end of input
 1134  1 lexer.lines = lexer.in.getCurline();
 1135  1 lexer.columns = lexer.in.getCurcol();
 1136  1 printMessage(code, lexer, "unexpected_end_of_file", new Object[]{getTagName(node)}, Level.WARNING);
 1137  1 break;
 1138   
 1139  0 case ID_NAME_MISMATCH :
 1140  0 printMessage(code, lexer, "id_name_mismatch", new Object[]{getTagName(node)}, Level.WARNING);
 1141  0 break;
 1142   
 1143  0 case BACKSLASH_IN_URI :
 1144  0 printMessage(code, lexer, "backslash_in_uri", new Object[]{getTagName(node)}, Level.WARNING);
 1145  0 break;
 1146   
 1147  5 case FIXED_BACKSLASH :
 1148  5 printMessage(code, lexer, "fixed_backslash", new Object[]{getTagName(node)}, Level.WARNING);
 1149  5 break;
 1150   
 1151  0 case ILLEGAL_URI_REFERENCE :
 1152  0 printMessage(code, lexer, "illegal_uri_reference", new Object[]{getTagName(node)}, Level.WARNING);
 1153  0 break;
 1154   
 1155  129 case ESCAPED_ILLEGAL_URI :
 1156  129 printMessage(code, lexer, "escaped_illegal_uri", new Object[]{getTagName(node)}, Level.WARNING);
 1157  129 break;
 1158   
 1159  8 case NEWLINE_IN_URI :
 1160  8 printMessage(code, lexer, "newline_in_uri", new Object[]{getTagName(node)}, Level.WARNING);
 1161  8 break;
 1162   
 1163  15 case ANCHOR_NOT_UNIQUE :
 1164  15 printMessage(
 1165    code,
 1166    lexer,
 1167    "anchor_not_unique",
 1168    new Object[]{getTagName(node), attribute.value},
 1169    Level.WARNING);
 1170  15 break;
 1171   
 1172  0 case ENTITY_IN_ID :
 1173  0 printMessage(code, lexer, "entity_in_id", null, Level.WARNING);
 1174  0 break;
 1175   
 1176  1 case JOINING_ATTRIBUTE :
 1177  1 printMessage(
 1178    code,
 1179    lexer,
 1180    "joining_attribute",
 1181    new Object[]{getTagName(node), attribute.attribute},
 1182    Level.WARNING);
 1183  1 break;
 1184   
 1185  1 case UNEXPECTED_EQUALSIGN :
 1186  1 printMessage(code, lexer, "expected_equalsign", new Object[]{getTagName(node)}, Level.WARNING);
 1187  1 break;
 1188   
 1189  2 case ATTR_VALUE_NOT_LCASE :
 1190  2 printMessage(code, lexer, "attr_value_not_lcase", new Object[]{
 1191    getTagName(node),
 1192    attribute.value,
 1193    attribute.attribute}, Level.WARNING);
 1194  2 break;
 1195   
 1196  6 default :
 1197  6 break;
 1198    }
 1199    }
 1200   
 1201    /**
 1202    * Prints warnings.
 1203    * @param lexer Lexer
 1204    * @param element parent/missing tag
 1205    * @param node current tag
 1206    * @param code error code
 1207    */
 1208  750 public void warning(Lexer lexer, Node element, Node node, short code)
 1209    {
 1210   
 1211  750 TagTable tt = lexer.configuration.tt;
 1212  750 if (!((code == DISCARDING_UNEXPECTED) && lexer.badForm != 0)) // lexer->errors++; already done in BadForm()
 1213    {
 1214  741 lexer.warnings++;
 1215    }
 1216   
 1217    // keep quiet after <showErrors> errors
 1218  750 if (lexer.errors > lexer.configuration.showErrors)
 1219    {
 1220  119 return;
 1221    }
 1222   
 1223  631 if (lexer.configuration.showWarnings)
 1224    {
 1225  627 switch (code)
 1226    {
 1227  18 case MISSING_ENDTAG_FOR :
 1228  18 printMessage(code, lexer, "missing_endtag_for", new Object[]{element.element}, Level.WARNING);
 1229  18 break;
 1230   
 1231  69 case MISSING_ENDTAG_BEFORE :
 1232  69 printMessage(
 1233    code,
 1234    lexer,
 1235    "missing_endtag_before",
 1236    new Object[]{element.element, getTagName(node)},
 1237    Level.WARNING);
 1238  69 break;
 1239   
 1240  104 case DISCARDING_UNEXPECTED :
 1241  104 if (lexer.badForm == 0)
 1242    {
 1243    // the case for when this is an error not a warning, is handled later
 1244  95 printMessage(
 1245    code,
 1246    lexer,
 1247    "discarding_unexpected",
 1248    new Object[]{getTagName(node)},
 1249    Level.WARNING);
 1250    }
 1251  104 break;
 1252   
 1253  22 case NESTED_EMPHASIS :
 1254  22 printMessage(code, lexer, "nested_emphasis", new Object[]{getTagName(node)}, Level.INFO);
 1255  22 break;
 1256   
 1257  5 case COERCE_TO_ENDTAG :
 1258  5 printMessage(code, lexer, "coerce_to_endtag", new Object[]{element.element}, Level.INFO);
 1259  5 break;
 1260   
 1261  4 case NON_MATCHING_ENDTAG :
 1262  4 printMessage(
 1263    code,
 1264    lexer,
 1265    "non_matching_endtag",
 1266    new Object[]{getTagName(node), element.element},
 1267    Level.WARNING);
 1268  4 break;
 1269   
 1270  31 case TAG_NOT_ALLOWED_IN :
 1271  31 printMessage(
 1272    code,
 1273    lexer,
 1274    "tag_not_allowed_in",
 1275    new Object[]{getTagName(node), element.element},
 1276    Level.WARNING);
 1277  31 break;
 1278   
 1279  2 case DOCTYPE_AFTER_TAGS :
 1280  2 printMessage(code, lexer, "doctype_after_tags", null, Level.WARNING);
 1281  2 break;
 1282   
 1283  10 case MISSING_STARTTAG :
 1284  10 printMessage(code, lexer, "missing_starttag", new Object[]{node.element}, Level.WARNING);
 1285  10 break;
 1286   
 1287  1 case UNEXPECTED_ENDTAG :
 1288  1 if (element != null)
 1289    {
 1290  0 printMessage(
 1291    code,
 1292    lexer,
 1293    "unexpected_endtag_in",
 1294    new Object[]{node.element, element.element},
 1295    Level.WARNING);
 1296    }
 1297    else
 1298    {
 1299  1 printMessage(code, lexer, "unexpected_endtag", new Object[]{node.element}, Level.WARNING);
 1300    }
 1301  1 break;
 1302   
 1303  0 case TOO_MANY_ELEMENTS :
 1304  0 if (element != null)
 1305    {
 1306  0 printMessage(
 1307    code,
 1308    lexer,
 1309    "too_many_elements_in",
 1310    new Object[]{node.element, element.element},
 1311    Level.WARNING);
 1312    }
 1313    else
 1314    {
 1315  0 printMessage(code, lexer, "too_many_elements", new Object[]{node.element}, Level.WARNING);
 1316    }
 1317  0 break;
 1318   
 1319  0 case USING_BR_INPLACE_OF :
 1320  0 printMessage(code, lexer, "using_br_inplace_of", new Object[]{getTagName(node)}, Level.WARNING);
 1321  0 break;
 1322   
 1323  95 case INSERTING_TAG :
 1324  95 printMessage(code, lexer, "inserting_tag", new Object[]{node.element}, Level.WARNING);
 1325  95 break;
 1326   
 1327  0 case CANT_BE_NESTED :
 1328  0 printMessage(code, lexer, "cant_be_nested", new Object[]{getTagName(node)}, Level.WARNING);
 1329  0 break;
 1330   
 1331  22 case PROPRIETARY_ELEMENT :
 1332  22 printMessage(code, lexer, "proprietary_element", new Object[]{getTagName(node)}, Level.WARNING);
 1333   
 1334  22 if (node.tag == tt.tagLayer)
 1335    {
 1336  0 lexer.badLayout |= USING_LAYER;
 1337    }
 1338  22 else if (node.tag == tt.tagSpacer)
 1339    {
 1340  0 lexer.badLayout |= USING_SPACER;
 1341    }
 1342  22 else if (node.tag == tt.tagNobr)
 1343    {
 1344  1 lexer.badLayout |= USING_NOBR;
 1345    }
 1346  22 break;
 1347   
 1348  16 case OBSOLETE_ELEMENT :
 1349  16 if (element.tag != null && (element.tag.model & Dict.CM_OBSOLETE) != 0)
 1350    {
 1351  0 printMessage(code, lexer, "obsolete_element", new Object[]{
 1352    getTagName(element),
 1353    getTagName(node)}, Level.WARNING);
 1354    }
 1355    else
 1356    {
 1357  16 printMessage(code, lexer, "replacing_element", new Object[]{
 1358    getTagName(element),
 1359    getTagName(node)}, Level.WARNING);
 1360    }
 1361  16 break;
 1362   
 1363  4 case UNESCAPED_ELEMENT :
 1364  4 printMessage(code, lexer, "unescaped_element", new Object[]{getTagName(element)}, Level.WARNING);
 1365  4 break;
 1366   
 1367  75 case TRIM_EMPTY_ELEMENT :
 1368  75 printMessage(code, lexer, "trim_empty_element", new Object[]{getTagName(element)}, Level.WARNING);
 1369  75 break;
 1370   
 1371  8 case MISSING_TITLE_ELEMENT :
 1372  8 printMessage(code, lexer, "missing_title_element", null, Level.WARNING);
 1373  8 break;
 1374   
 1375  1 case ILLEGAL_NESTING :
 1376  1 printMessage(code, lexer, "illegal_nesting", new Object[]{getTagName(element)}, Level.WARNING);
 1377  1 break;
 1378   
 1379  1 case NOFRAMES_CONTENT :
 1380  1 printMessage(code, lexer, "noframes_content", new Object[]{getTagName(node)}, Level.WARNING);
 1381  1 break;
 1382   
 1383  8 case INCONSISTENT_VERSION :
 1384  8 printMessage(code, lexer, "inconsistent_version", null, Level.WARNING);
 1385  8 break;
 1386   
 1387  0 case MALFORMED_DOCTYPE :
 1388  0 printMessage(code, lexer, "malformed_doctype", null, Level.WARNING);
 1389  0 break;
 1390   
 1391  4 case CONTENT_AFTER_BODY :
 1392  4 printMessage(code, lexer, "content_after_body", null, Level.WARNING);
 1393  4 break;
 1394   
 1395  9 case MALFORMED_COMMENT :
 1396  9 printMessage(code, lexer, "malformed_comment", null, Level.WARNING);
 1397  9 break;
 1398   
 1399  0 case BAD_COMMENT_CHARS :
 1400  0 printMessage(code, lexer, "bad_comment_chars", null, Level.WARNING);
 1401  0 break;
 1402   
 1403  0 case BAD_XML_COMMENT :
 1404  0 printMessage(code, lexer, "bad_xml_comment", null, Level.WARNING);
 1405  0 break;
 1406   
 1407  14 case BAD_CDATA_CONTENT :
 1408  14 printMessage(code, lexer, "bad_cdata_content", null, Level.WARNING);
 1409  14 break;
 1410   
 1411  0 case INCONSISTENT_NAMESPACE :
 1412  0 printMessage(code, lexer, "inconsistent_namespace", null, Level.WARNING);
 1413  0 break;
 1414   
 1415  0 case DTYPE_NOT_UPPER_CASE :
 1416  0 printMessage(code, lexer, "dtype_not_upper_case", null, Level.WARNING);
 1417  0 break;
 1418   
 1419  0 case UNEXPECTED_END_OF_FILE :
 1420    // on end of file adjust reported position to end of input
 1421  0 lexer.lines = lexer.in.getCurline();
 1422  0 lexer.columns = lexer.in.getCurcol();
 1423  0 printMessage(
 1424    code,
 1425    lexer,
 1426    "unexpected_end_of_file",
 1427    new Object[]{getTagName(element)},
 1428    Level.WARNING);
 1429  0 break;
 1430   
 1431  1 case NESTED_QUOTATION :
 1432  1 printMessage(code, lexer, "nested_quotation", null, Level.WARNING);
 1433  1 break;
 1434   
 1435  0 case ELEMENT_NOT_EMPTY :
 1436  0 printMessage(code, lexer, "element_not_empty", new Object[]{getTagName(element)}, Level.WARNING);
 1437  0 break;
 1438   
 1439  103 case MISSING_DOCTYPE :
 1440  103 printMessage(code, lexer, "missing_doctype", null, Level.WARNING);
 1441  103 break;
 1442   
 1443  0 default :
 1444  0 break;
 1445    }
 1446    }
 1447   
 1448  631 if ((code == DISCARDING_UNEXPECTED) && lexer.badForm != 0)
 1449    {
 1450    // the case for when this is a warning not an error, is handled earlier
 1451  9 printMessage(code, lexer, "discarding_unexpected", new Object[]{getTagName(node)}, Level.ERROR);
 1452    }
 1453   
 1454    }
 1455   
 1456    /**
 1457    * Prints errors.
 1458    * @param lexer Lexer
 1459    * @param element parent/missing tag
 1460    * @param node current tag
 1461    * @param code error code
 1462    */
 1463  28 public void error(Lexer lexer, Node element, Node node, short code)
 1464    {
 1465  28 lexer.errors++;
 1466   
 1467    // keep quiet after <showErrors> errors
 1468  28 if (lexer.errors > lexer.configuration.showErrors)
 1469    {
 1470  12 return;
 1471    }
 1472   
 1473  16 if (code == SUSPECTED_MISSING_QUOTE)
 1474    {
 1475  0 printMessage(code, lexer, "suspected_missing_quote", null, Level.ERROR);
 1476    }
 1477  16 else if (code == DUPLICATE_FRAMESET)
 1478    {
 1479  0 printMessage(code, lexer, "duplicate_frameset", null, Level.ERROR);
 1480    }
 1481  16 else if (code == UNKNOWN_ELEMENT)
 1482    {
 1483  15 printMessage(code, lexer, "unknown_element", new Object[]{getTagName(node)}, Level.ERROR);
 1484    }
 1485  1 else if (code == UNEXPECTED_ENDTAG)
 1486    {
 1487  1 if (element != null)
 1488    {
 1489  1 printMessage(
 1490    code,
 1491    lexer,
 1492    "unexpected_endtag_in",
 1493    new Object[]{node.element, element.element},
 1494    Level.ERROR);
 1495    }
 1496    else
 1497    {
 1498  0 printMessage(code, lexer, "unexpected_endtag", new Object[]{node.element}, Level.ERROR);
 1499    }
 1500    }
 1501    }
 1502   
 1503    /**
 1504    * Prints error summary.
 1505    * @param lexer Lexer
 1506    */
 1507  231 public void errorSummary(Lexer lexer)
 1508    {
 1509    // adjust badAccess to that its null if frames are ok
 1510  231 if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0)
 1511    {
 1512  8 if (!(((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0)))
 1513    {
 1514  5 lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
 1515    }
 1516    }
 1517  231 if (lexer.badChars != 0)
 1518    {
 1519  7 if ((lexer.badChars & VENDOR_SPECIFIC_CHARS) != 0)
 1520    {
 1521  7 int encodingChoiche = 0;
 1522   
 1523  7 if ("Cp1252".equals(lexer.configuration.getInCharEncodingName()))
 1524    {
 1525  0 encodingChoiche = 1;
 1526    }
 1527  7 else if ("MacRoman".equals(lexer.configuration.getInCharEncodingName()))
 1528    {
 1529  0 encodingChoiche = 2;
 1530    }
 1531   
 1532  7 printMessage(VENDOR_SPECIFIC_CHARS, lexer, "vendor_specific_chars_summary", new Object[]{new Integer(
 1533    encodingChoiche)}, Level.SUMMARY);
 1534    }
 1535   
 1536  7 if ((lexer.badChars & INVALID_SGML_CHARS) != 0 || (lexer.badChars & INVALID_NCR) != 0)
 1537    {
 1538  7 int encodingChoiche = 0;
 1539   
 1540  7 if ("Cp1252".equals(lexer.configuration.getInCharEncodingName()))
 1541    {
 1542  0 encodingChoiche = 1;
 1543    }
 1544  7 else if ("MacRoman".equals(lexer.configuration.getInCharEncodingName()))
 1545    {
 1546  0 encodingChoiche = 2;
 1547    }
 1548   
 1549  7 printMessage(INVALID_SGML_CHARS, lexer, "invalid_sgml_chars_summary", new Object[]{new Integer(
 1550    encodingChoiche)}, Level.SUMMARY);
 1551    }
 1552   
 1553  7 if ((lexer.badChars & INVALID_UTF8) != 0)
 1554    {
 1555  7 printMessage(INVALID_UTF8, lexer, "invalid_utf8_summary", null, Level.SUMMARY);
 1556    }
 1557   
 1558  7 if ((lexer.badChars & INVALID_UTF16) != 0)
 1559    {
 1560  7 printMessage(INVALID_UTF16, lexer, "invalid_utf16_summary", null, Level.SUMMARY);
 1561    }
 1562   
 1563  7 if ((lexer.badChars & INVALID_URI) != 0)
 1564    {
 1565  7 printMessage(INVALID_URI, lexer, "invaliduri_summary", null, Level.SUMMARY);
 1566    }
 1567    }
 1568   
 1569  231 if (lexer.badForm != 0)
 1570    {
 1571  3 printMessage(BADFORM_SUMMARY, lexer, "badform_summary", null, Level.SUMMARY);
 1572    }
 1573   
 1574  231 if (lexer.badAccess != 0)
 1575    {
 1576  19 if ((lexer.badAccess & MISSING_SUMMARY) != 0)
 1577    {
 1578  12 printMessage(MISSING_SUMMARY, lexer, "badaccess_missing_summary", null, Level.SUMMARY);
 1579    }
 1580   
 1581  19 if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0)
 1582    {
 1583  7 printMessage(MISSING_IMAGE_ALT, lexer, "badaccess_missing_image_alt", null, Level.SUMMARY);
 1584    }
 1585   
 1586  19 if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0)
 1587    {
 1588  0 printMessage(MISSING_IMAGE_MAP, lexer, "badaccess_missing_image_map", null, Level.SUMMARY);
 1589    }
 1590   
 1591  19 if ((lexer.badAccess & MISSING_LINK_ALT) != 0)
 1592    {
 1593  0 printMessage(MISSING_LINK_ALT, lexer, "badaccess_missing_link_alt", null, Level.SUMMARY);
 1594    }
 1595   
 1596  19 if (((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0))
 1597    {
 1598  3 printMessage(USING_FRAMES, lexer, "badaccess_frames", null, Level.SUMMARY);
 1599    }
 1600   
 1601  19 printMessage(BADACCESS_SUMMARY, lexer, "badaccess_summary", new Object[]{ACCESS_URL}, Level.SUMMARY);
 1602    }
 1603   
 1604  231 if (lexer.badLayout != 0)
 1605    {
 1606  21 if ((lexer.badLayout & USING_LAYER) != 0)
 1607    {
 1608  0 printMessage(USING_LAYER, lexer, "badlayout_using_layer", null, Level.SUMMARY);
 1609    }
 1610   
 1611  21 if ((lexer.badLayout & USING_SPACER) != 0)
 1612    {
 1613  0 printMessage(USING_SPACER, lexer, "badlayout_using_spacer", null, Level.SUMMARY);
 1614    }
 1615   
 1616  21 if ((lexer.badLayout & USING_FONT) != 0)
 1617    {
 1618  20 printMessage(USING_FONT, lexer, "badlayout_using_font", null, Level.SUMMARY);
 1619    }
 1620   
 1621  21 if ((lexer.badLayout & USING_NOBR) != 0)
 1622    {
 1623  1 printMessage(USING_NOBR, lexer, "badlayout_using_nobr", null, Level.SUMMARY);
 1624    }
 1625   
 1626  21 if ((lexer.badLayout & USING_BODY) != 0)
 1627    {
 1628  0 printMessage(USING_BODY, lexer, "badlayout_using_body", null, Level.SUMMARY);
 1629    }
 1630    }
 1631    }
 1632   
 1633    /**
 1634    * Prints the "unknown option" message.
 1635    * @param errout PrintWriter
 1636    * @param c invalid option char
 1637    */
 1638  0 public void unknownOption(PrintWriter errout, char c)
 1639    {
 1640  0 printMessage(errout, "unrecognized_option", new Object[]{new String(new char[]{c})}, Level.ERROR);
 1641    }
 1642   
 1643    /**
 1644    * Prints the "unknown file" message.
 1645    * @param errout PrintWriter
 1646    * @param file invalid file name
 1647    */
 1648  0 public void unknownFile(PrintWriter errout, String file)
 1649    {
 1650  0 printMessage(errout, "unknown_file", new Object[]{"Tidy", file}, Level.ERROR);
 1651    }
 1652   
 1653    /**
 1654    * Prints the "needs author intervention" message.
 1655    * @param errout PrintWriter
 1656    */
 1657  14 public void needsAuthorIntervention(PrintWriter errout)
 1658    {
 1659  14 printMessage(errout, "needs_author_intervention", null, Level.SUMMARY);
 1660    }
 1661   
 1662    /**
 1663    * Prints the "missing body" message.
 1664    * @param errout PrintWriter
 1665    */
 1666  0 public void missingBody(PrintWriter errout)
 1667    {
 1668  0 printMessage(errout, "missing_body", null, Level.ERROR);
 1669    }
 1670   
 1671    /**
 1672    * Prints the number of generated slides.
 1673    * @param errout PrintWriter
 1674    * @param count slides count
 1675    */
 1676  1 public void reportNumberOfSlides(PrintWriter errout, int count)
 1677    {
 1678  1 printMessage(errout, "slides_found", new Object[]{new Integer(count)}, Level.SUMMARY);
 1679    }
 1680   
 1681    /**
 1682    * Prints tidy general info.
 1683    * @param errout PrintWriter
 1684    */
 1685  0 public void generalInfo(PrintWriter errout)
 1686    {
 1687  0 printMessage(errout, "general_info", null, Level.SUMMARY);
 1688    }
 1689   
 1690    /**
 1691    * Prints tidy hello message.
 1692    * @param errout PrintWriter
 1693    */
 1694  233 public void helloMessage(PrintWriter errout)
 1695    {
 1696  233 printMessage(errout, "hello_message", new Object[]{Report.RELEASE_DATE, this.currentFile}, Level.SUMMARY);
 1697    }
 1698   
 1699    /**
 1700    * Sets the current file name.
 1701    * @param filename current file.
 1702    */
 1703  238 public void setFilename(String filename)
 1704    {
 1705  238 this.currentFile = filename; // for use with Gnu Emacs
 1706    }
 1707   
 1708    /**
 1709    * Prints information for html version in input file.
 1710    * @param errout PrintWriter
 1711    * @param lexer Lexer
 1712    * @param filename file name
 1713    * @param doctype doctype Node
 1714    */
 1715  214 public void reportVersion(PrintWriter errout, Lexer lexer, String filename, Node doctype)
 1716    {
 1717  214 int i, c;
 1718  214 int state = 0;
 1719  214 String vers = lexer.htmlVersionName();
 1720  214 int[] cc = new int[1];
 1721   
 1722    // adjust reported position to first line
 1723  214 lexer.lines = 1;
 1724  214 lexer.columns = 1;
 1725   
 1726  214 if (doctype != null)
 1727    {
 1728   
 1729  113 StringBuffer doctypeBuffer = new StringBuffer();
 1730  113 for (i = doctype.start; i < doctype.end; ++i)
 1731    {
 1732  9145 c = doctype.textarray[i];
 1733   
 1734    // look for UTF-8 multibyte character
 1735  9145 if (c < 0)
 1736    {
 1737  0 i += PPrint.getUTF8(doctype.textarray, i, cc);
 1738  0 c = cc[0];
 1739    }
 1740   
 1741  9145 if (c == '"')
 1742    {
 1743  378 ++state;
 1744    }
 1745  8767 else if (state == 1)
 1746    {
 1747  3701 doctypeBuffer.append((char) c);
 1748    }
 1749    }
 1750   
 1751  113 printMessage(
 1752    DOCTYPE_GIVEN_SUMMARY,
 1753    lexer,
 1754    "doctype_given",
 1755    new Object[]{filename, doctypeBuffer},
 1756    Level.SUMMARY);
 1757    }
 1758   
 1759  214 printMessage(REPORT_VERSION_SUMMARY, lexer, "report_version", new Object[]{
 1760    filename,
 1761  214 (vers != null ? vers : "HTML proprietary")}, Level.SUMMARY);
 1762    }
 1763   
 1764    /**
 1765    * Prints the number of error/warnings found.
 1766    * @param errout PrintWriter
 1767    * @param lexer Lexer
 1768    */
 1769  231 public void reportNumWarnings(PrintWriter errout, Lexer lexer)
 1770    {
 1771  231 if (lexer.warnings > 0 || lexer.errors > 0)
 1772    {
 1773  159 printMessage(
 1774    errout,
 1775    "num_warnings",
 1776    new Object[]{new Integer(lexer.warnings), new Integer(lexer.errors)},
 1777    Level.SUMMARY);
 1778    }
 1779    else
 1780    {
 1781  72 printMessage(errout, "no_warnings", null, Level.SUMMARY);
 1782    }
 1783    }
 1784   
 1785    /**
 1786    * Prints tidy help.
 1787    * @param out PrintWriter
 1788    */
 1789  0 public void helpText(PrintWriter out)
 1790    {
 1791  0 printMessage(out, "help_text", new Object[]{"Tidy", RELEASE_DATE}, Level.SUMMARY);
 1792    }
 1793   
 1794    /**
 1795    * Prints the "bad tree" message.
 1796    * @param errout PrintWriter
 1797    */
 1798  2 public void badTree(PrintWriter errout)
 1799    {
 1800  2 printMessage(errout, "bad_tree", null, Level.ERROR);
 1801    }
 1802   
 1803    /**
 1804    * Adds a message listener.
 1805    * @param listener TidyMessageListener
 1806    */
 1807  222 public void addMessageListener(TidyMessageListener listener)
 1808    {
 1809  222 this.listener = listener;
 1810    }
 1811    }