List of usage examples for org.apache.commons.lang StringUtils isBlank
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
From source file:de.doncarnage.minecraft.baseplugin.util.ItemUtil.java
/** * Returns the corresponding item for the given item and sub string. * * @param item the wanted item, e.g. log or step * @param sub the data byte of the material * @return a {@link MaterialData} instance reflecting this item *//* ww w .j a v a 2s . c o m*/ @SuppressWarnings("deprecation") public static MaterialData getMaterialDataByString(String item, String sub) { Preconditions.checkNotNull(item); Material mat = Material.getMaterial(item.toUpperCase()); if (mat == null) { return null; } MaterialData matData = new MaterialData(mat); if (!StringUtils.isBlank(sub)) { try { matData.setData(Byte.parseByte(sub)); } catch (NumberFormatException nfe) { return null; } } return matData; }
From source file:com.switchfly.inputvalidation.canonicalizer.QueryStringCanonicalizer.java
@Override public String execute(String content) { if (StringUtils.isBlank(content)) { return content; }//ww w . j ava 2 s . co m String s = super.execute(content); try { s = URLDecoder.decode(s, "UTF-8"); } catch (Exception e) { throw new RuntimeException(e); } return s; }
From source file:com.adobe.acs.commons.util.PathInfoUtil.java
/** * Get a named Query Parameter from the Request. * * @param request//from ww w . j a va 2s .c o m * @param key * @param dfault Value to return if Query Parameter value is blank * @return */ public static String getQueryParam(final SlingHttpServletRequest request, final String key, final String dfault) { String tmp = request.getParameter(key); if (StringUtils.isBlank(tmp)) { return dfault; } return tmp; }
From source file:net.praqma.hudson.scm.pollingmode.PollingModeDescriptor.java
public FormValidation doCheckComponent(@QueryParameter String component) { if (StringUtils.isBlank(component)) { return FormValidation.error("Component field cannot be empty"); } else {//w ww. java2s . c o m if (!component.contains("@\\")) { return FormValidation.errorWithMarkup( "Components must be entered with the correct syntax. <em>Syntax: [component]@[PVOB]</em>"); } } return FormValidation.ok(); }
From source file:com.zxy.commons.memcache.MemcacheFactory.java
private static MemcachedClient getObjectJava() { String servers = MemcachePropUtils.getServers(); if (StringUtils.isBlank(servers)) { throw new AssertionError("Parameter servers must not be empty."); }// ww w .ja v a2 s . c o m MemcachedClientBuilder builder = new XMemcachedClientBuilder(servers); builder.setConnectionPoolSize(MemcachePropUtils.getConnectPoolSize()); builder.setConnectTimeout(MemcachePropUtils.getInstance().getLong("connectTimeout")); try { return builder.build(); } catch (IOException e) { throw new AssertionError(e); } }
From source file:name.chengchao.myhttpclient.version3_1.HttpClient3Util.java
/** * ?url?ResponseBody,method=get//ww w . ja va 2s .c o m * * @param url exp:http://192.168.1.1:8080/dir/target.html * @return byte[]? */ public static byte[] getDataFromUrl(String url, int timeout) { if (StringUtils.isBlank(url)) { logger.error("url is blank!"); return null; } HttpClient httpClient = new HttpClient(); // httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(8000); // ? httpClient.getParams().setSoTimeout(timeout); GetMethod method = new GetMethod(url); // fix??? method.setRequestHeader("Connection", "close"); // ??1 method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false)); try { int statusCode = httpClient.executeMethod(method); if (statusCode == HttpStatus.SC_OK) { return method.getResponseBody(); } else { throw new RuntimeException("http request error,return code:" + statusCode + ",msg:" + new String(method.getResponseBody())); } } catch (HttpException e) { method.abort(); logger.error(e.getMessage()); } catch (IOException e) { method.abort(); logger.error(e.getMessage()); } finally { // Release the connection. method.releaseConnection(); } return null; }
From source file:com.feedzai.fos.api.util.ManagerUtils.java
/** * Obtain model UUID from ModelConfig if defined or generate a new random uuid * * @param config Model Configuration/*ww w . ja va2 s. c om*/ * @return new Model UUID * @throws com.feedzai.fos.api.FOSException */ public static UUID getUuid(ModelConfig config) throws FOSException { String suuid = config.getProperty("UUID"); return StringUtils.isBlank(suuid) ? UUID.randomUUID() : UUID.fromString(suuid); }
From source file:com.sunyue.util.calculator.impl.parser.SimpleExpressionParser.java
public Object[] parse(String expression) { if (StringUtils.isBlank(expression)) { throw new CalculationException("Expression can not be blank"); }/*from ww w . j a v a 2 s . com*/ char[] exp = expression.toCharArray(); StringBuilder buffer = new StringBuilder(100); List<Object> result = new ArrayList<Object>(); for (int i = 0; i < exp.length; i++) { String current = String.valueOf(exp[i]); if (AbstractExpressionParser.SPACE.equals(current) || AbstractExpressionParser.COMMA.equals(current)) { // space or comma addToken(result, buffer.toString()); clear(buffer); } else if (Bracket.LEFT_BRACKET.getSymbol().equals(current)) { // "(" addToken(result, buffer.toString(), Bracket.LEFT_BRACKET); clear(buffer); } else if (Bracket.RIGHT_BRACKET.getSymbol().equals(current)) { // ")" addToken(result, buffer.toString(), Bracket.RIGHT_BRACKET); clear(buffer); } else if (isOperator(current)) { // operator addToken(result, buffer.toString(), getOperator(current)); clear(buffer); } else { // other buffer.append(current); } } addToken(result, buffer.toString()); return result.toArray(); }
From source file:com.enonic.cms.core.content.contentdata.custom.support.XmlDataEntryParser.java
public XmlDataEntry parse(final Element containerElement, final DataEntryConfig inputConfig) { final List list = containerElement.getChildren(); String value = ""; if (!list.isEmpty()) { final Element xmlRootNode = (Element) list.get(0); value = elementToString(xmlRootNode); }/* ww w .j a v a2s.co m*/ if (StringUtils.isBlank(value)) { return new XmlDataEntry(inputConfig, null); } return new XmlDataEntry(inputConfig, value); }
From source file:io.github.lucaseasedup.logit.profile.field.Field.java
public Field(String name) { if (StringUtils.isBlank(name)) throw new IllegalArgumentException(); this.name = name; }