Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashSet;
- /**
- * JavaKeywords is a Utility class related to the reserved keywords
- *
- * @author MrLore
- */
- public class JavaKeywords
- {
- private static final HashSet<String> keywords = new HashSet(Arrays.asList(new String[]
- {
- //There are 50 keywords, and 3 literals; true, false and null.
- "abstract", "assert", "boolean", "break", "byte",
- "case", "catch", "char", "class", "const",
- "continue", "default", "do", "double", "else",
- "enum", "extends", "false", "final", "finally",
- "float", "for", "goto", "if", "implements",
- "import", "instanceof", "int", "interface", "long",
- "native", "new", "null", "package", "private",
- "protected", "public", "return", "short", "static",
- "strictfp", "super", "switch", "synchronized", "this",
- "throw", "throws", "transient", "true", "try",
- "void", "volatile", "while"
- }));
- public static boolean isKeyword(String toCheck)
- {
- return keywords.contains(toCheck);
- }//End isKeyword()
- public static String[] getAsArray()
- {
- return keywords.toArray(new String[keywords.size()]);
- }//End getAsArray()
- public static ArrayList<String> getAsArrayList()
- {
- return new ArrayList(keywords);
- }//End getAsArrayList()
- public static HashSet<String> getAsHashSet()
- {
- return keywords;
- }//End getAsHashSet()
- }//End JavaKeywords
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement