List of usage examples for java.lang String trim
public String trim()
From source file:Main.java
/** * DOCUMENT ME!//from w w w .j a v a 2s .co m * * @param id * DOCUMENT ME! * @param ids * DOCUMENT ME! * @return DOCUMENT ME! */ public static boolean isIn(String id, String[] ids) { if ((null == id) || (id.trim().equals("")) || (null == ids)) { return false; } boolean flag = false; for (int i = 0; i < ids.length; i++) { if (ids[i] != null && id.trim().equalsIgnoreCase(ids[i].trim())) { flag = true; break; } } return flag; }
From source file:Main.java
public static byte stringToHexBytes(int obj) { byte hex = 0; String aim = null; aim = String.valueOf(obj);/*from w w w. j ava 2 s .com*/ if (aim != null && !aim.trim().equals(" ")) { hex = Byte.parseByte(aim, 16); } return hex; }
From source file:Main.java
public static boolean isNullOrEmpty(String value) { boolean v = true; if (value != null && value.trim().equals("") == false && value.equalsIgnoreCase("null") == false) { v = false;/*from w w w .j ava2 s . c om*/ } return v; }
From source file:Main.java
public static boolean isValid(String str) { boolean isValid = false; if (str != null && !"".equals(str.trim())) { isValid = true;/*from www. j a va 2s . c om*/ } return isValid; }
From source file:Main.java
public static String getElementText(final Element eElement, final String name) { NodeList nodes = eElement.getElementsByTagName(name); if (nodes == null) { return null; }//from w w w. ja v a 2 s .c om Node node = nodes.item(0); if (node == null) { return null; } String value = node.getTextContent(); return (value != null) ? value.trim() : null; }
From source file:Main.java
public static String validateAndFixUserPhoneNumber(String text) { try {// w w w . j a va 2s .co m text = text.trim(); if (text.charAt(0) == '+') { text = text.substring(1); } BigInteger dummy = new BigInteger(text); if (text.charAt(0) == '8') { StringBuilder strBuilder = new StringBuilder(text); strBuilder.setCharAt(0, '7'); text = strBuilder.toString(); } if (text.charAt(0) != '7' || text.length() != 11) { throw new Exception(); } text = "+" + text; } catch (Throwable t) { text = ""; //LOGE("validateAndFixUserPhoneNumber: " + t.getMessage()); t.printStackTrace(); } return text; }
From source file:Main.java
public static String getPageName(String link, boolean cutQueries) { String s = link.trim(); if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); }//w w w. j a v a2s .com int i2 = -1; if (cutQueries) i2 = link.indexOf('?'); if (i2 < 0) i2 = s.length(); int i1 = s.lastIndexOf('/', i2) + 1; // int i2 = -1; // if (cutQueries) // i2 = link.indexOf('?'); // if (i2 < 0) // i2 = s.length(); if (i1 < 0) i1 = 0; return s.substring(i1, i2); }
From source file:Main.java
public static final Set<String> stringArrayToSet(final String[] array) { if (array == null) { return Collections.emptySet(); }/*from w ww . j a va 2s . c o m*/ Set<String> tmp = new LinkedHashSet<>(); for (String part : array) { String trimmed = part.trim(); if (trimmed.length() > 0) { tmp.add(trimmed.intern()); } } return tmp; }
From source file:Main.java
public static boolean isEmpty(String string) { return (string == null || string.length() == 0 || string.trim().length() == 0); }