Example usage for org.apache.commons.lang StringUtils stripToNull

List of usage examples for org.apache.commons.lang StringUtils stripToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils stripToNull.

Prototype

public static String stripToNull(String str) 

Source Link

Document

Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.

Usage

From source file:com.ansorgit.plugins.bash.documentation.DocumentationProvider.java

/**
 * Returns an external link to a command.
 *
 * @param element         The element for which the documentation is requested.
 * @param originalElement The element the caret was on.
 * @return The url which leads to the online documentation.
 *///  w  ww .j  ava2s.  com
static String documentationUrl(PsiElement element, PsiElement originalElement) {
    log.info("documentationUrl for " + element);
    for (DocumentationSource source : sourceList) {
        String url = source.documentationUrl(element, originalElement);
        if (StringUtils.stripToNull(url) != null) {
            return url;
        }
    }

    return null;
}

From source file:gov.nih.nci.calims2.taglib.form.DateTextBoxTag.java

/**
 * @param formatLength the formatLength to set
 *//*  w w w .  j  a v  a2s .  c  om*/
public void setFormatLength(String formatLength) {
    this.formatLength = StringUtils.stripToNull(formatLength);
}

From source file:com.opengamma.web.config.WebConfigResource.java

@GET
@Produces(MediaType.APPLICATION_JSON)// w  ww.  j  av  a  2 s.  c o m
public Response getJSON(@Context final Request request) {
    final EntityTag etag = new EntityTag(data().getConfig().getUniqueId().toString());
    final ResponseBuilder builder = request.evaluatePreconditions(etag);
    if (builder != null) {
        return builder.build();
    }
    final FlexiBean out = createRootData();
    final ConfigDocument doc = data().getConfig();
    final String jsonConfig = StringUtils.stripToNull(toJSON(doc.getConfig().getValue(), doc.getType()));
    if (jsonConfig != null) {
        out.put("configJSON", jsonConfig);
    }
    out.put("configXML", StringEscapeUtils.escapeJava(createXML(doc)));
    out.put("type", doc.getType().getSimpleName());
    final String json = getFreemarker().build(JSON_DIR + "config.ftl", out);
    return Response.ok(json).tag(etag).build();
}

From source file:com.egt.core.db.util.InterpreteSqlSQLServer.java

@Override
public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) {
    boolean retornaResultadoCompuesto = EnumTipoResultadoSQL.COMPUESTO.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 += ",?") {
            }//w ww . ja v a  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;
        }
    }
    Bitacora.trace(execute);
    return execute;
}

From source file:gov.nih.nci.calims2.taglib.form.FileInputTag.java

/**
 * @param promptMessage the promptMessage to set
 *///from  www.jav  a 2s  .c om
public void setPromptMessage(String promptMessage) {
    this.promptMessage = StringUtils.stripToNull(promptMessage);
}

From source file:ips1ap101.lib.core.db.util.InterpreteSqlSQLServer.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 += ",?") {
            }/*from   ww  w .  j  a v a 2 s  .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;
        }
    }
    Bitacora.trace(execute);
    return execute;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.LocalityRecFinalizer.java

@Override
public void finalizeForWrite(DataModelObjBase rec, int recNum, Uploader uploader) throws UploaderException {
    //This assumes that rec is a newly uploaded/created record. 
    //XXX Updates -- Will need to be re-worked when record updates are implemented
    Locality loc = (Locality) rec;/*ww  w  .j  a va2  s .c om*/
    WorkbenchRow wbRow = uploader.getWb().getRow(uploader.getRow());
    loc.setLat1text(wbRow.getLat1Text());
    loc.setLat2text(wbRow.getLat2Text());
    loc.setLong1text(wbRow.getLong1Text());
    loc.setLong2text(wbRow.getLong2Text());
    if (loc.getLatitude1() != null && loc.getLatLongType() == null) {
        if (loc.getLatitude2() == null) {
            //seems there's no formal definition of the allowed values for latlongtype??
            loc.setLatLongType("Point");
        } else {
            //hmmm...assume Line
            loc.setLatLongType("Line");
        }
    }
    LatLonConverter.FORMAT fmt = new GeoRefConverter()
            .getLatLonFormat(StringUtils.stripToNull(wbRow.getLat1Text()));
    loc.setOriginalLatLongUnit(fmt.ordinal());
    loc.setSrcLatLongUnit((byte) fmt.ordinal());

}

From source file:com.adobe.acs.commons.forms.impl.FormsRouterImpl.java

/**
 * Gets the Form Selector for the form POST request.
 *
 * @param slingRequest/*  w  w w . j  av a 2s  .c  o  m*/
 * @return
 */
@Override
public final String getFormSelector(final SlingHttpServletRequest slingRequest) {
    final String requestSuffix = slingRequest.getRequestPathInfo().getSuffix();
    if (StringUtils.equals(requestSuffix, this.getSuffix())
            || !StringUtils.startsWith(requestSuffix, this.getSuffix() + "/")) {
        return null;
    }

    final int segments = StringUtils.split(this.getSuffix(), '/').length;
    if (segments < 1) {
        return null;
    }

    final String formSelector = PathInfoUtil.getSuffixSegment(slingRequest, segments);
    return StringUtils.stripToNull(formSelector);
}

From source file:gov.nih.nci.calims2.ui.report.query.QueryForm.java

/**
 * Gets the clause rows from the request.
 * /*from ww w.ja v a  2 s  .  c o m*/
 * @return The list of clause rows
 */
public List<ClauseRow> getClauseRows() {
    List<ClauseRow> rows = new ArrayList<ClauseRow>();
    if (property != null) {
        for (int i = 0; i < property.size(); i++) {
            String propertyName = StringUtils.trimToEmpty(property.get(i));
            if (StringUtils.isNotEmpty(propertyName)) {
                ClauseRow row = new ClauseRow();
                row.setPropertyName(propertyName);
                row.setPropertyType(StringUtils.stripToEmpty(propertyType.get(i)));
                row.setOperator(Operator.valueOf(operator.get(i)));
                row.setValue(StringUtils.stripToEmpty(value.get(i)));
                if (connector != null && i < connector.size()) {
                    String connectorName = StringUtils.stripToNull(connector.get(i));
                    if (connectorName != null) {
                        row.setConnector(LogicalConnector.valueOf(connectorName));
                    }
                }
                row.setClauseIndex(i);
                rows.add(row);
            }
        }
    }
    return rows;
}

From source file:gov.nih.nci.calims2.taglib.form.FileInputTag.java

/**
 * @param toolTipPosition the toolTipPosition to set
 *//*from   w w w  . ja  v  a  2 s.  co  m*/
public void setToolTipPosition(String toolTipPosition) {
    this.toolTipPosition = StringUtils.stripToNull(toolTipPosition);
}