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:com.haulmont.cuba.web.app.folders.FolderEditWindow.java

public FolderEditWindow(boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) {
    this.folder = folder;
    this.commitHandler = commitHandler;

    messages = AppBeans.get(Messages.NAME);
    messagesPack = AppConfig.getMessagesPack();
    userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Configuration configuration = AppBeans.get(Configuration.NAME);
    clientConfig = configuration.getConfig(ClientConfig.class);

    setCaption(adding ? getMessage("folders.folderEditWindow.adding") : getMessage("folders.folderEditWindow"));

    ThemeConstants theme = App.getInstance().getThemeConstants();
    setWidthUndefined();/*from  w w w  . jav a  2s  .  c om*/
    setResizable(false);

    int[] modifiers = { ShortcutAction.ModifierKey.CTRL };
    addAction(new ShortcutListener("commit", com.vaadin.event.ShortcutAction.KeyCode.ENTER, modifiers) {
        @Override
        public void handleAction(Object sender, Object target) {
            commit();
        }
    });

    layout = new VerticalLayout();
    layout.setWidthUndefined();
    layout.setSpacing(true);

    setContent(layout);
    setModal(true);
    center();

    String fieldWidth = theme.get("cuba.web.FolderEditWindow.field.width");

    nameField = new TextField();
    nameField.setRequired(true);
    nameField.setCaption(getMessage("folders.folderEditWindow.nameField"));
    nameField.setWidth(fieldWidth);
    nameField.setValue(folder.getName());
    nameField.focus();
    layout.addComponent(nameField);

    tabNameField = new TextField();
    tabNameField.setCaption(getMessage("folders.folderEditWindow.tabNameField"));
    tabNameField.setWidth(fieldWidth);
    tabNameField.setValue(StringUtils.trimToEmpty(folder.getTabName()));
    layout.addComponent(tabNameField);

    parentSelect = new ComboBox();
    parentSelect.setCaption(getMessage("folders.folderEditWindow.parentSelect"));
    parentSelect.setWidth(fieldWidth);
    parentSelect.setNullSelectionAllowed(true);
    fillParentSelect();
    parentSelect.setValue(folder.getParent());
    layout.addComponent(parentSelect);

    if (folder instanceof SearchFolder) {
        if (presentations != null) {
            presentation = new ComboBox();
            presentation.setCaption(getMessage("folders.folderEditWindow.presentation"));
            presentation.setWidth(fieldWidth);
            presentation.setNullSelectionAllowed(true);
            fillPresentations(presentations);
            presentation.setValue(((SearchFolder) folder).getPresentation());
            layout.addComponent(presentation);
        } else if (((SearchFolder) folder).getPresentation() != null) {
            selectedPresentationField = new TextField();
            selectedPresentationField.setWidth(fieldWidth);
            selectedPresentationField.setCaption(getMessage("folders.folderEditWindow.presentation"));
            selectedPresentationField.setValue(((SearchFolder) folder).getPresentation().getName());
            selectedPresentationField.setEnabled(false);
            layout.addComponent(selectedPresentationField);
        }
    }

    sortOrderField = new TextField();
    sortOrderField.setCaption(getMessage("folders.folderEditWindow.sortOrder"));
    sortOrderField.setWidth(fieldWidth);
    sortOrderField.setValue(folder.getSortOrder() == null ? "" : folder.getSortOrder().toString());
    layout.addComponent(sortOrderField);

    if (userSessionSource.getUserSession().isSpecificPermitted("cuba.gui.searchFolder.global")
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet())) {
        globalCb = new CubaCheckBox(getMessage("folders.folderEditWindow.global"));
        globalCb.setValue(((SearchFolder) folder).getUser() == null);
        layout.addComponent(globalCb);
    }

    applyDefaultCb = new CubaCheckBox(getMessage("folders.folderEditWindow.applyDefault"));
    applyDefaultCb.setValue(BooleanUtils.isTrue(((AbstractSearchFolder) folder).getApplyDefault()));
    applyDefaultCb.setVisible(clientConfig.getGenericFilterManualApplyRequired()
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet()));
    layout.addComponent(applyDefaultCb);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setMargin(new MarginInfo(true, false, false, false));
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    okBtn = new CubaButton(getMessage("actions.Ok"));
    okBtn.setIcon(WebComponentsHelper.getIcon("icons/ok.png"));
    okBtn.addStyleName(WebButton.ICON_STYLE);

    initButtonOkListener();
    buttonsLayout.addComponent(okBtn);

    cancelBtn = new CubaButton(getMessage("actions.Cancel"));
    cancelBtn.setIcon(WebComponentsHelper.getIcon("icons/cancel.png"));
    cancelBtn.addStyleName(WebButton.ICON_STYLE);
    cancelBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    buttonsLayout.addComponent(cancelBtn);

    if (AppUI.getCurrent().isTestMode()) {
        setCubaId("folderEditWindow");

        nameField.setCubaId("nameField");
        tabNameField.setCubaId("tabNameField");
        parentSelect.setCubaId("parentSelect");
        if (presentation != null) {
            presentation.setCubaId("presentationSelect");
        }
        sortOrderField.setCubaId("sortOrderField");
        if (selectedPresentationField != null) {
            selectedPresentationField.setCubaId("selectedPresentationField");
        }
        if (globalCb != null) {
            globalCb.setCubaId("globalCb");
        }
        applyDefaultCb.setCubaId("applyDefaultCb");
        okBtn.setCubaId("okBtn");
        cancelBtn.setCubaId("cancelBtn");
    }
}

From source file:com.hangum.tadpole.rdb.core.dialog.export.sqltoapplication.MakeResultToUpdateStatementDialog.java

@Override
protected void okPressed() {
    listWhereColumnName.clear();//w  w w.  j  a  v  a2s  .com

    strTableName = StringUtils.trimToEmpty(textTableName.getText());
    for (int i = 0; i < btnUpdate.length; i++) {
        Button button = btnUpdate[i];
        if (button.getSelection())
            listWhereColumnName.add(button.getText());
    }

    if (StringUtils.isEmpty(strTableName)) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().InputTableName);
        return;
    } else if (listWhereColumnName.isEmpty()) {
        MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().PleaseSelectWhereColumn);
        return;
    }

    super.okPressed();
}

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

/**
 * ping test/*from   ww w  .  j a v  a 2  s  .  c  o  m*/
 * 
 * @param host
 * @param port
 */
protected void pingTest(String host, String port) {
    host = StringUtils.trimToEmpty(host);
    port = StringUtils.trimToEmpty(port);

    if ("".equals(host) || "".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
        MessageDialog.openWarning(null, Messages.get().Warning,
                String.format(Messages.get().DBLoginDialog_11, Messages.get().Host, Messages.get().Port));
        return;
    }

    try {
        if (ValidChecker.isPing(host, port)) {
            MessageDialog.openInformation(null, Messages.get().Confirm, Messages.get().DBLoginDialog_13);
        } else {
            MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().DBLoginDialog_15);
        }
    } catch (NumberFormatException nfe) {
        MessageDialog.openWarning(null, Messages.get().Warning, Messages.get().MySQLLoginComposite_4);
    }
}

From source file:com.hangum.tadpole.engine.sql.util.SQLUtil.java

/**
 * sql     ./* w  ww  . j  a v a 2 s  .  c o m*/
 * 
 * @param userDB
 * @param exeSQL
 * @return
 */
public static String removeCommentAndOthers(UserDBDAO userDB, String exeSQL) {
    exeSQL = StringUtils.trimToEmpty(exeSQL);
    exeSQL = removeComment(exeSQL);
    exeSQL = StringUtils.trimToEmpty(exeSQL);
    exeSQL = StringUtils.removeEnd(exeSQL, "/");
    exeSQL = StringUtils.trimToEmpty(exeSQL);
    //TO DO ?? ? ?  (;)  .  ?  .
    exeSQL = StringUtils.removeEnd(exeSQL, PublicTadpoleDefine.SQL_DELIMITER);

    return exeSQL;
}

From source file:com.metasoft.claim.service.impl.claim.ClaimServiceImpl.java

@Override
public ClaimSearchResultVoPaging searchPaging(Date jobDateStart, Date jobDateEnd, StdInsurance partyInsurance,
        Date maturityDate, ClaimType claimType, String claimNumber, JobStatus jobStatus, int start, int length,
        SecUser user) {//from  w ww  .  j av a 2 s  .  c om

    ClaimPaging claimPaging = claimDao.searchPaging(jobDateStart, jobDateEnd, partyInsurance, maturityDate,
            claimType, claimNumber, jobStatus, start, length, user);

    ClaimSearchResultVoPaging voPaging = new ClaimSearchResultVoPaging();
    voPaging.setDraw(claimPaging.getDraw());
    voPaging.setRecordsFiltered(claimPaging.getRecordsFiltered());
    voPaging.setRecordsTotal(claimPaging.getRecordsTotal());
    voPaging.setData(new ArrayList<ClaimSearchResultVo>());
    if (claimPaging != null && claimPaging.getData() != null) {
        for (TblClaimRecovery claim : claimPaging.getData()) {
            ClaimSearchResultVo vo = new ClaimSearchResultVo();
            if (claim.getAgent() != null) {
                vo.setAgentName(StringUtils.trimToEmpty(claim.getAgent().getName()) + " "
                        + (StringUtils.trimToEmpty(claim.getAgent().getLastName())));
            }
            vo.setClaimId(claim.getId().intValue());
            vo.setClaimNumber(StringUtils.trimToEmpty(claim.getClaimNumber()));
            if (claim.getClaimType() != null) {
                vo.setClaimType(claim.getClaimType().getName());
            }
            if (claim.getPartyInsurance() != null) {
                vo.setInsuranceName(claim.getPartyInsurance().getName());
            }
            if (claim.getJobDate() != null) {
                vo.setJobDate(DateToolsUtil.convertToString(claim.getJobDate(), DateToolsUtil.LOCALE_TH));
            }
            vo.setJobNo(StringUtils.trimToEmpty(claim.getJobNo()));
            if (claim.getJobStatus() != null) {
                vo.setJobStatus(claim.getJobStatus().getName());
            }
            if (claim.getMaturityDate() != null) {
                vo.setMaturityDate(
                        DateToolsUtil.convertToString(claim.getMaturityDate(), DateToolsUtil.LOCALE_TH));
            }
            if (claim.getRequestAmount() != null) {
                vo.setRequestAmount(NumberToolsUtil.decimalFormat(claim.getRequestAmount()));
            }
            voPaging.getData().add(vo);
        }
    }

    return voPaging;
}

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

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

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

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from  w  w w.  j  a va2 s  . c  o  m
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    return result.toString();
}

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

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *//*  w w  w  . j a v 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(getComponent1()));
        if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) {
            result.append("/");
            result.append(StringUtils.trimToEmpty(getComponent3()));
        }
    }
    return result.toString();
}

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

/**
 * Serializes the fields' components into the single string value (SWIFT format)
 *///from  www  . j  a  v a2s.c  o m
@Override
public String getValue() {
    final StringBuilder result = new StringBuilder();
    result.append(StringUtils.trimToEmpty(getComponent1()));
    result.append("/");
    result.append(StringUtils.trimToEmpty(getComponent2()));
    if (org.apache.commons.lang.StringUtils.isNotEmpty(getComponent3())) {
        result.append("/");
        result.append(StringUtils.trimToEmpty(getComponent3()));
    }
    return result.toString();
}

From source file:com.zmanww.bukkit.SnowControl.Config.java

private List<Material> stringToMaterial(List<String> tempList) {
    List<Material> retVal = new ArrayList<Material>();
    if (tempList != null) {
        for (String str : tempList) {
            str = StringUtils.trimToEmpty(str);
            if (StringUtils.isNumeric(str)) {
                retVal.add(Material.getMaterial(Integer.parseInt(str)));
            } else if (!StringUtils.isBlank(str)) {
                retVal.add(Material.getMaterial(str));
            }//from  w  w w . ja  v  a2  s .  c  om
        }
    }
    return retVal;
}