List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:com.wefika.androidResourceResizer.Density.java
@Nullable public static Density getFromString(String density) { if (!StringUtils.isEmpty(density)) { if ("l".equalsIgnoreCase(density)) { return LOW; } else if ("m".equalsIgnoreCase(density)) { return MEDIUM; } else if ("tv".equalsIgnoreCase(density)) { return TV; } else if ("h".equalsIgnoreCase(density)) { return HIGH; } else if ("xh".equalsIgnoreCase(density)) { return XHIGH; } else if ("xxh".equalsIgnoreCase(density)) { return XXHEIGH; } else if ("xxxh".equalsIgnoreCase(density)) { return XXXHEIGHT; }/*from w w w .ja v a 2 s . co m*/ } return null; }
From source file:com.adaptris.core.services.metadata.xpath.XpathQueryHelper.java
static String resolveSingleTextItem(Document doc, XPath xp, String expr, boolean allowEmptyResults) throws CoreException { String queryResult = null;/*from w w w . j av a 2 s . c o m*/ try { String node = xp.selectSingleTextItem(doc, expr); if (StringUtils.isEmpty(node) && !allowEmptyResults) { throw new CoreException(expr + " returned no data"); } queryResult = node; } catch (Exception e) { throw ExceptionHelper.wrapCoreException(e); } return queryResult; }
From source file:com.mysoft.b2b.event.util.HttpUtil.java
/** * http???//from w w w. j av a2 s .co m * @param uri ? * @param body ? */ public static Integer send(String uri, String body) { if (StringUtils.isEmpty(uri) || StringUtils.isEmpty(body)) return null; HttpClient client = new DefaultHttpClient(); try { HttpPost post = new HttpPost(uri + "/dealEvent.do"); post.addHeader("Content-Type", "application/json;charset=UTF-8"); HttpEntity entity = new StringEntity(body); post.setEntity(entity); HttpResponse response = client.execute(post); int code = response.getStatusLine().getStatusCode(); return code; } catch (Exception e) { logger.error("http???" + e); } return null; }
From source file:jp.co.nemuzuka.utils.TagStringUtils.java
/** * ?./* ww w . j a v a2s. com*/ * ????????????? * @param tag TODO(?) * @param searchTagName ??? * @return ????????true */ public static boolean matchTag(String tag, String searchTagName) { if (StringUtils.isEmpty(tag)) { return false; } String[] tags = tag.split(","); for (String target : tags) { String tagName = StringUtils.trimToEmpty(target); if (StringUtils.isEmpty(tagName)) { continue; } if (tagName.equals(searchTagName)) { return true; } } return false; }
From source file:AIR.Common.Web.UrlHelper.java
public static boolean IsFtpProtocol(String uriString) { if (StringUtils.isEmpty(uriString)) return false; return (uriString.startsWith("ftp:")); }
From source file:com.mmj.app.biz.cons.SexEnum.java
/** * ?value?//from w ww . ja v a 2s. c om */ public static SexEnum getEnum(String name) { if (StringUtils.isEmpty(name)) { return null; } if (StringUtils.equalsIgnoreCase("true", name) || StringUtils.equalsIgnoreCase("man", name) || StringUtils.equalsIgnoreCase("male", name)) { return MAN; } if (StringUtils.equalsIgnoreCase("false", name) || StringUtils.equalsIgnoreCase("man", name) || StringUtils.equalsIgnoreCase("female", name)) { return WOMAN; } return null; }
From source file:net.duckling.ddl.service.resource.dao.ResourceOrderUtils.java
public static String buildOrderSql(String tableAlies, String orderStr) { orderStr = StringUtils.isEmpty(orderStr) ? "" : orderStr; tableAlies = StringUtils.isEmpty(tableAlies) ? "" : (tableAlies + "."); switch (orderStr) { case ORDER_SORT_TIME: { return " order by " + tableAlies + "order_type asc ," + tableAlies + "last_edit_time"; }/*from ww w . ja v a2 s. c om*/ case ORDER_SORT_TIME_DESC: { return " order by " + tableAlies + "order_type asc ," + tableAlies + "last_edit_time desc"; } case ORDER_SORT_TITLE: { return " order by " + tableAlies + " order_type asc,convert(" + tableAlies + "title using gb2312)"; } case ORDER_SORT_TITLE_DESC: { return " order by " + tableAlies + "order_type asc,convert(" + tableAlies + "title using gb2312) desc"; } default: return " order by " + tableAlies + "order_type asc "; } }
From source file:net.sf.yal10n.svn.RepositoryUtil.java
/** * Gets the complete URL, either using the mirror if specified or not. * * @param config the config//from w ww . j a v a2 s. c om * @param repo the repo * @return the svn url */ public static String getSvnUrl(DashboardConfiguration config, Repository repo) { String svnCheckoutUrl = getCheckoutUrl(config, repo); String mirrorUrl = SVNUtil.toCompleteUrl(config.getMirrorPrefix(), repo.getMirrorUrl()); String svnUrl = StringUtils.isEmpty(mirrorUrl) ? svnCheckoutUrl : mirrorUrl; return svnUrl; }
From source file:com.mmj.app.biz.cons.TopicOrderEnum.java
/** * ?name?//from ww w.j a va 2 s. com */ public static TopicOrderEnum getEnum(String name) { if (StringUtils.isEmpty(name)) { return null; } for (TopicOrderEnum current : values()) { if (StringUtils.equalsIgnoreCase(current.name, name)) { return current; } } return null; }
From source file:com.rogoman.easyauth.Base32Encoding.java
/** * Converts the BASE32 string input to a byte array. * * @param input BASE32 string input//www. j a va2 s. c o m * @return byte array */ static byte[] toBytes(final String input) { if (StringUtils.isEmpty(input)) { throw new IllegalArgumentException("input"); } String cleanInput = input.replaceAll("[=]+$", ""); //remove padding characters int byteCount = cleanInput.length() * 5 / 8; //this must be TRUNCATED byte[] returnArray = new byte[byteCount]; byte curByte = 0, bitsRemaining = 8; int mask, arrayIndex = 0; for (char c : cleanInput.toCharArray()) { int cValue = charToValue(c); if (bitsRemaining > 5) { mask = cValue << (bitsRemaining - 5); curByte = (byte) (curByte | mask); bitsRemaining -= 5; } else { mask = cValue >> (5 - bitsRemaining); curByte = (byte) (curByte | mask); returnArray[arrayIndex++] = curByte; curByte = (byte) (cValue << (3 + bitsRemaining)); bitsRemaining += 3; } } //if we didn't end with a full byte if (arrayIndex != byteCount) { returnArray[arrayIndex] = curByte; } return returnArray; }