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.devnexus.ting.web.converter.StringToPresentationType.java
@Override public PresentationType convert(String source) { if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) { return null; } else {//from w w w . j ava 2 s. c om return PresentationType.fromId(Long.valueOf(source)); } }
From source file:com.devnexus.ting.web.converter.StringToPurchaseGroup.java
@Override public TicketGroup convert(String source) { if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) { return null; } else {/*from w ww . ja v a2 s . co m*/ return TicketGroup.fromId(Long.valueOf(source)); } }
From source file:net.bulletin.pdi.xero.step.support.Helpers.java
/** * <p>If the value is provided then this method will augment the supplied URL by adding on the * query to the URL.</p>//from w w w .ja v a 2 s . co m */ public static StringBuilder appendUrlQuery(StringBuilder url, String key, String value) { if (null == url || 0 == url.length()) { throw new IllegalArgumentException("the supplied url may not be empty."); } if (StringUtils.isEmpty(key)) { throw new IllegalArgumentException("the supplied query key may not be empty."); } if (StringUtils.isNotBlank(value)) { url.append(-1 == url.indexOf("?") ? '?' : '&'); url.append(key); url.append("="); try { url.append(URLEncoder.encode(value, CharEncoding.UTF_8)); } catch (UnsupportedEncodingException uee) { throw new IllegalStateException("the encoding must be supported; " + CharEncoding.UTF_8); } } return url; }
From source file:com.bbva.arq.devops.ae.mirrorgate.jenkins.plugin.utils.CredentialsUtils.java
/** * Get the credentials identified by the given id from the Jenkins * credential store.//from w w w . jav a 2s . c o m * * @param <T> * @param credentialsId The id for the credentials * @param credentialsClass The class of credentials to return * @return Jenkins credentials */ public static <T extends Credentials> T getJenkinsCredentials(final String credentialsId, final Class<T> credentialsClass) { if (StringUtils.isEmpty(credentialsId)) { return null; } return CredentialsMatchers .firstOrNull( CredentialsProvider.lookupCredentials(credentialsClass, Jenkins.getInstance(), ACL.SYSTEM, Collections.<DomainRequirement>emptyList()), CredentialsMatchers.withId(credentialsId)); }
From source file:com.vmware.appfactory.recipe.RecipeMatch.java
/** * Compare a string value from a recipe key to a string value from an * application, and return what kind of a match that is. * @param keyValue/*from w w w. ja v a 2 s . com*/ * @param appValue * @return */ public static RecipeMatch match(String keyValue, String appValue) { if (StringUtils.isEmpty(keyValue) && StringUtils.isEmpty(appValue)) { /* Both empty: that's a precise match */ return precise; } else if (StringUtils.isEmpty(keyValue) && StringUtils.isNotEmpty(appValue)) { /* Key is empty, value is not: that's a partial match */ return partial; } else if (keyValue.equals(appValue)) { /* Both the same: that's a precise match */ return precise; } return none; }
From source file:fm.last.syscommand.SysCommandUtils.java
/** * Converts a command line string to a List of Strings that can be passed to a ProcessBuilder. Splits string by space * characters but allows whitespace if contained within single or double quotes or for whitespace to be escaped by * "\".// ww w . j av a 2 s .c om * * @param commandString Command line string. * @return The commandString converted to a List of Strings. */ public static List<String> convertCommand(String commandString) { List<String> command = new ArrayList<String>(); StringBuilder currentCommand = new StringBuilder(); boolean insideSingleQuotes = false; boolean insideDoubleQuotes = false; for (int i = 0; i < commandString.length(); i++) { Character previousChar = null; if (i > 0) { previousChar = commandString.charAt(i - 1); } char currentChar = commandString.charAt(i); if (currentChar == ' ' && !insideSingleQuotes && !insideDoubleQuotes && (previousChar != null && previousChar != '\\')) { if (!StringUtils.isEmpty(currentCommand.toString())) { command.add(currentCommand.toString().trim()); currentCommand = new StringBuilder(); continue; } } if (currentChar == '\'') { insideSingleQuotes = !insideSingleQuotes; } else if (currentChar == '\"') { insideDoubleQuotes = !insideDoubleQuotes; } currentCommand.append(currentChar); } if (!StringUtils.isEmpty(currentCommand.toString())) { command.add(currentCommand.toString().trim()); } return command; }
From source file:net.bible.service.db.mynote.MyNoteDto.java
public boolean isEmpty() { return StringUtils.isEmpty(noteText); }
From source file:edu.harvard.iq.dataverse.NavigationWrapper.java
public String getRedirectPage() { return !StringUtils.isEmpty(getPageFromContext()) ? "?redirectPage=" + getPageFromContext() : ""; }
From source file:com.haulmont.cuba.web.toolkit.ui.converters.SimpleStringToIntegerConverter.java
@Override public Integer convertToModel(String value, Class<? extends Integer> targetType, Locale locale) throws ConversionException { if (StringUtils.isEmpty(value)) { return null; }/*from w w w. java2 s . c om*/ try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionException(e); } }
From source file:com.abiquo.server.core.util.network.IPAddress.java
/** * Checks the correct format of the ipAddress and returns empty string if is not correct. * //from w ww .j a va 2 s. co m * @param ipAddress proposed ipAddress * @return IPAddress reference or null if it's not valid */ public static IPAddress newIPAddress(String ipAddress) { if (!StringUtils.isEmpty(ipAddress)) { Pattern p = Pattern.compile(IPADDRESS_PATTERN); Matcher m = p.matcher(ipAddress); boolean matches = m.matches(); if (matches) return new IPAddress(ipAddress); } return null; }