List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:de.thischwa.pmcms.tool.Utils.java
/** * This method ensures that the output String has only * valid XML unicode characters as specified by the * XML 1.0 standard. For reference, please see * <a href="http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char">the * standard</a>. /*from ww w. j a v a2 s. c o m*/ * * @param in The String whose non-valid characters we want to remove. * @return The in String, stripped of non-valid characters. */ public static String stripNonValidXMLCharacters(String in) { if (in == null) return null; if (in.isEmpty()) return ""; StringBuffer out = new StringBuffer(); char current; for (int i = 0; i < in.length(); i++) { current = in.charAt(i); if ((current == 0x9) || (current == 0xA) || (current == 0xD) || ((current >= 0x20) && (current <= 0xD7FF)) || ((current >= 0xE000) && (current <= 0xFFFD)) || ((current >= 0x10000) && (current <= 0x10FFFF))) out.append(current); } return out.toString(); }
From source file:Main.java
/** Locate a sub-element tagged 'name', return its value. * * @param element Element where to start looking. May be null. * @param name Name of sub-element to locate. * @param default_value Default value if not found * * @return Returns double string that was found * @throws Exception on error in number format *///from w ww . ja v a 2 s . c om final public static double getSubelementDouble(final Element element, final String name, final double default_value) throws Exception { final String text = getSubelementString(element, name, "").trim(); if (text.isEmpty()) return default_value; try { return Double.parseDouble(text); } catch (NumberFormatException ex) { throw new Exception("Invalid number for <" + name + ">", ex); } }
From source file:com.amazonaws.services.kinesis.clientlibrary.config.AWSCredentialsProviderPropertyValueDecoder.java
private static List<String> getProviderNames(String property) { // assume list delimiter is "," String[] elements = property.split(LIST_DELIMITER); List<String> result = new ArrayList<String>(); for (int i = 0; i < elements.length; i++) { String string = elements[i].trim(); if (!string.isEmpty()) { // find all possible names and add them to name list result.addAll(getPossibleFullClassNames(string)); }/*ww w . j ava2s . co m*/ } return result; }
From source file:Main.java
public synchronized static Document loadDocument(String data) throws SAXException, IOException, ParserConfigurationException { if (data != null && !data.isEmpty()) { return loadDocument(new ByteArrayInputStream(data.getBytes("UTF-8"))); }//from www. j ava 2s . co m return null; }
From source file:Main.java
public static String getFIO(String f, String i, String o) { String res = ""; for (String t : new String[] { f, i, o }) { if (t != null && !(t = t.trim()).isEmpty()) { res += (res.isEmpty() ? "" : " ") + t; }/*from ww w . java 2s . c om*/ } return res; }
From source file:com.castis.xylophone.adsmadapter.common.util.CiDateUtil.java
public static boolean checkFutureDate(String date, String format) { if (date == null || date.isEmpty() == true) return false; Date tmpDate = convertDate(date, format); Date curDate = DateUtil.getCurDate(); return tmpDate.after(curDate); }
From source file:com.vmware.identity.openidconnect.protocol.JSONUtils.java
public static String getString(JSONObject json, String key) throws ParseException { Validate.notNull(json, "json"); Validate.notEmpty(key, "key"); Object objectValue = json.get(key); if (objectValue == null) { throw new ParseException(String.format("json is missing %s member", key)); }/*from w w w .j a v a 2 s.c om*/ if (!(objectValue instanceof String)) { throw new ParseException(String.format("json has non-string %s member", key)); } String stringValue = (String) objectValue; if (stringValue.isEmpty()) { throw new ParseException(String.format("json has empty %s member", key)); } return stringValue; }
From source file:Main.java
public static String doubleArr2String(Double[] doubleArray, String delimeter) { String str = ""; for (int i = 0; i < doubleArray.length; i++) { str += delimeter + Double.toString(doubleArray[i]); }//from w ww . j av a 2 s . co m if (!str.isEmpty()) str = str.substring(1); return str; }
From source file:Main.java
public static String concatString(List<String> listOfStrings, String delimeter) { String concat = ""; for (int i = 0; i < listOfStrings.size(); i++) { concat += delimeter + listOfStrings.get(i); }/*from w w w .ja v a 2s . c o m*/ if (!concat.isEmpty()) concat = concat.substring(1); return concat; }
From source file:Main.java
/** * Find all of the descendant elements of the given parent Node * whose tag name equals the given tag. * * @param parent The root of the xml dom tree to search. * @param tag The tag name to match./*from ww w. j ava 2 s. c om*/ * @param found The list of descendants that match the given tag. */ private static void findDescendantNamesWithSeparator(Node parent, String tag, String descendants, String separator, List<String> found) { if (parent instanceof Element) { String elementName = ((Element) parent).getAttribute("name"); if (!elementName.isEmpty()) { descendants += ((Element) parent).getAttribute("name"); } if (parent.getNodeName().equals(tag)) { found.add(descendants); } if (!elementName.isEmpty()) { descendants += separator; } } NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); findDescendantNamesWithSeparator(child, tag, descendants, separator, found); } }