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 import fc.io.*;
010
011 /**
012 Misc. utils
013 */
014 public final class MiscUtil
015 {
016 public static final String java_keywords[] = {
017 "abstract", "assert", "boolean", "break", "byte", "case", "catch",
018 "char", "class", "const", "continue", "default", "do", "double",
019 "else", "extends", "false", "final", "finally", "float", "for",
020 "goto", "if", "implements", "import", "instanceof", "int",
021 "interface", "long", "native", "new", "null", "package", "private",
022 "protected", "public", "return", "short", "static", "strictfp",
023 "super", "switch", "synchronized", "this", "throw", "throws",
024 "transient", "true", "try", "void", "volatile", "while"
025 };
026
027 /**
028 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.
029 */
030 public static boolean isJavaKeyword(String word) {
031 return (Arrays.binarySearch(java_keywords, word) >= 0);
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