001    // Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 
002    // The Molly framework is freely distributable under the terms of an
003    // MIT-style license. For details, see the molly pages web site at:
004    // http://www.mollypages.org/. Use, modify, have fun !
005    
006    package fc.util;
007    
008    import java.util.*;
009    
010    /**
011    Misc. utils
012    */
013    public class MiscUtil
014    {
015    public static final String java_keywords[] = {
016      "abstract", "assert", "boolean", "break", "byte", "case", "catch",
017      "char", "class", "const", "continue", "default", "do", "double",
018      "else", "extends", "false", "final", "finally", "float", "for",
019      "goto", "if", "implements", "import", "instanceof", "int",
020      "interface", "long", "native", "new", "null", "package", "private",
021      "protected", "public", "return", "short", "static", "strictfp",
022      "super", "switch", "synchronized", "this", "throw", "throws",
023      "transient", "true", "try", "void", "volatile", "while" 
024      };
025    
026    /** 
027    Returns true if the specified word is a Java Language Keyword. Keywords (and hence this comparison) are case sensitive, upper case versions of these are ok in Java. 
028    */
029    public static boolean isJavaKeyword(String word) {
030      return (Arrays.binarySearch(java_keywords, word) >= 0);
031    }
032    
033    
034    public static void main (String args[])
035      {
036      Args myargs = new Args(args);
037      System.out.println(isJavaKeyword(myargs.getRequired("word")));
038      }
039      
040    }
041