src/jdk.management.rest/share/classes/jdk/internal/management/remote/rest/json/parser/TokenMgrError.java
author hb
Fri, 19 Jan 2018 13:46:27 +0530
branchjmx-rest-api
changeset 56026 bd531f08d7c7
permissions -rw-r--r--
1. Removed all changes to Java SE APIs 2. Changed module name to jdk.management.rest 3. Rest Adapter invoked via Module service provider 4. changed package name to jdk.internal.management.remote.rest 5. rest module and httpserver module part of platform modules
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56026
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     1
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     2
/* JavaCCOptions: */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     3
package jdk.internal.management.remote.rest.json.parser;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     4
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     5
/** Token Manager Error. */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     6
public class TokenMgrError extends Error
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     7
{
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     8
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
     9
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    10
   * The version identifier for this Serializable class.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    11
   * Increment only if the <i>serialized</i> form of the
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    12
   * class changes.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    13
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    14
  private static final long serialVersionUID = 1L;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    15
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    16
  /*
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    17
   * Ordinals for various reasons why an Error of this type can be thrown.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    18
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    19
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    20
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    21
   * Lexical error occurred.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    22
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    23
  static final int LEXICAL_ERROR = 0;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    24
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    25
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    26
   * An attempt was made to create a second instance of a static token manager.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    27
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    28
  static final int STATIC_LEXER_ERROR = 1;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    29
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    30
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    31
   * Tried to change to an invalid lexical state.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    32
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    33
  static final int INVALID_LEXICAL_STATE = 2;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    34
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    35
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    36
   * Detected (and bailed out of) an infinite loop in the token manager.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    37
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    38
  static final int LOOP_DETECTED = 3;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    39
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    40
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    41
   * Indicates the reason why the exception is thrown. It will have
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    42
   * one of the above 4 values.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    43
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    44
  int errorCode;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    45
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    46
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    47
   * Replaces unprintable characters by their escaped (or unicode escaped)
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    48
   * equivalents in the given string
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    49
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    50
  protected static final String addEscapes(String str) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    51
    StringBuffer retval = new StringBuffer();
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    52
    char ch;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    53
    for (int i = 0; i < str.length(); i++) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    54
      switch (str.charAt(i))
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    55
      {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    56
        case 0 :
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    57
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    58
        case '\b':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    59
          retval.append("\\b");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    60
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    61
        case '\t':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    62
          retval.append("\\t");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    63
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    64
        case '\n':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    65
          retval.append("\\n");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    66
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    67
        case '\f':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    68
          retval.append("\\f");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    69
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    70
        case '\r':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    71
          retval.append("\\r");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    72
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    73
        case '\"':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    74
          retval.append("\\\"");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    75
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    76
        case '\'':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    77
          retval.append("\\\'");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    78
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    79
        case '\\':
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    80
          retval.append("\\\\");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    81
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    82
        default:
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    83
          if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    84
            String s = "0000" + Integer.toString(ch, 16);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    85
            retval.append("\\u" + s.substring(s.length() - 4, s.length()));
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    86
          } else {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    87
            retval.append(ch);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    88
          }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    89
          continue;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    90
      }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    91
    }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    92
    return retval.toString();
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    93
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    94
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    95
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    96
   * Returns a detailed message for the Error when it is thrown by the
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    97
   * token manager to indicate a lexical error.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    98
   * Parameters :
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
    99
   *    EOFSeen     : indicates if EOF caused the lexical error
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   100
   *    curLexState : lexical state in which this error occurred
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   101
   *    errorLine   : line number when the error occurred
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   102
   *    errorColumn : column number when the error occurred
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   103
   *    errorAfter  : prefix that was seen before this error occurred
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   104
   *    curchar     : the offending character
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   105
   * Note: You can customize the lexical error message by modifying this method.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   106
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   107
  protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   108
    return("Lexical error at line " +
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   109
          errorLine + ", column " +
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   110
          errorColumn + ".  Encountered: " +
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   111
          (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   112
          "after : \"" + addEscapes(errorAfter) + "\"");
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   113
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   114
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   115
  /**
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   116
   * You can also modify the body of this method to customize your error messages.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   117
   * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   118
   * of end-users concern, so you can return something like :
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   119
   *
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   120
   *     "Internal Error : Please file a bug report .... "
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   121
   *
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   122
   * from this method for such cases in the release version of your parser.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   123
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   124
  public String getMessage() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   125
    return super.getMessage();
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   126
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   127
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   128
  /*
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   129
   * Constructors of various flavors follow.
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   130
   */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   131
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   132
  /** No arg constructor. */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   133
  public TokenMgrError() {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   134
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   135
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   136
  /** Constructor with message and reason. */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   137
  public TokenMgrError(String message, int reason) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   138
    super(message);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   139
    errorCode = reason;
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   140
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   141
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   142
  /** Full Constructor. */
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   143
  public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   144
    this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   145
  }
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   146
}
bd531f08d7c7 1. Removed all changes to Java SE APIs
hb
parents:
diff changeset
   147
/* JavaCC - OriginalChecksum=98060294001500754a7ee499f6ef09d6 (do not edit this line) */