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:net.sf.authorship.util.AuthorUtil.java

public static final Author getAuthorFromAuthorJavadocAnnotation(String value) {
    value = StringUtils.trim(value);
    Author author = null;/*from ww w.j a  va2 s.  c  o m*/
    for (Production production : PRODUCTIONS) {
        author = production.produce(value);
        if (author != null) {
            break;
        }
    }
    return author;
}

From source file:gov.nih.nci.cabig.caaers.utils.XsltTransformerTest.java

public void testToText() throws Exception {
    String xml = new XsltTransformer().toText(xmlSearchResult(), "/xslt/c2a_generic_response.xslt");
    assertTrue(xml.endsWith("</stud:studies>"));

    String xml2 = new XsltTransformer().toText(xmlStudyDetailsResult(), "/xslt/c2a_generic_response.xslt");
    String s = StringUtils.trim(xml2);
    int i = NumberUtils.toInt(s, -99);
    assertEquals(1, i);/*from   w w  w  . ja v  a2 s .co  m*/

}

From source file:it.sample.parser.domain.TipologiaRapporto.java

/**
 * @param tipoRapporto/*from w w  w  .ja va2  s . com*/
 * @return
 */
public static TipologiaRapporto decode(String tipoRapporto) {
    return TipologiaRapporto.valueMap.get(StringUtils.trim(tipoRapporto));
}

From source file:com.smartitengineering.util.opensearch.impl.Utils.java

public static void checkMinLength(String name, int minLength, String testString, boolean trim) {
    final String finalTestString;
    if (trim) {/*from  w  w  w  . ja  va  2  s . com*/
        finalTestString = StringUtils.trim(testString);
    } else {
        finalTestString = testString;
    }
    if (StringUtils.length(finalTestString) < minLength) {
        throw new IllegalArgumentException(new StringBuilder(name).append(" must not be fewer than ")
                .append(minLength).append(" characters").toString());
    }
}

From source file:com.evolveum.midpoint.prism.polystring.PrismDefaultPolyStringNormalizer.java

@Override
public String normalize(String orig) {
    if (orig == null) {
        return null;
    }/* w w  w  . j a v  a2 s . co  m*/
    String s = StringUtils.trim(orig);
    s = Normalizer.normalize(s, Normalizer.Form.NFKD);
    s = s.replaceAll("[^\\w\\s\\d]", "");
    s = s.replaceAll("\\s+", " ");
    if (StringUtils.isBlank(s)) {
        s = "";
    }
    return StringUtils.lowerCase(s);
}

From source file:com.intuit.tank.harness.data.ResponseData.java

/**
 * @return the value
 */
public String getValue() {
    return StringUtils.trim(value);
}

From source file:eu.arthepsy.sonar.plugins.scapegoat.util.XmlUtils.java

public static String getNodeText(SMInputCursor cursor) throws XMLStreamException {
    return StringUtils.trim(cursor.collectDescendantText(false));
}

From source file:de.shadowhunt.sonar.plugins.ignorecode.model.AbstractPattern.java

static SortedSet<Integer> parseLineValues(final String lineValues) {
    final SortedSet<Integer> lines = new TreeSet<>();
    if ("*".equals(lineValues)) {
        return lines;
    }/* w  ww.j a  v  a  2 s  .co m*/

    final String s = StringUtils.substringBetween(StringUtils.trim(lineValues), "[", "]");
    final String[] parts = StringUtils.split(s, ',');
    for (final String part : parts) {
        if (StringUtils.contains(part, '-')) {
            final String[] range = StringUtils.split(part, '-');
            final int from = Integer.parseInt(range[0]);
            final int to = Integer.parseInt(range[1]);
            addLines(lines, from, to);
        } else {
            lines.add(Integer.parseInt(part));
        }
    }
    return lines;
}

From source file:com.hangum.tadpole.rdb.core.editors.main.SQLTextUtil.java

/**
 * ? //www.  j av a 2  s. co  m
 * 
 * 1. (Define.SQL_DILIMITER(;)) ? ??   ? ?  =>   ? .
 * 2.  ? ??  ? ?? ?. 
 *   
 * @param query
 * @param cursorPosition
 * @return
 */
public static String executeQuery(String query, int cursorPosition) {//throws Exception {
    if (query.split(Define.SQL_DILIMITER).length == 1 || query.indexOf(Define.SQL_DILIMITER) == -1) {
        return StringUtils.trimToEmpty(query);
    }

    String[] querys = StringUtils.split(query, Define.SQL_DILIMITER);
    //      if(logger.isDebugEnabled()) {
    //         logger.debug("=====[query]" + query + " =====[mouse point]" + cursorPoint);
    //      }

    int queryBeforeCount = 0;
    for (int i = 0; i < querys.length; i++) {
        // dilimiter ?  +1 .
        int firstSearch = querys[i].length() + 1;

        queryBeforeCount += firstSearch;
        if (cursorPosition <= queryBeforeCount) {
            if (logger.isDebugEnabled())
                logger.debug("[cursorPosition]" + cursorPosition + "[find postion]" + queryBeforeCount
                        + "[execute query]" + StringUtils.trim(querys[i]));
            return StringUtils.trim(querys[i]);
        }
    }

    if (logger.isDebugEnabled())
        logger.debug("[last find execute query]" + StringUtils.trim(querys[querys.length - 1]));
    return StringUtils.trim(querys[querys.length - 1]);
}

From source file:com.constellio.app.modules.es.connectors.http.fetcher.config.BasicUrlNormalizer.java

@Override
public String normalize(String url) throws MalformedURLException, URISyntaxException {
    String trimmedUrl = StringUtils.trim(url);
    String noFragmentUrl = StringUtils.substringBefore(trimmedUrl, "#");
    if (StringUtils.isEmpty(new URL(noFragmentUrl).getFile())) {
        noFragmentUrl = noFragmentUrl + "/";
    }/*  ww w  . j a va  2s . com*/
    URL normalizedUrl = new URL(noFragmentUrl);
    String lowerCaseHost = StringUtils.lowerCase(normalizedUrl.getHost());
    normalizedUrl = new URL(normalizedUrl.getProtocol(), lowerCaseHost, normalizedUrl.getPort(),
            normalizedUrl.getFile());
    return normalizedUrl.toURI().normalize().toString();
}