List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:$.DocumentQuery.java
/** * ?,???//from w w w.j av a 2 s .c o m * * @param PersonId * @param searchName * @return */ public static List<Document> findPersnalDocuments(long PersonId, String searchName) { List<Document> documents = Document.findByOneTag(UPLOADED_BY, longToString(PersonId)); List<Document> results = new ArrayList<Document>(); if (StringUtils.isEmpty(searchName)) { return documents; } for (Document document : documents) { if (!document.getName().contains(searchName)) { continue; } results.add(document); } return results; }
From source file:com.weibo.api.motan.util.StringTools.java
public static String urlEncode(String value) { if (StringUtils.isEmpty(value)) { return ""; }//from w w w . ja v a2s .c om try { return URLEncoder.encode(value, MotanConstants.DEFAULT_CHARACTER); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.alacoder.lion.common.utils.StringTools.java
public static String urlEncode(String value) { if (StringUtils.isEmpty(value)) { return ""; }// w w w . ja v a 2 s .c o m try { return URLEncoder.encode(value, LionConstants.DEFAULT_CHARACTER); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:io.cloudslang.content.database.services.SQLQueryLobService.java
public static boolean executeSqlQueryLob(SQLInputs sqlInputs) throws Exception { if (StringUtils.isEmpty(sqlInputs.getSqlCommand())) { throw new Exception("command input is empty."); }// w w w . j a va2s.co m boolean isLOB = false; ConnectionService connectionService = new ConnectionService(); try (final Connection connection = connectionService.setUpConnection(sqlInputs)) { StringBuilder strColumns = new StringBuilder(sqlInputs.getStrColumns()); connection.setReadOnly(true); Statement statement = connection.createStatement(sqlInputs.getResultSetType(), sqlInputs.getResultSetConcurrency()); statement.setQueryTimeout(sqlInputs.getTimeout()); ResultSet results = statement.executeQuery(sqlInputs.getSqlCommand()); ResultSetMetaData mtd = results.getMetaData(); int iNumCols = mtd.getColumnCount(); for (int i = 1; i <= iNumCols; i++) { if (i > 1) strColumns.append(sqlInputs.getStrDelim()); strColumns.append(mtd.getColumnLabel(i)); } sqlInputs.setStrColumns(strColumns.toString()); int nr = -1; while (results.next()) { nr++; final StringBuilder strRowHolder = new StringBuilder(); for (int i = 1; i <= iNumCols; i++) { if (i > 1) strRowHolder.append(sqlInputs.getStrDelim()); Object columnObject = results.getObject(i); if (columnObject != null) { String value; if (columnObject instanceof java.sql.Clob) { isLOB = true; final File tmpFile = File.createTempFile("CLOB_" + mtd.getColumnLabel(i), ".txt"); copyInputStreamToFile( new ReaderInputStream(results.getCharacterStream(i), StandardCharsets.UTF_8), tmpFile); if (sqlInputs.getLRowsFiles().size() == nr) { sqlInputs.getLRowsFiles().add(nr, new ArrayList<String>()); sqlInputs.getLRowsNames().add(nr, new ArrayList<String>()); } sqlInputs.getLRowsFiles().get(nr).add(tmpFile.getAbsolutePath()); sqlInputs.getLRowsNames().get(nr).add(mtd.getColumnLabel(i)); value = "(CLOB)..."; } else { value = results.getString(i); if (sqlInputs.isNetcool()) value = SQLUtils.processNullTerminatedString(value); } strRowHolder.append(value); } else strRowHolder.append("null"); } sqlInputs.getLRows().add(strRowHolder.toString()); } } return isLOB; }
From source file:de.micromata.genome.gwiki.page.impl.wiki.MacroAttributesUtils.java
public static Map<String, String> decode(String text) { Map<String, String> map = new HashMap<String, String>(); if (StringUtils.isEmpty(text) == true) return map; text = trim(text);/*from ww w . j a v a 2 s . c o m*/ List<String> tlist = Converter.parseStringTokens(text, "|\\=", true); if (tlist.size() == 0) return map; if (tlist.size() == 1) { map.put(MacroAttributes.DEFAULT_VALUE_KEY, tlist.get(0)); return map; } StringBuilder sb = new StringBuilder(); String curKey = null; String curValue = null; State state = State.ParseKey; for (int i = 0; i < tlist.size(); ++i) { String t = tlist.get(i); if ("\\".equals(t) == true) { ++i; t = tlist.get(i); sb.append(t); continue; } else if ("=".equals(t) == true) { if (state == State.ParseValue) { sb.append(t); continue; } curKey = sb.toString(); sb = new StringBuilder(); state = State.ParseValue; } else if ("|".equals(t) == true) { // if (state != State.ParseValue) { // //eigentlich fehler // throw new IllegalStateException("Parsing '|' in state: " + state); // } curValue = sb.toString(); map.put(curKey, curValue); sb = new StringBuilder(); curKey = null; curValue = null; state = State.ParseKey; } else { sb.append(t); } } if (curKey != null) { curValue = sb.toString(); map.put(curKey, StringUtils.defaultString(curValue)); } return map; }
From source file:atg.tools.dynunit.util.PropertiesUtil.java
public static void setSystemPropertyIfEmpty(final String key, final String value) { logger.entry(key, value);/* w w w .j av a 2 s .c om*/ if (StringUtils.isEmpty(getSystemProperty(key))) { setSystemProperty(key, value); } logger.exit(); }
From source file:AIR.Common.Json.JsonHelper.java
public static <T> T deserialize(String json, Class<T> class1) throws JsonParseException, JsonMappingException, IOException { if (StringUtils.isEmpty(json)) return null; ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(json, class1); }
From source file:com.webbfontaine.valuewebb.model.validators.CurrencyRateValidator.java
public static boolean isValid(String currencyCode, Date date) { boolean isValid; if (StringUtils.isEmpty(currencyCode)) { isValid = true;/*from w ww .j a v a 2 s . c o m*/ } else { RefSelect refSelect = (RefSelect) Component.getInstance(RefSelect.class, true); isValid = !refSelect.getRate(date, currencyCode).equals(Rate.EMPTY_INSTANCE); } return isValid; }
From source file:com.github.dozermapper.core.classmap.MappingDirection.java
public static MappingDirection valueOf(String mappingDirection) { if (BI_DIRECTIONAL_VALUE.equals(mappingDirection)) { return BI_DIRECTIONAL; } else if (ONE_WAY_VALUE.equals(mappingDirection)) { return ONE_WAY; } else if (StringUtils.isEmpty(mappingDirection)) { return null; }/*www . j av a 2 s .c o m*/ throw new IllegalStateException("type should be bi-directional or one-way. " + mappingDirection); }
From source file:com.arvato.thoroughly.exception.TmallAppException.java
private static String initErrorMessage(String code, String msg, Object body) { if (StringUtils.isEmpty(msg)) { msg = "Unknown exception, please contact the administrator."; }/*from w ww . ja v a 2 s . c o m*/ tmallAppResponse = new TmallAppResponse(code, msg, body); String responseJson = CommonUtils.getGsonByBuilder(false).toJson(tmallAppResponse); return responseJson; }