/** * Returns true if the given String matches the production of a valid Java identifier. * * @param string The String to check the production of. * @return true if the given String matches the production of a valid Java name, otherwise false. */ @Override public final boolean isValidJavaIdentifier(final String string) { if (string == null || string.length() == 0 || !Character.isJavaIdentifierStart(string.charAt(0))) { return false; } for (int i = 1; i < string.length(); i++) { char ch = string.charAt(i); if (!Character.isJavaIdentifierPart(ch)) { return false; } } return !isKeyword(string); }
/** * Converts the given name to a valid Java name. * * @param name the XML name to convert * @param useKeywordSubstitutions set to true to turn on keyword substitution * @return a valid Java member name */ @Override public final String toJavaMemberName(final String name, final boolean useKeywordSubstitutions) { if (name == null) { return null; } String memberName = toJavaName(name, false); if (isKeyword(memberName) && useKeywordSubstitutions) { String mappedName = (String) SUBST.get(memberName); if (mappedName != null) { memberName = mappedName; } } return memberName; }