litesoft
@ 600
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / shared / utils / StringUtils.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
package com.temp.shared.utils; public class StringUtils { public static String deNull(String pString) { return deNull(pString, ""); } public static String deNull(String pString, String pDefault) { return (pString != null) ? pString : pDefault; } public static String noEmpty(String pString) { return ((pString = deNull(pString).trim()).length() != 0) ? pString : null; } /** * return the index of the first character that is unacceptable for that position to be part of an Identifier. * * An Identifier is a String that stars with a 7bit Alpha or underscore, and is followed by any number of 7bit AlphaNumerics or underscores. * * @param toCheck not null or empty * * @return -1 if OK, otherwise the 'bad' character index. */ public static int checkIdentifier(String toCheck) { if (!CharacterUtils.is7bitAlphaUnderScore( toCheck.charAt( 0 ) )) { return 0; } for (int i = 1; i <toCheck.length(); i++) { if (!CharacterUtils.isAlphaNumericUnderScore7bitAscii( toCheck.charAt( i ) )) { return i; } } return -1; } } |