List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:controllers.require.RequireApp.java
/** * // ww w . j ava 2 s.c om */ @Transactional(readOnly = true) public static Result index() { DynamicForm requestData = Form.form().bindFromRequest(); ListOrderedMap cts = SkillTag.getCacheCategory(); Integer page = StringUtils.isBlank(requestData.get("page")) ? 1 : new Integer(requestData.get("page")); Integer pageSize = StringUtils.isBlank(requestData.get("pageSize")) ? 10 : new Integer(requestData.get("pageSize")); Long categoryId = StringUtils.isBlank(requestData.get("categoryId")) ? (Long) cts.asList().get(0) : new Long(requestData.get("categoryId")); String type = requestData.get("type") == null ? "html" : requestData.get("type"); Page<RequireListVO> returnPage = Require.queryRequireByPage(page, pageSize, categoryId); if (!type.equals("json")) { return ok(views.html.require.index.render(returnPage, cts, categoryId)); } return ok(play.libs.Json.toJson(returnPage)); }
From source file:net.packet.MetricInterval.java
public static MetricInterval fromValue(String value) { if (StringUtils.isBlank(value)) { throw new IllegalArgumentException("Value cannot be null or empty!"); }/*from w w w . j a v a 2 s . c o m*/ for (MetricInterval mi : MetricInterval.values()) { if (value.equalsIgnoreCase(mi.value)) { return mi; } } throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); }
From source file:com.trenako.validation.MoneyValidator.java
private static boolean validCurrency(Money m) { if (StringUtils.isBlank(m.getCurrency())) return false; try {//from w w w .j av a 2 s .c o m Currency.getInstance(m.getCurrency()); return true; } catch (IllegalArgumentException ex) { // currencyCode is not a supported ISO 4217 code } return false; }
From source file:com.esri.geoevent.test.performance.jaxb.TestType.java
public static TestType fromValue(String valueStr) { if (StringUtils.isBlank(valueStr)) return UNKNOWN; if (RAMP.toString().equalsIgnoreCase(valueStr) || RAMP.name().equalsIgnoreCase(valueStr)) return RAMP; else if (STRESS.toString().equalsIgnoreCase(valueStr) || STRESS.name().equalsIgnoreCase(valueStr)) return STRESS; else if (TIME.toString().equalsIgnoreCase(valueStr) || TIME.name().equalsIgnoreCase(valueStr)) return TIME; else/*from w w w. j a v a2 s . c o m*/ return UNKNOWN; }
From source file:com.thoughtworks.go.util.FilenameUtil.java
public static boolean isNormalizedPathOutsideWorkingDir(String path) { final String normalize = FilenameUtils.normalize(path); final String prefix = FilenameUtils.getPrefix(normalize); return (normalize != null && StringUtils.isBlank(prefix)); }
From source file:com.nesscomputing.syslog4j.impl.message.modifier.AbstractSyslogMessageModifier.java
public static String[] parseInlineModifier(String message, String prefix, String suffix) { String[] messageAndModifier = null; if (StringUtils.isBlank(message)) { return null; }/*from w w w.ja v a 2 s .c om*/ if (StringUtils.isBlank(prefix)) { prefix = " "; } if (StringUtils.isBlank(suffix)) { int pi = message.lastIndexOf(prefix); if (pi > -1) { messageAndModifier = new String[] { message.substring(0, pi), message.substring(pi + prefix.length()) }; } } else { int si = message.lastIndexOf(suffix); if (si > -1) { int pi = message.lastIndexOf(prefix, si); if (pi > -1) { messageAndModifier = new String[] { message.substring(0, pi), message.substring(pi + prefix.length(), si) }; } } } return messageAndModifier; }
From source file:jease.site.Discussions.java
/** * Adds a comment with given values to given Discussion. Visible flag * indicates if added comment should be visible or not. * /*from ww w .ja v a 2s . c om*/ * Returns null on success, otherwise an error message. */ public static String addComment(Discussion discussion, String author, String subject, String comment, boolean visible) { if (StringUtils.isBlank(subject) || StringUtils.isBlank(author) || StringUtils.isBlank(comment)) { return I18N.get("All_fields_are_required"); } if (subject.length() > MAX_SUBJECT_LENGTH || author.length() > MAX_AUTHOR_LENGTH || comment.length() > MAX_COMMENT_LENGTH) { return I18N.get("Input_is_too_long"); } // Escape all user input subject = StringEscapeUtils.escapeHtml4(subject); author = StringEscapeUtils.escapeHtml4(author); comment = StringEscapeUtils.escapeHtml4(comment); // Save comment to database. discussion.addComment(subject, author, comment, visible); Nodes.save(discussion); // Send email for review to editor in charge. String recipient = discussion.getEditor().getEmail(); if (StringUtils.isNotBlank(recipient)) { Mails.dispatch(recipient, recipient, String.format("%s (%s)", subject, author), comment); } return null; }
From source file:com.manisha.allmybooksarepacked.utility.JSONUtils.java
@SuppressWarnings("unchecked") public static <T> List<T> JSONToObjectList(String json, Class<T> elementClass) throws IOException { if (StringUtils.isBlank(json)) return (List<T>) Collections.EMPTY_LIST; return mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, elementClass)); }
From source file:com.vmware.photon.controller.api.frontend.lib.UsageTagHelper.java
public static List<UsageTag> deserialize(String concatenatedUsageTags) { if (StringUtils.isBlank(concatenatedUsageTags)) { throw new IllegalArgumentException("Blank string cannot be deserialized to list of UsageTags"); }/*from w w w .j ava2 s . c om*/ try { List<UsageTag> usageTags = objectMapper.readValue(concatenatedUsageTags, new TypeReference<List<UsageTag>>() { }); Collections.sort(usageTags); return usageTags; } catch (IOException e) { logger.error(String.format("Error deserializing UsageTag %s", concatenatedUsageTags), e); throw new IllegalArgumentException( String.format("Error deserializing UsageTag %s", concatenatedUsageTags), e); } }
From source file:ch.aonyx.broker.ib.api.contract.SecurityType.java
public static final SecurityType fromAbbreviation(final String abbreviation) { if (StringUtils.isBlank(abbreviation)) { return EMPTY; }/*from w w w. ja va 2 s. c o m*/ final String abbreviationUpperCase = abbreviation.toUpperCase(); if (MAP.containsKey(abbreviationUpperCase)) { return MAP.get(abbreviationUpperCase); } return UNKNOWN; }