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

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

Introduction

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

Prototype

public static String trim(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

Usage

From source file:info.magnolia.rendering.template.configured.ConfiguredInheritance.java

@Override
public Boolean isInheritsComponents() {
    return isEnabled() != null && isEnabled()
            && (StringUtils.equalsIgnoreCase(StringUtils.trim(components), COMPONENTS_ALL)
                    || StringUtils.equalsIgnoreCase(StringUtils.trim(components), COMPONENTS_FILTERED));
}

From source file:gov.nih.nci.caintegrator.external.caarray.GenericMultiSamplePerFileParser.java

/**
 * @param dataMap the data mapping//from w w w .ja  va  2s  .  c o m
 * @throws DataRetrievalException read data exception
 */
public void loadMultiDataPoint(Map<String, Map<String, float[]>> dataMap) throws DataRetrievalException {
    String[] fields;
    try {
        while ((fields = Cai2Util.readDataLine(dataFileReader)) != null) {
            String probeName = fields[0];
            for (String sampleName : sampleToIndexMap.keySet()) {
                String valueField = StringUtils.trim(fields[sampleToIndexMap.get(sampleName)]);
                if (NumberUtils.isNumber(valueField)) {
                    setMultiPointReporterMap(dataMap, sampleName, probeName, NumberUtils.toFloat(valueField));
                }
            }
        }
    } catch (IOException e) {
        throw new DataRetrievalException("Couldn't read supplemental file.", e);
    }
}

From source file:hudson.plugins.copyartifact.CopyArtifactPermissionProperty.java

/**
 * Constructor//from www .ja  v a2s . c  o m
 * 
 * @param projectNames comma-separated project names that can copy artifacts of this project.
 */
@DataBoundConstructor
public CopyArtifactPermissionProperty(String projectNames) {
    List<String> rawProjectNameList = Arrays
            .asList((projectNames != null) ? StringUtils.split(projectNames, ',') : new String[0]);
    projectNameList = new ArrayList<String>(rawProjectNameList.size());
    for (String rawProjectName : rawProjectNameList) {
        if (StringUtils.isBlank(rawProjectName)) {
            continue;
        }
        projectNameList.add(StringUtils.trim(rawProjectName));
    }
}

From source file:com.microsoft.alm.plugin.idea.git.ui.branch.CreateBranchForm.java

public String getBranchName() {
    return StringUtils.trim(nameTextField.getText());
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.elasticExcel.excelimport.AbstractDataImporter.java

protected String getNormalizedReleaseName(Cell cell) {
    String nameString = ExcelUtils.getStringCellValue(cell);
    String[] nameParts = nameString.split("#");
    if (nameParts.length == 1) {
        return StringUtils.trim(nameParts[0]);
    } else if (nameParts.length == 2) {
        if ("".equals(StringUtils.trim(nameParts[1]))) {
            return StringUtils.trim(nameParts[0]);
        } else {// ww w  .ja v a 2s . com
            return StringUtils.trim(nameParts[0]) + " # " + StringUtils.trim(nameParts[1]);
        }
    } else {
        logError("Cell {0}: Invalid name \"{1}\"", ExcelUtils.getFullCellName(cell), nameString);
        return "";
    }
}

From source file:gov.va.med.pharmacy.peps.presentation.common.displaytag.CsvView.java

/**
 * Escaping for csv format.// w w w .  j a v  a2  s .  c  om
 * <ul>
 * <li>Quotes inside quoted strings are escaped with a /</li>
 * <li>Fields containings newlines or , are surrounded by "</li>
 * </ul>
 * Note this is the standard CVS format and it's not handled well by excel.
 * @param value the value 
 * @return The appropriate escape value
 * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
 */
protected String escapeColumnValue(Object value) {
    String stringValue = StringUtils.trim(value.toString());
    String cleanStringValue = "";

    //        String cleanStringValue = stringValue.replaceAll("\\<.*?>", "");

    try {
        cleanStringValue = extractText(stringValue);
    } catch (IOException e) {
        LOG.debug(e.getMessage());
    }

    if (!StringUtils.containsNone(cleanStringValue, new char[] { '\n', ',' })) {
        return "\"" + //$NON-NLS-1$
                StringUtils.replace(cleanStringValue, "\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    return cleanStringValue;
}

From source file:com.lingxiang2014.template.directive.BaseDirective.java

protected List<Order> getOrders(Map<String, TemplateModel> params, String... ignoreProperties)
        throws TemplateModelException {
    String orderBy = StringUtils
            .trim(FreemarkerUtils.getParameter(ORDER_BY_PARAMETER_NAME, String.class, params));
    List<Order> orders = new ArrayList<Order>();
    if (StringUtils.isNotEmpty(orderBy)) {
        String[] orderByItems = orderBy.split(ORDER_BY_ITEM_SEPARATOR);
        for (String orderByItem : orderByItems) {
            if (StringUtils.isNotEmpty(orderByItem)) {
                String property = null;
                Direction direction = null;
                String[] orderBys = orderByItem.split(ORDER_BY_FIELD_SEPARATOR);
                if (orderBys.length == 1) {
                    property = orderBys[0];
                } else if (orderBys.length >= 2) {
                    property = orderBys[0];
                    try {
                        direction = Direction.valueOf(orderBys[1]);
                    } catch (IllegalArgumentException e) {
                        continue;
                    }/*from w w  w. ja  v a  2s .  c  om*/
                } else {
                    continue;
                }
                if (!ArrayUtils.contains(ignoreProperties, property)) {
                    orders.add(new Order(property, direction));
                }
            }
        }
    }
    return orders;
}

From source file:com.github.woonsanko.katharsis.examples.hippo.katharsis.resource.repository.TaskRepository.java

@Override
public Iterable<TaskResource> findAll(RequestParams requestParams) {
    List<TaskResource> taskResList = new LinkedList<>();

    try {//from w w  w .  j  av  a  2  s .com
        final HstRequestContext requestContext = RequestContextProvider.get();
        final HippoBean scope = requestContext.getSiteContentBaseBean();
        final HstQuery hstQuery = requestContext.getQueryManager().createQuery(scope, TaskDocument.class, true);

        String queryTerm = null;

        if (requestParams.getFilters() != null) {
            queryTerm = StringUtils.trim(requestParams.getFilters().get("q").asText());
        }

        if (StringUtils.isNotEmpty(queryTerm)) {
            final Filter filter = hstQuery.createFilter();
            filter.addContains(".", queryTerm);
            hstQuery.setFilter(filter);
        }

        hstQuery.setOffset(getPaginationOffset(requestParams, 0));
        hstQuery.setLimit(this.getPaginationLimit(requestParams, 200));

        final HstQueryResult result = hstQuery.execute();

        TaskDocument taskDoc;
        TaskResource taskRes;

        for (HippoBeanIterator it = result.getHippoBeans(); it.hasNext();) {
            taskDoc = (TaskDocument) it.nextHippoBean();
            taskRes = new TaskResource().represent(taskDoc);
            taskResList.add(taskRes);
        }
    } catch (Exception e) {
        log.error("Failed to query tasks.", e);
    }

    return taskResList;
}

From source file:de.tsystems.mms.apm.performancesignature.ui.PerfSigTestActionTest.java

@LocalData
@Test// w w w . ja  v a  2 s. c o m
public void testTestReportPageDetail() throws Exception {
    Project proj = (Project) j.jenkins.getItem(TEST_PROJECT_WITH_HISTORY);
    assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

    Run<?, ?> build = proj.getBuildByNumber(11157);
    assertNotNull("We should have a build with number 11157", build);
    JenkinsRule.WebClient wc = j.createWebClient();
    HtmlPage testReport = wc.getPage(build,
            "testReport/com.dynatrace.easytravel.util/ZipUtilsTest/testZipSrcDirExclude/");

    j.assertXPath(testReport, "//*[@id=\"main-panel\"]/table/tbody/tr/td/div/table/tbody/tr[1]/td[2]");
    j.assertXPathValue(testReport,
            "//*[@id=\"main-panel\"]/table/tbody/tr/td/div/table/tbody/tr[1]/td[2]/text()", "0.22");
    j.assertXPath(testReport, "//*[@id=\"main-panel\"]/table/tbody/tr/td/div/p/text()[2]");
    assertEquals(StringUtils.trim(((DomText) testReport
            .getByXPath("//*[@id=\"main-panel\"]/table/tbody/tr/td/div/p/text()[2]").get(0)).getWholeText()),
            "Status: Failed\n" + "        ");
}

From source file:mitm.application.djigzo.james.matchers.GlobalVerifyHMACHeader.java

@Override
public void init() throws MessagingException {
    super.init();

    String[] parameters = getParameters();

    if (parameters.length > 3) {
        decrypt = Boolean.parseBoolean(StringUtils.trim(parameters[3]));
    }/*from   w w w. j  a v a  2  s  .  co  m*/

    sessionManager = SystemServices.getSessionManager();

    globalPreferencesManager = SystemServices.getGlobalPreferencesManager();

    actionExecutor = DatabaseActionExecutorBuilder.createDatabaseActionExecutor(sessionManager);
}