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:io.github.lucaseasedup.logit.cooldown.Cooldown.java
public Cooldown(String name) { if (StringUtils.isBlank(name)) throw new IllegalArgumentException(); this.name = name; }
From source file:com.bstek.dorado.view.output.StylePropertyOutputter.java
public boolean isEscapeValue(Object value) { if (value == null) { return true; }/*from ww w. j av a 2 s . co m*/ if (value instanceof String) { return StringUtils.isBlank((String) value); } else if (value instanceof Map) { return ((Map<?, ?>) value).isEmpty(); } return true; }
From source file:de.codesourcery.eve.skills.datamodel.CharacterID.java
public CharacterID(String id) { if (StringUtils.isBlank(id)) { throw new IllegalArgumentException("character ID cannot be blank / NULL"); }/* www. ja v a2 s .c o m*/ this.id = id; }
From source file:nc.noumea.mairie.appock.core.utility.TelUtil.java
/** * Formatte un numro de tlphone, en se basant sur la librairie google libPhoneNumber. Si le numro n'est pas reconnu, le numro est retourn tel quel * sans les blancs devant/derrire.//from w w w . j a va 2 s .c o m * * @param tel numro de tlphone traiter * @return "" si le tlphone en entre est "vide" (null ou blanc) */ public static String formatteTel(String tel) { if (StringUtils.isBlank(tel)) { return ""; } try { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); PhoneNumber phoneNumber = phoneUtil.parse(tel, FORMAT_PHONE_NC); return phoneUtil.format(phoneNumber, PhoneNumberFormat.NATIONAL); } catch (Exception e) { // en cas d'erreur, on se contente de retourner le tel pass en entre, sans les blancs devant/derrire return StringUtils.trimToEmpty(tel); } }
From source file:name.chengchao.myhttpclient.version3_1.HttpClient3UtilError.java
/** * ?url?ResponseBody,method=get// w w w . j av a2 s.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.spotify.docker.CompositeImageName.java
/** * An image name can be a plain image name or in the composite format <name>:<tag> and * this factory method makes sure that we get the plain image name as well as all the desired tags * for an image, including any composite tag. */// ww w. j a v a 2 s.c o m static CompositeImageName create(final String imageName, final List<String> imageTags) throws MojoExecutionException { final String name = StringUtils.substringBeforeLast(imageName, ":"); if (StringUtils.isBlank(name)) { throw new MojoExecutionException("imageName not set!"); } final List<String> tags = new ArrayList<>(); final String tag = StringUtils.substringAfterLast(imageName, ":"); if (StringUtils.isNotBlank(tag)) { tags.add(tag); } if (imageTags != null) { tags.addAll(imageTags); } if (tags.size() == 0) { throw new MojoExecutionException("No tag included in imageName and no imageTags set!"); } return new CompositeImageName(name, tags); }
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.PeriodDeltaXmlValidationTest.java
public void testValidteElement() { amendment.getDeltas().clear();/*from ww w .j a v a2s. co m*/ assertFalse(StringUtils.isBlank(periodDeltaXmlSerializer.validate(amendment, ePeriod))); assertEquals(String.format( "\n released amendment present in the system does have any delta matching with provied grid id %s and node id %s of delta.\n", periodDelta.getGridId(), period3.getGridId()), periodDeltaXmlSerializer.validate(amendment, ePeriod).toString()); amendment.addDelta(periodDelta); assertTrue(StringUtils.isBlank(periodDeltaXmlSerializer.validate(amendment, ePeriod))); }
From source file:com.egt.core.jsf.component.BotonBuscar.java
private boolean isRenderedToo() { String script = this.getOnClick(); return StringUtils.isBlank(script) ? false : this.getSibling() instanceof TextField ? this.getSibling().isRendered() && !((TextField) this.getSibling()).isReadOnly() : true;// w ww. j av a 2 s . co m }
From source file:com.enonic.cms.domain.security.user.UsernameResolver.java
public String resolveUsername(final StoreNewUserCommand command) { userName = command.getUsername();//from ww w. ja v a 2 s. c om displayName = command.getDisplayName(); UserInfo userInfo = command.getUserInfo(); if (userInfo != null) { setUserInfoFields(userInfo); } String resolvedUsername = doResolve(); if (StringUtils.isBlank(resolvedUsername)) { throw new IllegalArgumentException("Could not resolve user name"); } return stripBlankspaces(resolvedUsername); }
From source file:com.beginner.core.utils.Base64Util.java
/** * Base64/* w w w. j av a 2 s.c o m*/ * @param plaintext * @param encoding ?? * @return */ public static String encrypt(String plaintext, String encoding) { if (StringUtils.isBlank(plaintext)) return plaintext; try { return new String(encodeBase64(plaintext.getBytes(encoding))); } catch (UnsupportedEncodingException e) { return plaintext; } }