List of usage examples for org.apache.commons.lang StringUtils stripToNull
public static String stripToNull(String str)
Strips whitespace from the start and end of a String returning null
if the String is empty ("") after the strip.
From source file:ips1ap101.lib.core.db.util.InterpreteSqlPostgreSQL.java
@Override public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) { boolean retornaResultadoCompuesto = EnumTipoResultadoSQL.COMPOUND.equals(tipoResultado); String execute = StringUtils.stripToNull(comando); String command = retornaResultadoCompuesto ? COMANDO_EXECUTE_2 : COMANDO_EXECUTE_1; if (execute != null) { String[] token = StringUtils.split(execute); String parametros = "()"; if (argumentos > 0) { parametros = ""; for (int i = 0; i < argumentos; i++, parametros += ",?") { }// ww w. ja va 2s .c o m parametros = "(" + parametros.substring(1) + ")"; } if (!token[0].equalsIgnoreCase(COMANDO_EXECUTE_1)) { execute = command + " " + execute; } if (!execute.endsWith(parametros) && !execute.endsWith(";")) { execute += parametros; } } return execute; }
From source file:gov.nih.nci.calims2.taglib.form.ButtonTag.java
/** * @param url the url to set */ public void setUrl(String url) { this.url = StringUtils.stripToNull(url); }
From source file:com.adobe.acs.tools.csv_asset_importer.impl.Parameters.java
public Parameters(SlingHttpServletRequest request) throws IOException { final RequestParameter charsetParam = request.getRequestParameter("charset"); final RequestParameter delimiterParam = request.getRequestParameter("delimiter"); final RequestParameter fileParam = request.getRequestParameter("file"); final RequestParameter multiDelimiterParam = request.getRequestParameter("multiDelimiter"); final RequestParameter separatorParam = request.getRequestParameter("separator"); final RequestParameter fileLocationParam = request.getRequestParameter("fileLocation"); final RequestParameter importStrategyParam = request.getRequestParameter("importStrategy"); final RequestParameter updateBinaryParam = request.getRequestParameter("updateBinary"); final RequestParameter mimeTypePropertyParam = request.getRequestParameter("mimeTypeProperty"); final RequestParameter skipPropertyParam = request.getRequestParameter("skipProperty"); final RequestParameter absTargetPathPropertyParam = request.getRequestParameter("absTargetPathProperty"); final RequestParameter relSrcPathPropertyParam = request.getRequestParameter("relSrcPathProperty"); final RequestParameter uniquePropertyParam = request.getRequestParameter("uniqueProperty"); final RequestParameter ignorePropertiesParam = request.getRequestParameter("ignoreProperties"); final RequestParameter throttleParam = request.getRequestParameter("throttle"); final RequestParameter batchSizeParam = request.getRequestParameter("batchSize"); this.charset = DEFAULT_CHARSET; if (charsetParam != null) { this.charset = StringUtils.defaultIfEmpty(charsetParam.toString(), DEFAULT_CHARSET); }/*from ww w . java2s.c o m*/ this.delimiter = null; if (delimiterParam != null && StringUtils.isNotBlank(delimiterParam.toString())) { this.delimiter = delimiterParam.toString().charAt(0); } this.separator = null; if (separatorParam != null && StringUtils.isNotBlank(separatorParam.toString())) { this.separator = separatorParam.toString().charAt(0); } this.multiDelimiter = "|"; if (multiDelimiterParam != null && StringUtils.isNotBlank(multiDelimiterParam.toString())) { this.multiDelimiter = multiDelimiterParam.toString(); } this.importStrategy = ImportStrategy.FULL; if (importStrategyParam != null && StringUtils.isNotBlank(importStrategyParam.toString())) { this.importStrategy = ImportStrategy.valueOf(importStrategyParam.toString()); } this.updateBinary = false; if (updateBinaryParam != null && StringUtils.isNotBlank(updateBinaryParam.toString())) { this.updateBinary = StringUtils.equalsIgnoreCase(updateBinaryParam.toString(), "true"); } this.fileLocation = "/dev/null"; if (fileLocationParam != null && StringUtils.isNotBlank(fileLocationParam.toString())) { this.fileLocation = fileLocationParam.toString(); } this.skipProperty = null; if (skipPropertyParam != null && StringUtils.isNotBlank(skipPropertyParam.toString())) { skipProperty = StringUtils.stripToNull(skipPropertyParam.toString()); } this.mimeTypeProperty = null; if (mimeTypePropertyParam != null && StringUtils.isNotBlank(mimeTypePropertyParam.toString())) { mimeTypeProperty = StringUtils.stripToNull(mimeTypePropertyParam.toString()); } this.absTargetPathProperty = null; if (absTargetPathPropertyParam != null && StringUtils.isNotBlank(absTargetPathPropertyParam.toString())) { this.absTargetPathProperty = StringUtils.stripToNull(absTargetPathPropertyParam.toString()); } this.relSrcPathProperty = null; if (relSrcPathPropertyParam != null && StringUtils.isNotBlank(relSrcPathPropertyParam.toString())) { this.relSrcPathProperty = StringUtils.stripToNull(relSrcPathPropertyParam.toString()); } this.uniqueProperty = null; if (uniquePropertyParam != null && StringUtils.isNotBlank(uniquePropertyParam.toString())) { this.uniqueProperty = StringUtils.stripToNull(uniquePropertyParam.toString()); } this.ignoreProperties = new String[] { CsvAssetImporterServlet.TERMINATED }; if (ignorePropertiesParam != null && StringUtils.isNotBlank(ignorePropertiesParam.toString())) { final String[] tmp = StringUtils.split(StringUtils.stripToNull(ignorePropertiesParam.toString()), ","); final List<String> list = new ArrayList<String>(); for (final String t : tmp) { String val = StringUtils.stripToNull(t); if (val != null) { list.add(val); } } list.add(CsvAssetImporterServlet.TERMINATED); this.ignoreProperties = list.toArray(new String[] {}); } if (fileParam != null && fileParam.getInputStream() != null) { this.file = fileParam.getInputStream(); } this.throttle = DEFAULT_THROTTLE; if (throttleParam != null && StringUtils.isNotBlank(throttleParam.toString())) { try { this.throttle = Long.valueOf(throttleParam.toString()); if (this.throttle < 0) { this.throttle = DEFAULT_THROTTLE; } } catch (Exception e) { this.throttle = DEFAULT_THROTTLE; } } batchSize = DEFAULT_BATCH_SIZE; if (batchSizeParam != null && StringUtils.isNotBlank(batchSizeParam.toString())) { try { this.batchSize = Integer.valueOf(batchSizeParam.toString()); if (this.batchSize < 1) { this.batchSize = DEFAULT_BATCH_SIZE; } } catch (Exception e) { this.batchSize = DEFAULT_BATCH_SIZE; } } }
From source file:gov.nih.nci.calims2.taglib.form.FormWidgetTag.java
/** * @param type the type to set */ public void setType(String type) { this.type = StringUtils.stripToNull(type); }
From source file:com.egt.core.db.util.InterpreteSqlOracle.java
@Override public String getNombreTabla(String tabla) { return StringUtils.upperCase(StringUtils.stripToNull(tabla)); }
From source file:gov.nih.nci.calims2.taglib.form.ValidationTextBoxTag.java
/** * @param pattern the pattern to set */ public void setPattern(String pattern) { this.pattern = StringUtils.stripToNull(pattern); }
From source file:com.activecq.experiments.redis.impl.RedisSessionUtilImpl.java
@Override public String getId(final SlingHttpServletRequest request) { final Cookie cookie = request.getCookie(this.getSessionCookieName()); if (cookie != null) { return StringUtils.stripToNull(cookie.getValue()); }/*from w w w . java 2 s . com*/ return null; }
From source file:gov.nih.nci.calims2.ui.generic.crud.CRUDTableDecorator.java
/** * Formats the given value according to its type and the current locale. * @param column The column/* ww w .j av a 2 s .com*/ * * @param value The value to format * @return The formatted value */ public String formatValue(Column column, Object value) { if (value == null) { return ""; } if (value instanceof I18nEnumeration) { return ((I18nEnumeration) value).getLocalizedValue(locale); } if (value instanceof DateTime) { return getDateTimeFormatter(column).print((DateTime) value); } if (value instanceof BigDecimal) { return ((BigDecimal) value).toPlainString(); } if (value instanceof Collection<?>) { ExpressionParser expressionParser = new SpelExpressionParser(); Expression expression = expressionParser.parseExpression(StringUtils.stripToNull(column.getFormat())); StringBuilder builder = new StringBuilder(); for (Object entity : (Collection<?>) value) { EvaluationContext context = new StandardEvaluationContext(entity); Object expresionValue = evaluateExpression(expression, context); if (expresionValue != null) { builder.append(expresionValue.toString()); builder.append("<br/>"); } } return builder.toString(); } return value.toString(); }
From source file:edu.ku.brc.specify.rstools.WorkbenchRowPlacemarkWrapper.java
public Pair<Double, Double> getLatLon() { GeoRefConverter converter = new GeoRefConverter(); initExportData();/* ww w . ja va2s . c o m*/ Double latitude = null; Double longitude = null; for (WorkbenchDataItem wbdi : dataList) { WorkbenchTemplateMappingItem wbtmi = mappings.get(wbdi.getColumnNumber()); if (wbtmi.getFieldName().equals("latitude1")) { String valStr = wbdi.getCellData(); if (StringUtils.isNotEmpty(valStr)) { String latStr; try { latStr = converter.convert(StringUtils.stripToNull(valStr), GeoRefFormat.D_PLUS_MINUS.name()); latitude = UIHelper.parseDouble(latStr); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(WorkbenchRowPlacemarkWrapper.class, e); latitude = null; } } } else if (wbtmi.getFieldName().equals("longitude1")) { String valStr = wbdi.getCellData(); if (StringUtils.isNotEmpty(valStr)) { String lonStr; try { lonStr = converter.convert(StringUtils.stripToNull(valStr), GeoRefFormat.D_PLUS_MINUS.name()); longitude = UIHelper.parseDouble(lonStr); } catch (Exception e) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(WorkbenchRowPlacemarkWrapper.class, e); longitude = null; } } } } if (latitude != null && longitude != null) { return new Pair<Double, Double>(latitude, longitude); } return null; }
From source file:com.opengamma.web.analytics.rest.WebUiResource.java
@Path("{viewId}/pauseOrResume") @PUT//from w ww . j a va 2 s . c o m public Response pauseOrResumeView(@PathParam("viewId") String viewId, @FormParam("state") String state) { ViewClient viewClient = _viewManager.getViewCient(viewId); state = StringUtils.stripToNull(state); Response response = Response.status(Response.Status.BAD_REQUEST).build(); if (state != null) { ViewClientState currentState = viewClient.getState(); state = state.toUpperCase(); switch (state) { case "PAUSE": case "P": if (currentState != ViewClientState.TERMINATED) { viewClient.pause(); response = Response.ok().build(); } break; case "RESUME": case "R": if (currentState != ViewClientState.TERMINATED) { viewClient.resume(); response = Response.ok().build(); } break; default: s_logger.warn("client {} requesting for invalid view client state change to {}", viewId, state); response = Response.status(Response.Status.BAD_REQUEST).build(); break; } } return response; }