List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:com.google.gerrit.server.util.LogUtil.java
public static boolean shouldConfigureLogSystem() { return Strings.isNullOrEmpty(System.getProperty(LOG4J_CONFIGURATION)); }
From source file:be.ohatv.searchproviders.Btdigg.java
public static String GrapMagnet(String phrase) { try {//from ww w . j a va 2 s .c o m if (Strings.isNullOrEmpty(phrase) == false) { JSONObject jsonsettings = DbFunctions.getBittorrentclient(); String ignorewords[] = null; if (jsonsettings.has("btignorewords")) { String btignorewords = jsonsettings.getString("btignorewords"); ignorewords = btignorewords.split(";"); } phrase = phrase.replaceAll("\\(", ""); phrase = phrase.replaceAll("\\)", ""); String strwords[] = phrase.split(" "); String quality = ""; if (phrase.contains("720p")) { quality = "720p"; } else if (phrase.contains("1080p")) { quality = "1080p"; } StringBuilder sbhtml = new StringBuilder(); sbhtml.append(url).append(URLEncoder.encode(phrase, "UTF-8")); String btdiggpage = Webclient.sendGet(sbhtml.toString()); if (Strings.isNullOrEmpty(btdiggpage) == false) { List<String> lstmagnets = new ArrayList<>(); Pattern p = Pattern.compile("href=\"(.*?)\""); Matcher m = p.matcher(btdiggpage); while (m.find()) { String magnet = m.group(1); if (magnet.contains("magnet:?")) { lstmagnets.add(magnet); } } if (lstmagnets.size() > 0) { int counter = 0; for (String magnet : lstmagnets) { for (String word : strwords) { if (magnet.toLowerCase().contains(word.toLowerCase())) { counter++; } } if (counter == strwords.length) { if (Strings.isNullOrEmpty(quality) == false) { if (magnet.contains(quality) == false) { counter = 0; } } else { if (magnet.contains("720") && magnet.contains("1080")) { counter = 0; } } } if (counter == strwords.length) { return magnet; } } } } } } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:co.cask.hydrator.plugin.FieldCase.java
public static FieldCase toFieldCase(String fieldCase) { if (Strings.isNullOrEmpty(fieldCase)) { return FieldCase.NONE; }//from w w w.jav a2 s. c om try { return FieldCase.valueOf(fieldCase.toUpperCase()); } catch (IllegalArgumentException e) { return FieldCase.NONE; } }
From source file:com.urswolfer.gerrit.client.rest.http.util.UrlUtils.java
public static String appendToUrlQuery(String query, String parameter) { if (!Strings.isNullOrEmpty(query)) { query += "&"; }// ww w. j av a 2 s.c o m query += parameter; return query; }
From source file:com.tosinogunrinde.cql.statementbuilder.util.StringValidator.java
public static void validateNotNullOrEmpty(String value) { if (Strings.isNullOrEmpty(value)) { throw new IllegalArgumentException("value must not be null or empty"); }//from w ww . j a va 2s . com }
From source file:com.google.util.JspUtil.java
public static boolean isNullOrEmpty(String value) { return Strings.isNullOrEmpty(value); }
From source file:com.shampan.db.services.SearchController.java
public static void getSearchResult(RoutingContext routingContext) { int offset = 0; int limit = 10; String searchValue = routingContext.request().getParam("searchValue"); /*//w w w . j ava2 s .c o m If offset is incorrect then offset will be used as default */ if (!Strings.isNullOrEmpty(routingContext.request().getParam("offset"))) { try { offset = Integer.parseInt(routingContext.request().getParam("offset")); } catch (NumberFormatException nfe) { logger.debug(nfe.getMessage()); } } /* If limit is incorrect then limit will be used as default */ if (!Strings.isNullOrEmpty(routingContext.request().getParam("limit"))) { try { limit = Integer.parseInt(routingContext.request().getParam("limit")); } catch (NumberFormatException nfe) { logger.debug(nfe.getMessage()); } } routingContext.response().putHeader("content-type", "application/json; charset=utf-8") .end(SearchService.getSearchResult(searchValue, offset, limit)); }
From source file:org.incode.eurocommercial.contactapp.dom.util.StringUtil.java
public static String firstNonEmpty(final String... str) { for (String s : str) { if (!Strings.isNullOrEmpty(s)) { return s; }/* w w w .j av a 2s. co m*/ } return null; }
From source file:be.ohatv.btclients.Transmission.java
private static void getsessiontoken(String url) { try {//w w w .j a va2s. c om String s = getTransmissionSessionId(url); if (Strings.isNullOrEmpty(s) == false) { sessiontoken = s; } } catch (Exception ex) { } }
From source file:org.shaf.core.util.PatternUtils.java
public static final Pattern getWildCardPattern(final String wildcard) { if (Strings.isNullOrEmpty(wildcard)) { throw new IllegalArgumentException("The wildcard is not defined."); }/*ww w.j a va 2 s .c o m*/ StringBuilder regexp = new StringBuilder(); for (int i = 0, is = wildcard.length(); i < is; i++) { char c = wildcard.charAt(i); switch (c) { case '*': regexp.append(".*"); break; case '?': regexp.append('.'); break; case '(': case ')': case '[': case ']': case '$': case '^': case '.': case '{': case '}': case '|': case '\\': regexp.append('\\'); regexp.append(c); break; default: regexp.append(c); break; } } return Pattern.compile(regexp.toString()); }