List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.apache.hadoop.hbase.security.HBaseKerberosUtils.java
static boolean isKerberosPropertySetted() { String krbPrincipal = System.getProperty(KRB_PRINCIPAL); String krbKeytab = System.getProperty(KRB_KEYTAB_FILE); if (Strings.isNullOrEmpty(krbPrincipal) || Strings.isNullOrEmpty(krbKeytab)) { return false; }//from w ww. ja v a 2 s. c o m return true; }
From source file:org.pentaho.di.trans.dataservice.ui.BindingConverters.java
public static BindingConvertor<String, Boolean> stringIsEmpty() { return new BindingConvertor<String, Boolean>() { @Override/* w w w . j a v a2s .co m*/ public Boolean sourceToTarget(String value) { return Strings.isNullOrEmpty(value); } @Override public String targetToSource(Boolean value) { throw new AbstractMethodError("Boolean to String conversion is not supported"); } }; }
From source file:com.streamsets.lib.security.http.SSOPrincipalUtils.java
public static String getClientIpAddress(HttpServletRequest request) { String xff = request.getHeader(CLIENT_IP_HEADER); List<String> ipList = xffSplitter.splitToList(Strings.nullToEmpty(xff)); String ip;/*w w w .j a va2 s. co m*/ if (ipList.size() == 0 || UNKNOWN_IP.equalsIgnoreCase(ipList.get(0))) { ip = request.getRemoteAddr(); if (Strings.isNullOrEmpty(ip)) { ip = UNKNOWN_IP; } } else { ip = ipList.get(0); } return ip; }
From source file:be.ohatv.searchproviders.Webclient.java
public static String sendGet(String url) throws Exception { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", USER_AGENT); int responseCode = con.getResponseCode(); if (responseCode == 200) { BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine;// w w w .j a va2 s . c o m StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); //print result String result = response.toString(); if (Strings.isNullOrEmpty(url) == false) { return result; } } return null; }
From source file:monasca.api.infrastructure.persistence.SubAlarmDefinitionQueries.java
public static String buildJoinClauseFor(Map<String, String> dimensions) { StringBuilder sbJoin = new StringBuilder(); if (dimensions != null) { sbJoin = new StringBuilder(); int i = 0; for (String dimension_key : dimensions.keySet()) { sbJoin.append(" inner join sub_alarm_definition_dimension d").append(i).append(" on d").append(i) .append(".dimension_name = :dname").append(i); if (!Strings.isNullOrEmpty(dimensions.get(dimension_key))) { sbJoin.append(" and d").append(i).append(".value = :dvalue").append(i); }/*from w ww. j av a2 s . c om*/ sbJoin.append(" and dim.sub_alarm_definition_id = d").append(i).append(".sub_alarm_definition_id"); i++; } } return sbJoin.toString(); }
From source file:com.omade.monitor.utils.DateUtils.java
public static String toStringFromDate(Date date, String format) { try {/* w ww . j a v a 2 s . c o m*/ if (Strings.isNullOrEmpty(format)) { format = DATE_FORMAT_DEFAULT; } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); return simpleDateFormat.format(date); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:net.mad.ads.db.definition.AdSlot.java
public static AdSlot fromString(String uuid) throws IllegalArgumentException { if (Strings.isNullOrEmpty(uuid)) { throw new IllegalArgumentException("Invalid AdUUID string: " + uuid); }// w w w .ja v a 2 s . c om String[] components = uuid.split("-"); if (components.length != 2) { throw new IllegalArgumentException("Invalid AdUUID string: " + uuid); } AdSlot aduuid = new AdSlot(Base16.decode(components[0]), Base16.decode(components[1])); return aduuid; }
From source file:io.gravitee.common.utils.PropertiesUtils.java
public static Object getProperty(final Properties properties, final String propertyName, final boolean isNumber) { final String propertyValue = properties.getProperty(propertyName); if (Strings.isNullOrEmpty(propertyValue)) { throw new IllegalStateException("Missing property configuration:" + propertyName); }/*from ww w. ja v a2s . c o m*/ try { if (isNumber) { return Integer.parseInt(propertyValue); } return propertyValue; } catch (final NumberFormatException e) { throw new IllegalArgumentException("The property must be a valid number:" + propertyName, e); } }
From source file:org.n52.shetland.util.CRSHelper.java
/** * * Parse the srsName to integer value/*from w w w . j a v a 2 s . c om*/ * * @param srsName * the srsName to parse * * @return srsName integer value * */ public static int parseSrsName(String srsName) { if (!Strings.isNullOrEmpty(srsName) && !"NOT_SET".equalsIgnoreCase(srsName)) { int idx = Math.max(srsName.lastIndexOf(':'), srsName.lastIndexOf('/')); if (idx >= 0 && idx < srsName.length() - 1) { return Integer.parseInt(srsName.substring(idx + 1), 10); } } return -1; }
From source file:org.obiba.mica.spi.search.support.AttributeKey.java
public static String getMapKey(String name, @Nullable String namespace) { return Strings.isNullOrEmpty(namespace) ? name : namespace + SEPARATOR + name; }