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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:edu.ku.brc.specify.toycode.mexconabio.MexConvToSQL.java

/**
 * @param str//from w ww  .  ja  v a 2  s.  c  o m
 * @param usePeriods
 * @return
 */
private String clean(final String str, final boolean usePeriods) {
    String s = StringUtils.remove(str, ':');

    if (!usePeriods)
        s = StringUtils.remove(s, '.');

    s = StringUtils.remove(s, '-');
    s = StringUtils.remove(s, ',');
    return s;
}

From source file:edu.ku.brc.specify.toycode.mexconabio.AnalysisBase.java

/**
 * @param str//from w w w. j  a  v a2 s  .c o m
 * @param usePeriods
 * @return
 */
protected String cleanString(final String str, final boolean usePeriods, final boolean replaceWithSpaces) {
    String s = StringUtils.remove(str, ':');

    if (!usePeriods) {
        if (replaceWithSpaces) {
            s = StringUtils.replaceChars(s, '.', ' ');
        } else {
            s = StringUtils.remove(s, '.');
        }
    }

    s = StringUtils.remove(s, '-');
    s = StringUtils.remove(s, ',');
    return s;
}

From source file:com.migratebird.integrationtest.MigrateBirdIntegrationTest.java

private String getTableNameForScript(TestScript scriptName) {
    String shortFileName = getShortFileName(scriptName);
    if (isIndexedFileName(shortFileName))
        shortFileName = substringAfter(shortFileName, "_");
    shortFileName = StringUtils.remove(shortFileName, "#");
    return shortFileName;
}

From source file:ips1ap101.lib.base.util.StrUtils.java

public static String removeWords(String string, String remove, char affixType) {
    if (remove != null) {
        String separatorChars = ", ";
        String[] tokens = StringUtils.split(remove, separatorChars);
        for (String token : tokens) {
            remove = StrUtils.getWordyString(token);
            if (affixType == 'p') {
                string = StringUtils.removeStart(string, remove + " ");
            } else if (affixType == 's') {
                string = StringUtils.removeEnd(string, " " + remove);
            } else {
                string = StringUtils.remove(string, " " + remove + " ");
            }//  w w  w . j  a  v  a 2s.  c om
        }
    }
    return string;
}

From source file:com.google.gdt.eclipse.designer.core.model.widgets.RootLayoutPanelTest.java

private void anchor_assertEditor(String... lines) {
    try {//from  w w  w .j a v  a  2 s . c o  m
        m_assertEditor_expectedSourceProcessor = new Function<String, String>() {
            public String apply(String source) {
                String strToRemove = "\t\t\t\n";
                return StringUtils.remove(source, strToRemove);
            }
        };
        assertEditor(lines);
    } finally {
        m_assertEditor_expectedSourceProcessor = null;
    }
}

From source file:com.cws.esolutions.core.processors.impl.ServiceManagementProcessorImpl.java

/**
 * @see com.cws.esolutions.core.processors.interfaces.IServiceManagementProcessor#getServiceData(com.cws.esolutions.core.processors.dto.ServiceManagementRequest)
 *///from   www. j a v a 2 s. co  m
public ServiceManagementResponse getServiceData(final ServiceManagementRequest request)
        throws ServiceManagementException {
    final String methodName = IServiceManagementProcessor.CNAME
            + "#getServiceData(final ServiceManagementRequest request) throws ServiceManagementException";

    if (DEBUG) {
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("ServiceManagementRequest: {}", request);
    }

    ServiceManagementResponse response = new ServiceManagementResponse();

    final Service service = request.getService();
    final UserAccount userAccount = request.getUserAccount();
    final RequestHostInfo reqInfo = request.getRequestInfo();

    if (DEBUG) {
        DEBUGGER.debug("Service: {}", service);
        DEBUGGER.debug("UserAccount: {}", userAccount);
        DEBUGGER.debug("RequestHostInfo: {}", reqInfo);
    }

    try {
        // this will require admin and service authorization
        AccessControlServiceRequest accessRequest = new AccessControlServiceRequest();
        accessRequest.setUserAccount(userAccount);
        accessRequest.setServiceGuid(request.getServiceId());

        if (DEBUG) {
            DEBUGGER.debug("AccessControlServiceRequest: {}", accessRequest);
        }

        AccessControlServiceResponse accessResponse = accessControl.isUserAuthorized(accessRequest);

        if (DEBUG) {
            DEBUGGER.debug("AccessControlServiceResponse accessResponse: {}", accessResponse);
        }

        if (!(accessResponse.getIsUserAuthorized())) {
            // unauthorized
            response.setRequestStatus(CoreServicesStatus.UNAUTHORIZED);

            // audit
            try {
                AuditEntry auditEntry = new AuditEntry();
                auditEntry.setHostInfo(reqInfo);
                auditEntry.setAuditType(AuditType.LOADPLATFORM);
                auditEntry.setUserAccount(userAccount);
                auditEntry.setAuthorized(Boolean.FALSE);
                auditEntry.setApplicationId(request.getApplicationId());
                auditEntry.setApplicationName(request.getApplicationName());

                if (DEBUG) {
                    DEBUGGER.debug("AuditEntry: {}", auditEntry);
                }

                AuditRequest auditRequest = new AuditRequest();
                auditRequest.setAuditEntry(auditEntry);

                if (DEBUG) {
                    DEBUGGER.debug("AuditRequest: {}", auditRequest);
                }

                auditor.auditRequest(auditRequest);
            } catch (AuditServiceException asx) {
                ERROR_RECORDER.error(asx.getMessage(), asx);
            }

            return response;
        }

        List<Server> serverList = null;
        List<String> serviceData = serviceDao.getService(service.getGuid());

        if (DEBUG) {
            DEBUGGER.debug("serviceData: {}", serviceData);
        }

        if ((serviceData != null) && (serviceData.size() != 0)) {
            if (ServiceType.valueOf(serviceData.get(0)) == ServiceType.PLATFORM) {
                String appTmp = StringUtils.remove(serviceData.get(5), "["); // PLATFORM_SERVERS
                String platformServers = StringUtils.remove(appTmp, "]");

                if (DEBUG) {
                    DEBUGGER.debug("String: {}", platformServers);
                }

                if (platformServers.split(",").length >= 1) {
                    serverList = new ArrayList<Server>();

                    for (String serverGuid : platformServers.split(",")) {
                        List<Object> serverData = serverDao.getServer(StringUtils.trim(serverGuid));

                        if (DEBUG) {
                            DEBUGGER.debug("serverData: {}", serverData);
                        }

                        if ((serverData != null) && (serverData.size() != 0)) {
                            Server server = new Server();
                            server.setServerGuid((String) serverData.get(0)); // SYSTEM_GUID
                            server.setServerRegion(ServiceRegion.valueOf((String) serverData.get(3))); // SYSTEM_REGION
                            server.setOperHostName((String) serverData.get(16)); // OPER_HOSTNAME

                            if (DEBUG) {
                                DEBUGGER.debug("Server: {}", server);
                            }

                            serverList.add(server);
                        }
                    }

                    if (DEBUG) {
                        DEBUGGER.debug("serverList: {}", serverList);
                    }
                }
            }

            Service resService = new Service();
            resService.setGuid(service.getGuid());
            resService.setType(ServiceType.valueOf(serviceData.get(0)));
            resService.setName(serviceData.get(1));
            resService.setRegion(ServiceRegion.valueOf(serviceData.get(2)));
            resService.setPartition(NetworkPartition.valueOf(serviceData.get(3)));
            resService.setServers(serverList);
            resService.setStatus(ServiceStatus.valueOf(serviceData.get(4)));
            resService.setDescription(serviceData.get(6));

            if (DEBUG) {
                DEBUGGER.debug("Service: {}", resService);
            }

            response.setRequestStatus(CoreServicesStatus.SUCCESS);
            response.setService(resService);
        } else {
            response.setRequestStatus(CoreServicesStatus.FAILURE);
        }
    } catch (SQLException sqx) {
        ERROR_RECORDER.error(sqx.getMessage(), sqx);

        throw new ServiceManagementException(sqx.getMessage(), sqx);
    } catch (AccessControlServiceException acsx) {
        ERROR_RECORDER.error(acsx.getMessage(), acsx);

        throw new ServiceManagementException(acsx.getMessage(), acsx);
    } finally {
        // audit
        try {
            AuditEntry auditEntry = new AuditEntry();
            auditEntry.setHostInfo(reqInfo);
            auditEntry.setAuditType(AuditType.LOADPLATFORM);
            auditEntry.setUserAccount(userAccount);
            auditEntry.setAuthorized(Boolean.TRUE);
            auditEntry.setApplicationId(request.getApplicationId());
            auditEntry.setApplicationName(request.getApplicationName());

            if (DEBUG) {
                DEBUGGER.debug("AuditEntry: {}", auditEntry);
            }

            AuditRequest auditRequest = new AuditRequest();
            auditRequest.setAuditEntry(auditEntry);

            if (DEBUG) {
                DEBUGGER.debug("AuditRequest: {}", auditRequest);
            }

            auditor.auditRequest(auditRequest);
        } catch (AuditServiceException asx) {
            ERROR_RECORDER.error(asx.getMessage(), asx);
        }
    }

    return response;
}

From source file:edu.ku.brc.specify.utilapps.RegisterApp.java

/**
 * /*w  w w . j a  v a  2  s  .  co  m*/
 */
@SuppressWarnings("unchecked")
protected void doSetVersion() {
    CellConstraints cc = new CellConstraints();

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g"));

    Vector<String> versionsList = new Vector<String>();
    Hashtable<String, String> verToDateHash = new Hashtable<String, String>();
    try {
        SimpleDateFormat mmddyyyy = new SimpleDateFormat("MM/dd/yyyy");
        SimpleDateFormat yyyymmdd = new SimpleDateFormat("yyyy/MM/dd");
        List<String> lines = FileUtils.readLines(rp.getDataFromWeb(
                UIRegistry.getResourceString("CGI_BASE_URL") + "/specifydownloads/specify6/alpha/versions.txt",
                false));
        for (String line : lines) {
            String[] toks = line.split(",");
            if (toks.length > 2) {
                String ver = StringUtils.remove(toks[1].trim(), "Alpha ");

                versionsList.insertElementAt(ver, 0);

                String dateStr = toks[2].trim();
                dateStr = StringUtils.replace(dateStr, ".", "/");
                try {
                    Date date = mmddyyyy.parse(dateStr);
                    verToDateHash.put(ver, yyyymmdd.format(date));

                } catch (Exception ex) {
                }
            }
        }
        versionsList.insertElementAt("Clear", 0);

    } catch (IOException ex) {
        ex.printStackTrace();
    }

    final JList list = new JList(versionsList);
    final CustomDialog dlg = new CustomDialog(null, "Set Version", true, pb.getPanel());

    pb.add(UIHelper.createLabel("Versions", SwingConstants.CENTER), cc.xy(1, 1));
    pb.add(UIHelper.createScrollPane(list), cc.xy(1, 3));

    list.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1);
            }
        }
    });
    list.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            if (e.getClickCount() == 2) {
                dlg.getOkBtn().doClick();
            }
        }

    });

    pb.setDefaultDialogBorder();

    dlg.createUI();
    dlg.getOkBtn().setEnabled(false);

    dlg.setVisible(true);
    if (!dlg.isCancelled()) {
        int inx = list.getSelectedIndex();
        String version = (String) list.getSelectedValue();

        if (version.equals("Clear")) {
            rp.setVersionDates(null, null, null);
            frame.setTitle(title);
        } else {
            String prevVersion = inx == list.getModel().getSize() - 1 ? null
                    : (String) list.getModel().getElementAt(inx + 1);
            rp.setVersionDates(version, prevVersion, verToDateHash);
            frame.setTitle(title + " for " + version);
        }

        /*try
        {
        rp.process(doLocal ? new File("reg.dat") : rp.getDataFromWeb("SpReg.REGISTER_URL", true));
        rp.processTracks(doLocal ? new File("track.dat") : rp.getDataFromWeb("StatsTrackerTask.URL", true));
        rp.mergeStats();
                
        } catch (IOException ex)
        {
        ex.printStackTrace();
        }*/

    }
}

From source file:hydrograph.ui.propertywindow.widgets.dialogs.join.JoinMapDialog.java

private void populateJoinMapDialog() {

    if (joinMappingGrid.getLookupMapProperties() != null
            && !joinMappingGrid.getLookupMapProperties().isEmpty()) {
        mappingTableItemList = joinMappingGrid.getLookupMapProperties();
    } else {/*w  ww  . j  av a2s.  co  m*/
        mappingTableItemList = new LinkedList<>();
    }

    if (joinMappingGrid.getButtonText() != null
            && !StringUtils.equals(joinMappingGrid.getButtonText(), NO_COPY)) {
        radioButtonMap.get(joinMappingGrid.getButtonText()).setSelection(true);
        mappingTableViewer.getTable().setEnabled(false);
        enableMappingTableButtonPanel(false);
        String inputPortID = StringUtils.remove(joinMappingGrid.getButtonText(),
                Constants.COPY_FROM_INPUT_PORT_PROPERTY);
        copyFieldsWhenCopyOfIsSelected(
                inputPorts.get(Integer.parseInt(StringUtils.remove(inputPortID, Constants.INPUT_SOCKET_TYPE))),
                inputPortID);

    } else {
        radioButtonMap.get(NO_COPY).setSelection(true);
    }

    mappingTableViewer.setInput(mappingTableItemList);

    mappingTableViewer.refresh();

    populatePreviousItemsOfTable();

    mouseDoubleClick();
}

From source file:com.prowidesoftware.swift.model.SwiftTagListBlock.java

private String escapeJson(final String value) {
    String tmp = StringUtils.replace(value, "\n", "\\n");
    tmp = StringUtils.replace(tmp, "\"", "\\\"");
    tmp = StringUtils.remove(tmp, "\r");
    return tmp;/* ww w  . j a  va2 s.  c o m*/
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * @param pb/*from   ww w. ja v a  2  s . co m*/
 * @param label
 * @param cc
 * @param items
 */
private void addLabel(final ArrayList<String> items, final PanelBuilder pb, final JLabel label,
        final CellConstraints cc) {
    if (label != null && items != null && pb != null && cc != null) {
        pb.add(label, cc);
        String text = label.getText();
        items.add(StringUtils.remove(text != null ? text.trim() : "", ":"));
    } else {
        log.error("Error adding label.");
    }
}