title: Using reserved words in an enum / switch statement, best workaround?
body: <p>I am writing a flat file parser that reads token/value pairs using a Scanner.  The files being read contain the token "class".  The token is later used in a switch statement, and uses the (pre Java 7) valueOf(token) Java idiom to produce an enum value. (I am using Java6 for compatibility with GWT.) As a workaround, I am using uppercase values in the enum, and valueOf(token.toUpperCase()).</p>
  
  <pre><code>public enum ParseTags {
      CODE, CLASS, INSTRUCTOR, HOURS;
  }
  
  // . . . 
  
  token = scanner.next();
  value = scanner.next();
  
  switch (ParseTags.valueOf(token.toUpperCase())) {
  case CODE:
      entry.setCode(value);
      break;
  case CLASS:
      entry.setClass(value);
      break;
  </code></pre>
  
  <p>Because this is being compiled into javascript, I want to avoid the extra "toUpperCase()" operation on each iteration; not sure what performance will be on target platform. Is there a more graceful way to represent reserved words in an enumeration?  This would be handled well by Java7's switch on String, but again, I am confined to Java6sdk.</p>