All Downloads are FREE. Search and download functionalities are using the official Maven repository.

link.thingscloud.freeswitch.esl.util.StringUtils Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package link.thingscloud.freeswitch.esl.util;

/**
 * 

StringUtils class.

* * @author zhouhailin * @version 1.0.0 */ public class StringUtils { public static final String BLANK = " "; private StringUtils() { } /** *

length.

* * @param cs a {@link java.lang.CharSequence} object. * @return a int. */ public static int length(final CharSequence cs) { return cs == null ? 0 : cs.length(); } /** *

isNotBlank.

* * @param cs a {@link java.lang.CharSequence} object. * @return a boolean. */ public static boolean isNotBlank(final CharSequence cs) { return !isBlank(cs); } /** *

isBlank.

* * @param cs a {@link java.lang.CharSequence} object. * @return a boolean. */ public static boolean isBlank(final CharSequence cs) { final int strLen = length(cs); if (strLen == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } /** *

equals.

* * @param cs1 a {@link java.lang.CharSequence} object. * @param cs2 a {@link java.lang.CharSequence} object. * @return a boolean. */ public static boolean equals(final CharSequence cs1, final CharSequence cs2) { if (cs1 == cs2) { return true; } if (cs1 == null || cs2 == null) { return false; } if (cs1.length() != cs2.length()) { return false; } if (cs1 instanceof String && cs2 instanceof String) { return cs1.equals(cs2); } // Step-wise comparison final int length = cs1.length(); for (int i = 0; i < length; i++) { if (cs1.charAt(i) != cs2.charAt(i)) { return false; } } return true; } public static boolean inEquals(String str, String... strs) { for (String s : strs) { if (equals(str, s)) { return true; } } return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy