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:net.duckling.ddl.service.devent.impl.NoticeServiceImpl.java

private String getDEntityURL(DEventBody e) {
    DEntity t = e.getTarget();//from   w  w w .j a va2 s . c  o  m
    if (DEntity.DFILE.equals(t.getType())) {
        return urlGenerator.getURL(e.getTid(), UrlPatterns.T_VIEW_R, t.getId(), null);
    }
    if (DEntity.DPAGE.equals(t.getType())) {
        return urlGenerator.getURL(e.getTid(), UrlPatterns.T_VIEW_R, t.getId(), null);
    }
    if (DEntity.DFOLDER.equals(t.getType())) {
        return urlGenerator.getURL(e.getTid(), UrlPatterns.T_VIEW_R, t.getId(), null);
    }
    if (DEntity.DCOLLECTION.equals(t.getType())) {
        return urlGenerator.getURL(e.getTid(), UrlPatterns.VIEW_COLLECTION, t.getId(), null);
    }
    if (DEntity.DTEAM.equals(t.getType())) {
        return urlGenerator.getURL(e.getTid(), UrlPatterns.T_TEAM_HOME, t.getId(), null);
    }
    if (DEntity.DUSER.equals(t.getType())) {
        UserExt ext = aoneUserService.getUserExtInfo(t.getId());
        return urlGenerator.getURL(UrlPatterns.USER, ext.getId() + "", null);
    }
    // add by lvly@2012-6-25
    if (DEntity.DTASK_SHARE.equals(t.getType())) {
        String param = null;
        if (DAction.OVER_TASK.equals(e.getOperation())) {
            param = "&listType=allHistory";
        }
        return urlGenerator.getURL(UrlPatterns.T_TASK_PATTERNS, "", null) + "?taskId=" + t.getId()
                + "&taskType=" + TaskService.TYPE_SHARE + StringUtils.trimToEmpty(param);
    }
    if (DEntity.DTASK_INDEPENDENT.equals(t.getType())) {
        String param = null;
        if (DAction.OVER_TASK.equals(e.getOperation())) {
            param = "&listType=allHistory";
        }
        return urlGenerator.getURL(e.getTid(), UrlPatterns.T_TASK_PATTERNS, "", null) + "?taskId=" + t.getId()
                + "&taskType=" + TaskService.TYPE_INDEPENDENT + StringUtils.trimToEmpty(param);
    }

    return null;
}

From source file:com.prowidesoftware.swift.model.field.Field69B.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 */// ww  w.  ja v a 2  s.  co  m
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(":");
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("//");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append(StringUtils.trimToEmpty(getComponent3()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent4()));
    result.append(StringUtils.trimToEmpty(getComponent5()));
    return result.toString();
}

From source file:com.opengamma.bbg.loader.EquityLoader.java

@Override
protected void parseIdentifiers(final FudgeMsg fieldData, final ManageableSecurity security) {
    super.parseIdentifiers(fieldData, security);

    String marketSector = StringUtils.trimToEmpty(fieldData.getString(FIELD_MARKET_SECTOR_DES));
    if (!BloombergDataUtils.isValidField(marketSector)) {
        return;/*from   w ww . j a v a 2s. c o  m*/
    }
    String bbgExchangeCode;
    if (MARKET_SECTOR_PREFERRED.equals(marketSector)) {
        bbgExchangeCode = null;
    } else {
        bbgExchangeCode = StringUtils.trimToEmpty(fieldData.getString(FIELD_EXCH_CODE));
        if (!BloombergDataUtils.isValidField(bbgExchangeCode)) {
            bbgExchangeCode = null;
        }
    }

    String securityShortDes = StringUtils.trimToEmpty(fieldData.getString(FIELD_SECURITY_SHORT_DES));
    if (BloombergDataUtils.isValidField(securityShortDes)) {
        security.addExternalId(getTicker(securityShortDes, bbgExchangeCode, marketSector));
    } else {
        String securityDes = StringUtils.trimToEmpty(fieldData.getString(FIELD_SECURITY_DES));
        if (BloombergDataUtils.isValidField(securityDes)) {
            security.addExternalId(getTicker(securityDes, bbgExchangeCode, marketSector));
        }
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.OracleLoginComposite.java

@Override
public void crateComposite() {
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 3;//from  w  ww  .  j a  va 2 s .  c o  m
    gridLayout.horizontalSpacing = 3;
    gridLayout.marginHeight = 3;
    gridLayout.marginWidth = 3;
    setLayout(gridLayout);
    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Composite compositeBody = new Composite(this, SWT.NONE);
    compositeBody.setLayout(new GridLayout(2, false));
    compositeBody.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    Label lblOperationType = new Label(compositeBody, SWT.NONE);
    lblOperationType.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));
    lblOperationType.setText(Messages.MySQLLoginComposite_lblOperationType_text);

    comboOperationType = new Combo(compositeBody, SWT.READ_ONLY);
    comboOperationType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (DBOperationType opType : DBOperationType.values()) {
        comboOperationType.add(opType.getTypeName());
    }
    comboOperationType.select(1);

    Label lblGroupName = new Label(compositeBody, SWT.NONE);
    lblGroupName.setText(Messages.MySQLLoginComposite_lblGroupName_text);
    comboGroup = new Combo(compositeBody, SWT.NONE);
    comboGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    for (String strGroup : listGroupName)
        comboGroup.add(strGroup);

    Label lblNewLabel_1 = new Label(compositeBody, SWT.NONE);
    lblNewLabel_1.setText(Messages.DBLoginDialog_lblNewLabel_1_text);

    textDisplayName = new Text(compositeBody, SWT.BORDER);
    textDisplayName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    new Label(compositeBody, SWT.NONE);
    new Label(compositeBody, SWT.NONE);

    Label lblHost = new Label(compositeBody, SWT.NONE);
    lblHost.setText(Messages.DBLoginDialog_1);

    textHost = new Text(compositeBody, SWT.BORDER);
    textHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblNewLabelPort = new Label(compositeBody, SWT.NONE);
    lblNewLabelPort.setText(Messages.DBLoginDialog_5);

    textPort = new Text(compositeBody, SWT.BORDER);
    textPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    new Label(compositeBody, SWT.NONE);
    new Label(compositeBody, SWT.NONE);

    comboConnType = new Combo(compositeBody, SWT.READ_ONLY);
    comboConnType.add("SID");
    comboConnType.add("Service Name");
    comboConnType.select(0);

    textDatabase = new Text(compositeBody, SWT.BORDER);
    textDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblUser = new Label(compositeBody, SWT.NONE);
    lblUser.setText(Messages.DBLoginDialog_2);

    textUser = new Text(compositeBody, SWT.BORDER);
    textUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblPassword = new Label(compositeBody, SWT.NONE);
    lblPassword.setText(Messages.DBLoginDialog_3);

    textPassword = new Text(compositeBody, SWT.BORDER | SWT.PASSWORD);
    textPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    //      new Label(compositeBody, SWT.NONE);

    //      comboLocale = new Combo(compositeBody, SWT.NONE);
    //      comboLocale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    //      
    //         comboLocale.setVisibleItemCount(8);
    //         
    //         for(String val : DBLocaleUtils.getOracleList()) comboLocale.add(val);
    //         comboLocale.select(0);

    Button btnPing = new Button(compositeBody, SWT.NONE);
    btnPing.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String host = StringUtils.trimToEmpty(textHost.getText());
            String port = StringUtils.trimToEmpty(textPort.getText());

            if ("".equals(host) || "".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
                MessageDialog.openError(null, Messages.DBLoginDialog_10, Messages.DBLoginDialog_11);
                return;
            }

            try {
                if (isPing(host, port)) {
                    MessageDialog.openInformation(null, Messages.DBLoginDialog_12, Messages.DBLoginDialog_13);
                } else {
                    MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.DBLoginDialog_15);
                }
            } catch (NumberFormatException nfe) {
                MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4);
            }
        }
    });
    btnPing.setText(Messages.DBLoginDialog_btnPing_text);

    init();
}

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

public static Process executeReport(String informe, long funcion, String destino, EnumFormatoInforme tipo,
        String select, Object[] args) {
    Bitacora.trace(Reporter.class, "executeReport", informe, String.valueOf(funcion), destino,
            String.valueOf(tipo));
    Bitacora.trace(select);//from   w w  w .ja  v a  2s .co  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.REPORT_RUNNER_DIR) + EA.getString(EAC.REPORT_RUNNER_CMD);
                command += " " + commandParameters(informe, rastro, destino, tipo, select, args);
                String[] envp = null;
                File dir = new File(EA.getString(EAC.REPORT_RUNNER_DIR));
                Bitacora.trace(command);
                Bitacora.trace(dir.getPath());
                subprocess = Runtime.getRuntime().exec(command, envp, dir);
                TLC.getBitacora().info(CBM2.REPORT_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.prowidesoftware.swift.model.field.Field90J.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from  w ww. j  a  v  a 2s.  com
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(":");
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("//");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent3()));
    result.append(StringUtils.trimToEmpty(getComponent4()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent5()));
    result.append(StringUtils.trimToEmpty(getComponent6()));
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field90F.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*from w  w w  .j a  v a  2s  .  co m*/
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(":");
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("//");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent3()));
    result.append(StringUtils.trimToEmpty(getComponent4()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent5()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent6()));
    return result.toString();
}

From source file:com.prowidesoftware.swift.model.field.Field98H.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///w  ww.  j  av a 2s  .com
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent2())) {
        result.append(",");
        result.append(StringUtils.trimToEmpty(getComponent2()));
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())
            || org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())) {
        result.append("/");
        if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) {
            result.append(StringUtils.trimToEmpty(getComponent3()));
        }
        result.append(StringUtils.trimToEmpty(getComponent4()));
    }
    return result.toString();
}

From source file:com.edgenius.wiki.render.impl.LinkRenderHelperImpl.java

public ObjectPosition appendExtSpaceLink(StringBuffer buffer, String extSpaceUname, String link, String view,
        String anchor) {//ww w  . ja v a2 s  . com
    extSpaceUname = StringUtils.trimToEmpty(extSpaceUname);
    link = StringUtils.trimToEmpty(link);
    view = StringUtils.trimToEmpty(view);
    anchor = StringUtils.trimToEmpty(anchor);

    ObjectPosition pos = new ObjectPosition("[" + view + "]");
    pos.serverHandler = LinkHandler.HANDLER;
    pos.uuid = context.createUniqueKey(false);
    pos.values.put(NameConstants.TYPE, String.valueOf(LinkModel.LINK_TO_VIEW_FLAG));
    pos.values.put(NameConstants.SPACE, extSpaceUname);
    pos.values.put(NameConstants.NAME, link);
    pos.values.put(NameConstants.VIEW, view);
    pos.values.put(NameConstants.ANCHOR, anchor);
    context.getObjectList().add(pos);
    buffer.append(pos.uuid);
    return pos;
}

From source file:com.prowidesoftware.swift.model.field.Field42D.java

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from   www .  ja  v a  2s  .  com
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    boolean wroteSomething = false;
    if (getComponent1() != null) {
        result.append("/" + StringUtils.trimToEmpty(getComponent1()));
        wroteSomething = true;
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent2())) {
        result.append("/" + getComponent2());
        wroteSomething = true;
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) {
        if (wroteSomething) {
            result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
        }
        result.append(StringUtils.trimToEmpty(getComponent3()));
        wroteSomething = true;
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent4())) {
        if (wroteSomething) {
            result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
        }
        result.append(StringUtils.trimToEmpty(getComponent4()));
        wroteSomething = true;
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent5())) {
        if (wroteSomething) {
            result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
        }
        result.append(StringUtils.trimToEmpty(getComponent5()));
        wroteSomething = true;
    }
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent6())) {
        if (wroteSomething) {
            result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL);
        }
        result.append(StringUtils.trimToEmpty(getComponent6()));
    }
    return result.toString();
}