Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6263368

Illegible output in ParserDelegator when calling handleError

XMLWordPrintable

    • b46
    • x86
    • windows_2000

      A DESCRIPTION OF THE REQUEST :
      ParserDelegator calls javax.swing.text.html.HTMLEditorKit.ParserCallback.handleError
      for each error it encounters. It passes as argument the position within the file, where
      the error occurs, and the error message.

      The error message is practically unreadable, due to lack of proper spacing between
      the words. It is also not obvious (at least it is not documented) what one could
      do to turn this into an error message understandable for a human being.



      JUSTIFICATION :
      I think it can't be so hard to insert a space between two adjecent words
      when communicating an error message, and it would make the class much
      more usable.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I would like to see an error message like this (for instance, when the src attribute
      is missing in a img tag):

      required attribut missing: src img
      ACTUAL -
      Instead I see the cryptic:

      req.att srcimg?

      Why can't there be at the very least an innocent space between src and img?????


      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileNotFoundException;
      import java.io.BufferedReader;
      import java.io.FileReader;
      import java.net.URL;
      import java.io.BufferedInputStream;
      import java.io.FileOutputStream;
      import java.io.DataInputStream;
      import java.io.PrintWriter;
      import java.io.FileWriter;
      import javax.swing.text.html.parser.DocumentParser;
      import javax.swing.text.html.parser.DTD;
      import javax.swing.text.html.HTMLEditorKit.ParserCallback;
      import javax.swing.text.html.parser.ParserDelegator;

      public class TTest1 {

      public static void main( String[] args ) {
      System.out.println("TTest1");
      ParserDelegator pd=new ParserDelegator();
          for(int i=0; i<args.length; i++)
          {
           String fn=args[i];
      try{
           if(pd != null)
           {
      System.out.println("ParserDelegator says:");
      pd.parse(new BufferedReader(new FileReader(fn)),new ParserCallback()
      {
      public void handleError(String errorMsg, int pos) {
      System.out.println("Error at position "+pos
      +": \n"+errorMsg);
      }
      },true);
           }
           }

           catch(FileNotFoundException e)
           {
           System.out.println("Can not read "+fn);
           }
           catch(IOException e)
           {
           System.out.println("Bailing out at "+fn);
           }
          }
      }

      }

      ---------- END SOURCE ----------
      ###@###.### 2005-04-29 05:20:06 GMT

            idk Igor Kushnirskiy (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: