MCPcopy Create free account
hub / github.com/apache/tomcat / isIdentifier

Method isIdentifier

java/org/apache/el/util/Validation.java:51–83  ·  view source on GitHub ↗

Test whether a string is a Java identifier. Note that the behaviour of this method depend on the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK @param key The string to test @return true if the provided String should be treated as a Java identifier, otherwise false

(String key)

Source from the content-addressed store, hash-verified

49 * @return {@code true} if the provided String should be treated as a Java identifier, otherwise false
50 */
51 public static boolean isIdentifier(String key) {
52
53 if (SKIP_IDENTIFIER_CHECK) {
54 return true;
55 }
56
57 // Should not be the case but check to be sure
58 if (key == null || key.isEmpty()) {
59 return false;
60 }
61
62 // Check the list of known invalid values
63 int i = 0;
64 int j = invalidIdentifiers.length;
65 while (i < j) {
66 int k = (i + j) >>> 1; // Avoid overflow
67 int result = invalidIdentifiers[k].compareTo(key);
68 if (result == 0) {
69 return false;
70 }
71 if (result < 0) {
72 i = k + 1;
73 } else {
74 j = k;
75 }
76 }
77
78 /*
79 * The parser checks Character.isJavaIdentifierStart() and Character.isJavaIdentifierPart() so no need to check
80 * them again here. However, we do need to check that '#' hasn't been used at the start of the identifier.
81 */
82 return key.charAt(0) != '#';
83 }
84}

Callers 2

setImageMethod · 0.95
setImageMethod · 0.95

Calls 3

charAtMethod · 0.80
compareToMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected