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:com.bagdemir.eboda.validator.PageNumberValidator.java
@Override public ValidationResult<Integer> validate(final String input) { final ValidationResult<Integer> validationResult = new ValidationResult<>(); if (StringUtils.isBlank(input)) { registerError(validationResult, "Page number shouldn't be an integer value: null"); } else {//from ww w . java 2s . c o m validatePageNumber(input, validationResult); } return validationResult; }
From source file:com.intuit.tank.vm.event.NotificationContext.java
public NotificationContext addContextEntry(String key, String value) { this.context.put(key, StringUtils.isBlank(value) ? "N/A" : value); return this; }
From source file:ar.com.zauber.commons.web.transformation.utils.WebValidate.java
/** * Valida que la URI termine con / y que no este en blanco sino * lanza una excepcion./*from w w w . ja va 2 s . c o m*/ * * @param uri URI a validar. * @throws IllegalArgumentException if uri does not validate */ public static void uriNotBlank(final String uri) throws IllegalArgumentException { Validate.isTrue(!StringUtils.isBlank(uri)); uriWellFormed(uri); }
From source file:ar.com.zauber.commons.repository.query.values.PropertyValue.java
/** Creates the PropertyValue. */ public PropertyValue(final String otherProperty) { Validate.isTrue(!StringUtils.isBlank(otherProperty)); this.otherProperty = otherProperty; }
From source file:com.zigbee.framework.common.dto.CodeTextRegistry.java
public Map<String, String> getStatusMap(String code) { if (StringUtils.isBlank(code)) { return null; }/*from www. j ava 2 s . c o m*/ return Collections.unmodifiableMap(codeTextMap.get(code)); }
From source file:de.thischwa.pmcms.tool.connection.PathAnalyzer.java
public PathAnalyzer(final String targetPath) { if (StringUtils.isBlank(targetPath)) throw new IllegalArgumentException("TargetPath shouldn't be null!"); int pos = StringUtils.lastIndexOf(targetPath, '/'); if (pos == -1 || pos == 0) { dir = ""; if (pos == -1) name = targetPath;/*from w ww .j a v a 2 s .c o m*/ else name = targetPath.substring(1); } else { dir = targetPath.substring(0, StringUtils.lastIndexOf(targetPath, '/')); name = targetPath.substring(StringUtils.lastIndexOf(targetPath, '/'), targetPath.length()); if (name.startsWith("/")) name = name.substring(1); if (dir.startsWith("/")) dir = dir.substring(1); } }
From source file:com.mozilla.bagheera.util.IdUtil.java
/** * Takes a given id and prefixes it with a byte character and the date in a non-random fashion * This method expects id to be something like a UUID consisting only of hex characters. If id * is something else this will produce unpredictable results. * @param id//from www .j ava 2 s. com * @param d * @return * @throws IOException */ public static byte[] nonRandByteBucketizeId(String id, Date d) throws IOException { if (StringUtils.isBlank(id)) { throw new IllegalArgumentException("id cannot be null or empty"); } if (d == null) { throw new IllegalArgumentException("date cannot be null"); } // bucket byte + SDF bytes + id bytes ByteBuffer buf = ByteBuffer.allocate(9 + id.length()); int bucket = 0; if (id.length() >= 2) { // Munge two hex characters into the range of a single byte bucket = Integer.parseInt(id.substring(0, 2), 16) - 128; } else { bucket = Integer.parseInt(id, 16) - 128; } buf.put((byte) bucket); buf.put(SDF.format(d).getBytes()); buf.put(id.getBytes()); return buf.array(); }
From source file:com.ah.ui.actions.tools.ClientMgmtTestAction.java
@Override public String execute() { try {/* w ww . j av a 2 s .c om*/ if ("test".equals(operation)) { jsonObject = new JSONObject(); String customerId = LicenseOperationTool.getCustomerIdFromRemote(getDomain().getInstanceId()); PairValue<Boolean, PairValue<String, String>> rtnvalue = CertificateGenSV .troubleshooting(customerId, getDomain()); String message = rtnvalue.getDesc().getValue(); String warningMessage = rtnvalue.getDesc().getDesc(); if (rtnvalue.getValue()) { jsonObject.put("succ", true); if (StringUtils.isBlank(message)) { jsonObject.put("msg", MgrUtil.getUserMessage("home.hmSettings.clientManagement.troubleshooting.success")); } } else { jsonObject.put("succ", false); if (Integer.parseInt(message) > 0) { message = MgrUtil.getEnumString(CertificateGenSV.TROUBLESHOOTING_EXCEPTION + message); } jsonObject.put("msg", MgrUtil.getUserMessage( "home.hmSettings.clientManagement.troubleshooting.failure.reason", message)); } if (StringUtils.isNotBlank(warningMessage)) { jsonObject.put("warn", warningMessage); } return "json"; } } catch (Exception e) { } return SUCCESS; }
From source file:com.googlecode.jtiger.modules.ecside.core.bean.TableDefaults.java
static String getStyleClass(TableModel model, String styleClass) { if (StringUtils.isBlank(styleClass)) { return model.getPreferences().getPreference(PreferencesConstants.TABLE_STYLE_CLASS); }/*from ww w .jav a 2s .c om*/ return styleClass; }
From source file:com.michelin.cio.hudson.plugins.qc.QualityCenterUtils.java
/** * Checks the Quality Center server URL. *///from w ww . ja v a2 s . co m public static FormValidation checkQcServerURL(String value, Boolean acceptEmpty) { String url; // Path to the page to check if the server is alive String page = "servlet/tdservlet/TDAPI_GeneralWebTreatment"; // Do will allow empty value? if (StringUtils.isBlank(value)) { if (!acceptEmpty) { return FormValidation.error(Messages.QualityCenter_ServerURLMustBeDefined()); } else { return FormValidation.ok(); } } // Does the URL ends with a "/" ? if not, add it if (value.lastIndexOf("/") == value.length() - 1) { url = value + page; } else { url = value + "/" + page; } // Open the connection and perform a HEAD request HttpURLConnection connection; try { connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestMethod("HEAD"); // Check the response code if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { return FormValidation.error(connection.getResponseMessage()); } } catch (MalformedURLException ex) { // This is not a valid URL return FormValidation.error(Messages.QualityCenter_MalformedServerURL()); } catch (IOException ex) { // Cant open connection to the server return FormValidation.error(Messages.QualityCenter_ErrorOpeningServerConnection()); } return FormValidation.ok(); }