Subversion Repository Public Repository

litesoft

Diff Revisions 599 vs 600 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/StringUtils.java

Diff revisions: vs.
  @@ -12,4 +12,25 @@
12 12 public static String noEmpty(String pString) {
13 13 return ((pString = deNull(pString).trim()).length() != 0) ? pString : null;
14 14 }
15 +
16 + /**
17 + * return the index of the first character that is unacceptable for that position to be part of an Identifier.
18 + *
19 + * An Identifier is a String that stars with a 7bit Alpha or underscore, and is followed by any number of 7bit AlphaNumerics or underscores.
20 + *
21 + * @param toCheck not null or empty
22 + *
23 + * @return -1 if OK, otherwise the 'bad' character index.
24 + */
25 + public static int checkIdentifier(String toCheck) {
26 + if (!CharacterUtils.is7bitAlphaUnderScore( toCheck.charAt( 0 ) )) {
27 + return 0;
28 + }
29 + for (int i = 1; i <toCheck.length(); i++) {
30 + if (!CharacterUtils.isAlphaNumericUnderScore7bitAscii( toCheck.charAt( i ) )) {
31 + return i;
32 + }
33 + }
34 + return -1;
35 + }
15 36 }