src/jdk.jcmd/share/classes/sun/tools/jstat/SyntaxException.java

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


  48         message = "Syntax error at line " + lineno
  49                   + ": Expected " + expected
  50                   + ", Found " + found;
  51     }
  52 
  53     public SyntaxException(int lineno, String expected, Token found) {
  54         message = "Syntax error at line " + lineno
  55                   + ": Expected " + expected
  56                   + ", Found " + found.toMessage();
  57     }
  58 
  59     public SyntaxException(int lineno, Token expected, Token found) {
  60         message = "Syntax error at line " + lineno
  61                   + ": Expected " + expected.toMessage()
  62                   + ", Found " + found.toMessage();
  63     }
  64 
  65     public SyntaxException(int lineno, Set<String> expected, Token found) {
  66         StringBuilder msg = new StringBuilder();
  67 
  68         msg.append("Syntax error at line " + lineno + ": Expected one of \'");
  69 
  70         boolean first = true;
  71         for (Iterator<String> i = expected.iterator(); i.hasNext(); /* empty */) {
  72             String keyWord = i.next();
  73             if (first) {
  74                 msg.append(keyWord);
  75                 first = false;
  76             } else {
  77                 msg.append("|" + keyWord);
  78             }
  79         }
  80 
  81         msg.append("\', Found " + found.toMessage());
  82         message = msg.toString();
  83     }
  84 
  85     public String getMessage() {
  86         return message;
  87     }
  88 }


  48         message = "Syntax error at line " + lineno
  49                   + ": Expected " + expected
  50                   + ", Found " + found;
  51     }
  52 
  53     public SyntaxException(int lineno, String expected, Token found) {
  54         message = "Syntax error at line " + lineno
  55                   + ": Expected " + expected
  56                   + ", Found " + found.toMessage();
  57     }
  58 
  59     public SyntaxException(int lineno, Token expected, Token found) {
  60         message = "Syntax error at line " + lineno
  61                   + ": Expected " + expected.toMessage()
  62                   + ", Found " + found.toMessage();
  63     }
  64 
  65     public SyntaxException(int lineno, Set<String> expected, Token found) {
  66         StringBuilder msg = new StringBuilder();
  67 
  68         msg.append("Syntax error at line ").append(lineno).append(": Expected one of \'");
  69 
  70         boolean first = true;
  71         for (Iterator<String> i = expected.iterator(); i.hasNext(); /* empty */) {
  72             String keyWord = i.next();
  73             if (first) {
  74                 msg.append(keyWord);
  75                 first = false;
  76             } else {
  77                 msg.append('|').append(keyWord);
  78             }
  79         }
  80 
  81         msg.append("\', Found ").append(found.toMessage());
  82         message = msg.toString();
  83     }
  84 
  85     public String getMessage() {
  86         return message;
  87     }
  88 }