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

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

Introduction

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

Prototype

public static String trimToEmpty(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null.

Usage

From source file:adalid.util.meta.CodeAnalyzerTreeVisitor.java

private void info(String string) {
    string = StringUtils.removeEnd(string, CM);
    //      string = StringUtils.remove(string, NL);
    string = StringUtils.replace(string, EOL, SP); // "<n>"
    //      string = StringUtils.remove(string, TB);
    string = StringUtils.replace(string, TAB, SP); // "<t>"
    string = StringUtils.remove(string, SP + SP);
    string = StringUtils.trimToEmpty(string);
    logger.info(tabs() + string);/*from   w w  w.ja  v a 2 s. co m*/
}

From source file:com.egt.ejb.core.sqlagent.SqlAgentBrokerBean.java

@Override
public ObjectMessage executeProcedure(String procedimiento, long funcion, Object[] args) {
    Bitacora.trace(this.getClass(), "executeProcedure", procedimiento, String.valueOf(funcion));
    Utils.traceObjectArray(args);//from w w  w.  j a v a2 s.co m
    Long rastro = null;
    ObjectMessage reply = null;
    try {
        procedimiento = StringUtils.trimToEmpty(procedimiento);
        if (STP.esIdentificadorArchivoValido(procedimiento)) {
            if (TLC.getControlador().esFuncionAutorizada(funcion)) {
                TLC.getConnection(ds);
                rastro = TLC.getControlador().ponerProcesoPendiente(funcion);
                SqlAgentMessage message = new SqlAgentMessage(procedimiento, funcion);
                TLC.getControlador().ponerUsuarioEnMensaje(message);
                message.setRastro(rastro);
                message.setMensaje(Bitacora.getTextoMensaje(CBM2.PROCESS_EXECUTION_REQUEST, procedimiento));
                message.setArgs(args);
                reply = messenger.send(message);
                TLC.getBitacora().info(message.getMensaje());
            } else {
                throw new ExcepcionAplicacion(
                        Bitacora.getTextoMensaje(CBM2.FUNCION_NO_AUTORIZADA, procedimiento));
            }
        } else {
            throw new ExcepcionAplicacion(
                    Bitacora.getTextoMensaje(CBM2.IDENTIFICADOR_ARCHIVO_INVALIDO, procedimiento));
        }
    } catch (Exception ex) {
        EnumCondicionEjeFun condicion = EnumCondicionEjeFun.EJECUCION_CANCELADA;
        String mensaje = ThrowableUtils.getString(ex);
        Auditor.grabarRastroProceso(rastro, condicion, null, mensaje);
        TLC.getBitacora().error(mensaje);
    }
    return reply;
}

From source file:com.hangum.tadpole.monitoring.core.dialogs.schedule.AddSQLDialog.java

@Override
protected void okPressed() {
    String txtTitle = StringUtils.trimToEmpty(textTitle.getText());
    String txtDesc = StringUtils.trimToEmpty(textDesc.getText());
    String txtSQL = StringUtils.trimToEmpty(textSQL.getText());

    if (StringUtils.isEmpty(txtTitle)) {
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().AddSQLDialog_4);
        textTitle.setFocus();// w ww .ja  v  a  2 s . c  o m
        return;
    }

    if (StringUtils.isEmpty(txtSQL)) {
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().AddSQLDialog_6);
        textSQL.setFocus();
        return;
    }

    dao.setName(txtTitle);
    dao.setDescription(txtDesc);
    dao.setSql(txtSQL);

    super.okPressed();
}

From source file:com.haulmont.cuba.core.entity.EntityStatistics.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(StringUtils.trimToEmpty(name));
    sb.append(": instanceCount=").append(instanceCount != null ? instanceCount : 0);
    if (lazyCollectionThreshold != null)
        sb.append(", lazyCollectionThreshold=").append(lazyCollectionThreshold);
    if (maxFetchUI != null)
        sb.append(", maxFetchUI=").append(maxFetchUI);
    return sb.toString();
}

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

public static Process executeExport(String informe, long funcion, String destino, EnumFormatoArchivo tipo,
        String select, Object[] args) {
    Bitacora.trace(Exporter.class, "executeExport", informe, String.valueOf(funcion), destino,
            String.valueOf(tipo));
    Bitacora.trace(select);//ww  w  .java  2s. c o  m
    Utils.traceObjectArray(args);
    Long rastro = null;
    Process subprocess = null;
    try {
        informe = StringUtils.trimToEmpty(informe);
        if (STP.esIdentificadorArchivoValido(informe)) {
            if (TLC.getControlador().esFuncionAutorizada(funcion)) {
                rastro = TLC.getControlador().ponerInformePendiente(funcion);
                String command = EA.getString(EAC.EXPORT_RUNNER_DIR) + EA.getString(EAC.EXPORT_RUNNER_CMD);
                command += " " + commandParameters(informe, rastro, destino, tipo, select, args);
                String[] envp = null;
                File dir = new File(EA.getString(EAC.EXPORT_RUNNER_DIR));
                Bitacora.trace(command);
                Bitacora.trace(dir.getPath());
                subprocess = Runtime.getRuntime().exec(command, envp, dir);
                TLC.getBitacora().info(CBM2.EXPORT_EXECUTION_REQUEST, informe);
            } else {
                throw new ExcepcionAplicacion(Bitacora.getTextoMensaje(CBM2.FUNCION_NO_AUTORIZADA, informe));
            }
        } else {
            throw new ExcepcionAplicacion(
                    Bitacora.getTextoMensaje(CBM2.IDENTIFICADOR_ARCHIVO_INVALIDO, informe));
        }
    } catch (Exception ex) {
        EnumCondicionEjeFun condicion = EnumCondicionEjeFun.EJECUCION_CANCELADA;
        String mensaje = ThrowableUtils.getString(ex);
        Auditor.grabarRastroInforme(rastro, condicion, null, mensaje);
        TLC.getBitacora().error(mensaje);
    }
    return subprocess;
}

From source file:com.eyeq.pivot4j.util.MarkupWriter.java

/**
 * @param content/*w  w  w . j a v a 2 s . c  om*/
 */
public void writeContent(String content) {
    if (formatOutput) {
        writeIndent();
    }

    writer.print(StringUtils.trimToEmpty(content));

    if (formatOutput) {
        writer.println();
    }
}

From source file:com.egt.core.aplicacion.Bitacora.java

public static void stamp(Object obj, String str) {
    String objeto = obj == null ? "" : getFirmaMetodo(obj, null, 0) + " ";
    stamp(objeto + StringUtils.trimToEmpty(str));
}

From source file:de.xirp.profile.CommunicationProtocol.java

/**
 * Returns the message handler main class name. The handler
 * handles messages sent from application to robot.
 * /*from   w  w  w . j  av a 2  s  . com*/
 * @return The message handler class name.
 */
@XmlTransient
public String getMessageHandler() {
    String trimToEmpty = StringUtils.trimToEmpty(messageHandler);
    return trimToEmpty;
}

From source file:net.ageto.gyrex.persistence.jdbc.pool.internal.commands.ListPools.java

private void printPool(final PoolDefinition pool) throws BackingStoreException {
    printf("Pool %s", pool.getPoolId());
    printf(StringUtils.EMPTY);//from  ww  w .  j  a v a 2s .c  om

    final Properties driverProperties = pool.getDriverProperties();
    if (!driverProperties.isEmpty()) {
        printf("Driver Properties:");
        final SortedSet<String> names = new TreeSet<String>();
        final Enumeration<?> propertyNames = driverProperties.propertyNames();
        while (propertyNames.hasMoreElements()) {
            names.add((String) propertyNames.nextElement());
        }
        for (final String key : names) {
            printf("  %35s: %s", key, StringUtils.trimToEmpty(driverProperties.getProperty(key)));
        }
        printf(StringUtils.EMPTY);
    }

    printf("Pool Statistics:");
    final BoneCPDataSource dataSource = (BoneCPDataSource) PoolActivator.getInstance().getRegistry()
            .getDataSource(pool.getPoolId());

    // test connectivity (this also works around a bug in BoneCP which would result in an NPE below)
    try {
        final Connection connection = dataSource.getConnection();
        if (connection instanceof ConnectionHandle) {
            printf("  %35s: %s", "connectionTest",
                    ((ConnectionHandle) connection).isValid(1000) ? "OK" : "NOT OK");
        } else {
            printf("  %35s: %s", "connectionSample", connection.toString());
        }
        connection.close();
    } catch (final SQLException e) {
        printf("  unable to connect to pool: %s", e.getMessage());
    }

    // total number of leased connections
    printf("  %35s: %d", "totalLeased", dataSource.getTotalLeased());
    printf(StringUtils.EMPTY);

    printf("Effective Pool Config:");
    final TreeMap<String, String> poolConfig = readPoolConfig(dataSource);
    for (final Entry<String, String> entry : poolConfig.entrySet()) {
        printf("  %35s: %s", entry.getKey(), entry.getValue());
    }
}

From source file:com.bluexml.xforms.generator.forms.ModelElement.java

/**
 * Builds the path section of the URI for the list action
 * /*  w  w w.j  a v  a 2 s  .  c  o  m*/
 * @param identifier
 * @param maxLength
 * @param formatPattern
 * @param typeCompleteName
 * @param dataSourceUri
 * @return
 */
protected String buildListActionUriFragment(String typeCompleteName, String formatPattern, String maxLength,
        String identifier, String filterAssoc, boolean isComposition, boolean isForSearchMode,
        String luceneQuery, String dataSourceUri) {
    // StringBuffer result = new StringBuffer(MsgId.INT_ACT_CODE_LIST.getText() + "/");
    // result.append(typeCompleteName).append("/");
    // result.append(StringUtils.trimToEmpty(formatPattern)).append("/");
    // result.append(maxLength).append("/");
    // result.append(StringUtils.trimToEmpty(identifier)).append("/");
    // result.append(StringUtils.trimToEmpty(filterAssoc)).append("/");
    // result.append(isComposition ? "1" : "0").append("/");
    // result.append(isForSearchMode ? "1" : "0").append("/");
    String queryEncoded = StringUtils.trimToEmpty(luceneQuery);
    try {
        // encoded twice (because of our using the "/" as a param separator in URIs) so that the
        // user doesn't have to encode "/" as "%252F"
        queryEncoded = URLEncoder.encode(queryEncoded, "UTF-8");
        queryEncoded = URLEncoder.encode(queryEncoded, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        queryEncoded = "";
    }
    // result.append(queryEncoded).append("/");
    // return result.toString();
    String result = MsgId.INT_ACT_CODE_LIST.getText() + "?";

    List<MsgId> param = new ArrayList<MsgId>();
    List<String> value = new ArrayList<String>();
    String isCompStr = isComposition ? "1" : "0";
    String isSearchStr = isForSearchMode ? "1" : "0";

    param.add(MsgId.INT_ACT_PARAM_ANY_DATATYPE);
    value.add(typeCompleteName);
    param.add(MsgId.INT_ACT_PARAM_LIST_FORMAT);
    value.add(formatPattern);
    param.add(MsgId.INT_ACT_PARAM_LIST_MAXLENGTH);
    value.add(maxLength);
    param.add(MsgId.INT_ACT_PARAM_LIST_IDENTIFIER);
    value.add(identifier);
    param.add(MsgId.INT_ACT_PARAM_LIST_FILTER_ASSOC);
    value.add(filterAssoc);
    param.add(MsgId.INT_ACT_PARAM_LIST_IS_COMPOSITION);
    value.add(isCompStr);
    param.add(MsgId.INT_ACT_PARAM_LIST_IS_SEARCH_MODE);
    value.add(isSearchStr);
    param.add(MsgId.INT_ACT_PARAM_LIST_LUCENE_QUERY);
    value.add(queryEncoded);
    if (dataSourceUri != null) {
        param.add(MsgId.INT_ACT_PARAM_LIST_DATA_SOURCE_URI);
        value.add(dataSourceUri.replaceAll("&", "@\\$@"));
    }

    for (int i = 0; i < param.size(); i++) {
        if (i > 0) {
            result += "&";
        }
        result += param.get(i) + "=" + StringUtils.trimToEmpty(value.get(i));
    }
    return result;
}