/** * Checks if a string is a valid Java identifier and not a Java keyword. * * @param string * the string to be tested */ public static boolean isLegalJavaIdentifier(String string) { if (string == null) { return false; } return !KEYWORDS.contains(string) && isJavaIdentifier(string); }
/** * Checks if a string is a valid Java package identifier. * * @param string * the string to be tested */ public static boolean isLegalJavaExecutableIdentifier(String string) { if (string == null) { return false; } if (string.equals(CtExecutableReference.CONSTRUCTOR_NAME)) { return true; } return isLegalJavaIdentifier(string); } }
/** * Checks if a string is a valid Java package identifier. * * @param string * the string to be tested */ public static boolean isLegalJavaPackageIdentifier(String string) { if (string == null) { return false; } StringTokenizer st = new StringTokenizer(string, "."); while (st.hasMoreElements()) { String s = st.nextToken(); if (!isLegalJavaIdentifier(s)) { return false; } } return true; }
/** * Checks if a string is a valid Java identifier and not a Java keyword. * * @param string * the string to be tested */ public static boolean isLegalJavaIdentifier(String string) { if (string == null) { return false; } return !KEYWORDS.contains(string) && isJavaIdentifier(string); }
/** * Checks if a string is a valid Java package identifier. * * @param string * the string to be tested */ public static boolean isLegalJavaExecutableIdentifier(String string) { if (string == null) { return false; } if (string.equals("<init>")) { return true; } return isLegalJavaIdentifier(string); }
/** * Checks if a string is a valid Java package identifier. * * @param string * the string to be tested */ public static boolean isLegalJavaPackageIdentifier(String string) { if (string == null) { return false; } StringTokenizer st = new StringTokenizer(string, "."); while (st.hasMoreElements()) { String s = st.nextToken(); if (!isLegalJavaIdentifier(s)) { return false; } } return true; }