/** * Returns <jk>true</jk> if specified string is not <jk>null</jk> or empty. * * @param s The string to check. * @return <jk>true</jk> if specified string is not <jk>null</jk> or empty. */ public static boolean isNotEmpty(String s) { return ! isEmpty(s); }
/** * Returns <jk>true</jk> if specified string is not <jk>null</jk> or it's {@link #toString()} method doesn't return an empty * string. * * @param s The string to check. * @return * <jk>true</jk> if specified string is not <jk>null</jk> or it's {@link #toString()} method doesn't return an empty string. */ public static boolean isNotEmpty(Object s) { return ! isEmpty(s); }
/** * Converts the specified {@link String} to an <code>XMLGregorianCalendar</code>. */ @Override /* PojoSwap */ public XMLGregorianCalendar unswap(BeanSession session, String s, ClassMeta<?> hint) throws Exception { if (isEmpty(s)) return null; return dtf.newXMLGregorianCalendar(s); } }
/** * Converts the specified {@link String} to an <code>XMLGregorianCalendar</code>. */ @Override /* PojoSwap */ public XMLGregorianCalendar unswap(BeanSession session, String s, ClassMeta<?> hint) throws Exception { if (isEmpty(s)) return null; return dtf.newXMLGregorianCalendar(s); } }
@Override /* HttpServletRequest */ public String getQueryString() { if (queryString == null) { queryString = ""; if (uri.indexOf('?') != -1) { queryString = uri.substring(uri.indexOf('?') + 1); if (queryString.indexOf('#') != -1) queryString = queryString.substring(0, queryString.indexOf('#')); } } return isEmpty(queryString) ? null : queryString; }
/** * Same as {@link #getString(String,String)} but converts the value to a boolean. * * @param name The URL parameter name. * @param def The default value. * @return * The parameter value, or the default value if parameter not specified or has no value (e.g. <js>"&foo"</js>). */ public boolean getBoolean(String name, boolean def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Boolean.parseBoolean(s); }
/** * Same as {@link #getString(String,String)} but converts the value to an integer. * * @param name The HTTP header name. * @param def The default value to return if the header value isn't found. * @return The header value, or the default value if the header isn't present. */ public int getInt(String name, int def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Integer.parseInt(s); }
/** * Same as {@link #getString(String,String)} but converts the value to an integer. * * @param name The HTTP header name. * @param def The default value to return if the header value isn't found. * @return The header value, or the default value if the header isn't present. */ public int getInt(String name, int def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Integer.parseInt(s); }
/** * Same as {@link #getString(String,String)} but converts the value to a boolean. * * @param name The HTTP header name. * @param def The default value to return if the header value isn't found. * @return The header value, or the default value if the header isn't present. */ public boolean getBoolean(String name, boolean def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Boolean.parseBoolean(s); }
private static String[] getDefaultProtocols() { String sp = System.getProperty("transport.client.protocol"); if (isEmpty(sp)) return new String[] {"SSL_TLS","TLS","SSL"}; return StringUtils.split(sp, ','); } }
/** * Same as {@link #getString(String,String)} but converts the value to an integer. * * @param name The form-data parameter name. * @param def The default value. * @return The parameter value, or the default value if parameter does not exist or is <jk>null</jk> or empty. */ public int getInt(String name, int def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Integer.parseInt(s); }
private ContentType getRequestContentType(ContentType def) { Header h = request.getFirstHeader("Content-Type"); if (h != null) { String s = h.getValue(); if (! isEmpty(s)) return ContentType.create(s); } return def; }
/** * Same as {@link #getString(String,String)} but converts the value to a boolean. * * @param name The form-data parameter name. * @param def The default value. * @return The parameter value, or the default value if parameter does not exist or is <jk>null</jk> or empty. */ public boolean getBoolean(String name, boolean def) { String s = getString(name); return StringUtils.isEmpty(s) ? def : Boolean.parseBoolean(s); }
private String section(String section) { assertFieldNotNull(section, "section"); if (isEmpty(section)) return ""; return section; }
final static Set<String> toSet(String s) { if (isEmpty(s)) return null; Set<String> set = new ASet<>(); try { for (Object o : StringUtils.parseListOrCdl(s)) set.add(o.toString()); } catch (ParseException e) { throw new RuntimeException(e); } return set; }
String toString(boolean simple) { StringBuilder sb = new StringBuilder().append('[').append(depth).append(']').append(' '); sb.append(isEmpty(name) ? "<noname>" : name).append(':'); sb.append(aType.toString(simple)); if (aType != aType.getSerializedClassMeta(BeanTraverseSession.this)) sb.append('/').append(aType.getSerializedClassMeta(BeanTraverseSession.this).toString(simple)); return sb.toString(); } }
/** * Parses an ISO8601 string and converts it to a {@link Date}. * * @param s The string to parse. * @return The parsed value, or <jk>null</jk> if the string was <jk>null</jk> or empty. */ public static Date parseISO8601(String s) { if (isEmpty(s)) return null; return DatatypeConverter.parseDateTime(toValidISO8601DT(s)).getTime(); }
/** * Parses an ISO8601 string and converts it to a {@link Calendar}. * * @param s The string to parse. * @return The parsed value, or <jk>null</jk> if the string was <jk>null</jk> or empty. */ public static Calendar parseISO8601Calendar(String s) { if (isEmpty(s)) return null; return DatatypeConverter.parseDateTime(toValidISO8601DT(s)); }
private ObjectMap merge(ObjectMap om, ResponseHeader[] a) throws ParseException { if (a.length == 0) return om; om = newMap(om); for (ResponseHeader aa : a) { String name = StringUtils.firstNonEmpty(aa.name(), aa.value()); if (isEmpty(name)) throw new RuntimeException("@ResponseHeader used without name or value."); om.getObjectMap(name, true).putAll(merge(null, aa)); } return om; }
private ObjectMap merge(ObjectMap om, ResponseHeader[] a) throws ParseException { if (a.length == 0) return om; om = newMap(om); for (ResponseHeader aa : a) { String name = StringUtils.firstNonEmpty(aa.name(), aa.value()); if (isEmpty(name)) throw new RuntimeException("@ResponseHeader used without name or value."); om.getObjectMap(name, true).putAll(merge(null, aa)); } return om; }