aspose file tools*
The moose likes Java in General and the fly likes Method to find reserved words Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Method to find reserved words" Watch "Method to find reserved words" New topic
Author

Method to find reserved words

Tom Diamond
Ranch Hand

Joined: May 10, 2001
Posts: 98
Hello,
Is there a method in the Java API that indicates wether a string given as parameter is a reserved word or not? (reserved word aka 'public', 'void', etc.).
Tnx,
Tom.
omar khan
Ranch Hand

Joined: Feb 01, 2001
Posts: 183
I do not think it exists.
Never heard of.
Anyway to write one should be straightforward.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I agree with Omar. The HashSet class seems ideal for this. Here's a list of keywords for you.


"I'm not back." - Bill Harding, Twister
Steve Loughran
Ranch Hand

Joined: Aug 06, 2002
Posts: 37
The code to do this is in apache tomcat and then in ant; it is there to rename JSP pages.

the code to compare this is simply

for performance, a hash table would be better.
-steve
 
 
subject: Method to find reserved words