List of usage examples for org.springframework.util StringUtils isEmpty
public static boolean isEmpty(@Nullable Object str)
From source file:com.cherong.mock.common.base.util.EncryptionUtil.java
public static String md5L32(String unencryptedText) { if (StringUtils.isEmpty(unencryptedText)) { LOGGER.info("unencryptedText is null."); return unencryptedText; }//from w w w .java 2 s . c om String ciphertext = ""; try { MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[] bytes = md5.digest(unencryptedText.getBytes("UTF-8")); StringBuffer buffer = new StringBuffer(); for (byte b : bytes) { int bt = b & 0xff; if (bt < 16) { buffer.append(0); } buffer.append(Integer.toHexString(bt)); } ciphertext = buffer.toString(); LOGGER.info("encrypt string {} to {};", unencryptedText, ciphertext); } catch (Exception e) { LOGGER.error(e.getMessage()); } return ciphertext; }
From source file:com.appleframework.cache.jedis.misc.URIBuilder.java
public static URI create(String uri, int database, String password) { String[] parts = uri.split(":"); if (parts.length - 1 >= 3) { String port = parts[parts.length - 1]; uri = "[" + uri.replace(":" + port, "") + "]:" + port; }//from w w w . jav a 2 s . com if (StringUtils.isEmpty(password)) { return URI.create("redis://" + uri + "/" + database); } else { return URI.create("redis://" + password + "@" + uri + "/" + database); } }
From source file:com.github.zhanhb.ckfinder.connector.utils.PathUtils.java
/** * Escapes double slashes (//) and replaces backslashes characters (\) with * slashes (/). <br>// ww w . ja v a 2 s . c o m * <strong>NOTE:</strong> This method preserves UNC paths. * * @param string string to escapeUrl * @return Escaped string, {@code null} or empty string. */ public static String normalizeUrl(String string) { if (StringUtils.isEmpty(string)) { return string; } final int prefixIndex = string.indexOf("://"); String prefix; String suffix; if (prefixIndex > -1) { prefix = string.substring(0, prefixIndex + 2); suffix = string.substring(prefixIndex + 2); } else { prefix = ""; suffix = string; } suffix = suffix.replace('\\', '/'); // preserve // at the beginning for UNC paths if (suffix.startsWith("//")) { return prefix + "/" + suffix.replaceAll("/+", "/"); } else { return prefix.concat(suffix.replaceAll("/+", "/")); } }
From source file:io.github.vdubois.codechecker.common.AssertionUtils.java
/** * @param field field to test/*from w ww . j a v a 2 s . c o m*/ * @param stringToTest value to test * @throws IllegalArgumentException if field is not filled */ public static void assertFieldFilled(String field, String stringToTest) { if (StringUtils.isEmpty(stringToTest)) { throw new IllegalArgumentException(field + " must be filled"); } }
From source file:cn.guoyukun.spring.web.form.bind.SearchBindStatus.java
public static Object getValue(PageContext pageContext, String name) { if (StringUtils.isEmpty(name)) { return null; }//from w w w .ja va2s. co m Object value = null; String[] parameters = pageContext.getRequest().getParameterValues(name); if (parameters != null && parameters.length == 1) { value = parameters[0]; } else { value = parameters; } //??? // if(value == null || (value instanceof String && StringUtils.isEmpty((String) value))) { // Object attributeValue = pageContext.findAttribute(name); // if(attributeValue != null) { // value = attributeValue; // } // } return value; }
From source file:com.abuabdul.knodex.utils.KnodexUtil.java
public static KnodexDoc convertFormToDocObject(KnodexForm knodexForm) { log.debug("Entered KnodexUtil.convertFormToDocObject method"); String sentenceKey = ""; KnodexDoc knodexDoc = null;/* w w w . ja va2 s.c om*/ if (knodexForm != null) { knodexDoc = new KnodexDoc(); if (!StringUtils.isEmpty(knodexForm.getIndexSentence())) { log.debug("Knodex Sentence entered by the user " + knodexForm.getIndexSentence()); knodexDoc.setIndexSentence(knodexForm.getIndexSentence().trim()); char indexKey = knodexDoc.getIndexSentence().charAt(0); sentenceKey = String.valueOf(indexKey).toUpperCase(); knodexDoc.setKey(sentenceKey); String[] index = knodexDoc.getIndexSentence().split("-"); if (index.length > 1) { log.debug("Knodex Sentence actual indexBy value " + index[0]); log.debug("Knodex Sentence actual sentence value " + index[1]); knodexDoc.setIndexBy(index[0].trim()); knodexDoc.setIndexSentence(index[1].trim()); } else { knodexDoc.setIndexBy(sentenceKey); } } if (StringUtils.isEmpty(knodexDoc.getIndexSentence()) || StringUtils.isEmpty(knodexDoc.getIndexBy())) { knodexDoc = null; } } return knodexDoc; }
From source file:com.vmware.licensecheck.service.HelloWorldService.java
public String getTitle(String name) { logger.debug("getTitle() is executed! $name : {}", name); if (StringUtils.isEmpty(name)) { return "Hello World"; } else {//from w w w . jav a2 s.c o m return "Hello " + name; } }
From source file:com.cxy.service.Impl.IdentityImpl.java
@Override public int saveIdentity(Identity identity, String path) { if (!StringUtils.isEmpty(identity.getIdCard())) { identity.setIdCard(path);/*w ww . ja v a 2 s.c o m*/ } else if (!StringUtils.isEmpty(identity.getLicense())) { identity.setLicense(path); } else if (!StringUtils.isEmpty(identity.getGraduation())) { identity.setGraduation(path); } identity.setCreateTime(UserTools.getCurrentTime()); return mapper.insert(identity); }
From source file:com.jive.myco.seyren.api.util.DateTimeParam.java
public DateTimeParam(String value) { if (StringUtils.isEmpty(value)) { this.value = null; } else {//from w ww .ja v a 2 s . com this.value = DateTime.parse(value); } }
From source file:com.dickthedeployer.dick.web.mapper.BuildMapper.java
public static Map<String, Build.Status> getBuildStatusMap(Build build) { Map<String, Build.Status> buildStatusMap = new HashMap<>(); boolean afterCurrentStage = StringUtils.isEmpty(build.getCurrentStage()); for (String stageName : build.getStages()) { if (stageName.equals(build.getCurrentStage())) { buildStatusMap.put(stageName, build.getStatus()); afterCurrentStage = true;/* w w w. ja v a2 s . c o m*/ } else { if (afterCurrentStage) { buildStatusMap.put(stageName, Build.Status.READY); } else { buildStatusMap.put(stageName, Build.Status.DEPLOYED); } } } return buildStatusMap; }