List of usage examples for org.apache.commons.lang3 StringUtils trimToNull
public static String trimToNull(final String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .
From source file:org.openestate.io.immobiliare_it.ImmobiliareItDocument.java
@Override public ImmobiliareItVersion getDocumentVersion() { String version;// www .ja va2 s. c om try { Document doc = this.getDocument(); version = StringUtils .trimToNull(XmlUtils.newXPath("/io:feed/io:version/text()", doc).stringValueOf(doc)); if (version == null) { LOGGER.warn("Can't find version informations in the XML document!"); //System.out.println( "----------------------------" ); //try //{ // DocumentUtils.write( doc, System.out ); //} //catch (Exception ex) //{ // LOGGER.error( "Can't write XML document!" ); // LOGGER.error( "> " + ex.getLocalizedMessage(), ex ); //} //System.out.println( "----------------------------" ); return null; } } catch (JaxenException ex) { LOGGER.error("Can't evaluate XPath expression!"); LOGGER.error("> " + ex.getLocalizedMessage(), ex); return null; } ImmobiliareItVersion v = ImmobiliareItVersion.detectFromString(version); if (v != null) return v; LOGGER.warn("The provided version (" + version + ") is not supported!"); return null; }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static Category parseCategory(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; Category cat = Category.fromXmlValue(value); if (cat == null) throw new IllegalArgumentException("Can't parse category value '" + value + "'!"); return cat;// w ww . j ava 2 s .co m }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static Currency parseCurrency(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; try {/*from w w w . j a v a 2 s . com*/ if (value.trim().length() != 3) throw new Exception("Currency code must contain of 3 characters."); return Currency.getInstance(value.trim().toUpperCase()); } catch (Exception ex) { throw new IllegalArgumentException("Can't parse currency value '" + value + "'!", ex); } }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static String parseEmailType(String value) { //value = StringUtils.trimToNull( value ); //if (value==null) // return null; //else if (value.matches( "[^@]+@[^\\.]+\\..+" )) // return value; //else/*w w w .j a va 2 s .co m*/ // throw new IllegalArgumentException( "Can't parse e-mail value '" + value + "'!" ); return StringUtils.trimToNull(value); }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static EnergyUnit parseEnergyUnit(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; EnergyUnit unit = EnergyUnit.fromXmlValue(value); if (unit == null) throw new IllegalArgumentException("Can't parse energy-unit value '" + value + "'!"); return unit;/*ww w . j a va2s . c o m*/ }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static BigInteger parseInteger(String value) { value = StringUtils.trimToNull(value); return (value != null) ? DatatypeConverter.parseInteger(value) : null; }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static LandSizeUnit parseLandSizeUnit(String value) { value = StringUtils.trimToNull(value); if (value == null) return null; LandSizeUnit unit = LandSizeUnit.fromXmlValue(value); if (unit == null) throw new IllegalArgumentException("Can't parse land-size-unit value '" + value + "'!"); return unit;// w w w.j a v a 2s .c o m }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static BigDecimal parseLatitude(String value) { value = StringUtils.trimToNull(value); return (value != null) ? DatatypeConverter.parseDecimal(value) : null; }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static BigDecimal parseLongitude(String value) { value = StringUtils.trimToNull(value); return (value != null) ? DatatypeConverter.parseDecimal(value) : null; }
From source file:org.openestate.io.immobiliare_it.ImmobiliareItUtils.java
public static Integer parseRooms(String value) { value = StringUtils.trimToNull(value); return (value != null) ? DatatypeConverter.parseInt(value) : null; }