Example usage for org.apache.commons.lang.text StrTokenizer setIgnoreEmptyTokens

List of usage examples for org.apache.commons.lang.text StrTokenizer setIgnoreEmptyTokens

Introduction

In this page you can find the example usage for org.apache.commons.lang.text StrTokenizer setIgnoreEmptyTokens.

Prototype

public StrTokenizer setIgnoreEmptyTokens(boolean ignoreEmptyTokens) 

Source Link

Document

Sets whether the tokenizer should ignore and not return empty tokens.

Usage

From source file:org.intermine.api.query.LookupTokeniser.java

/**
 * Transform an input string into a list of identifiers.
 * @param input A comma, new line, or tab delimited set of identifiers,
 * with optional double quoting.//from w w w . j a  v a 2  s  .c  o m
 * @return A list of identifiers.
 */
public List<String> tokenise(String input) {
    List<String> ret = new LinkedList<String>();

    StrTokenizer tokeniser = new StrTokenizer(input, charSetMatcher);
    tokeniser.setQuoteChar('"');
    tokeniser.setIgnoreEmptyTokens(true);
    tokeniser.setTrimmerMatcher(StrMatcher.trimMatcher());
    while (tokeniser.hasNext()) {
        String token = tokeniser.nextToken().trim();
        ret.add(token);
    }
    return ret;
}

From source file:org.kuali.kfs.module.bc.document.web.struts.TempListLookupAction.java

/**
 * Parses the methodToCall parameter which contains the lock information in a known format. Populates a
 * BudgetConstructionLockSummary that represents the record to unlock.
 *
 * @param methodToCallString - request parameter containing lock information
 * @return lockSummary populated from request parameter
 *///w ww. j  a v  a  2 s. c  o m
protected BudgetConstructionLockSummary populateLockSummary(String methodToCallString) {
    BudgetConstructionLockSummary lockSummary = new BudgetConstructionLockSummary();

    // parse lock fields from methodToCall parameter
    String lockType = StringUtils.substringBetween(methodToCallString,
            KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
    String lockFieldsString = StringUtils.substringBetween(methodToCallString,
            KFSConstants.METHOD_TO_CALL_PARM9_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM9_RIGHT_DEL);
    String lockUser = StringUtils.substringBetween(methodToCallString,
            KFSConstants.METHOD_TO_CALL_PARM3_LEFT_DEL, KFSConstants.METHOD_TO_CALL_PARM3_RIGHT_DEL);

    // space was replaced by underscore for html
    lockSummary.setLockType(StringUtils.replace(lockType, "_", " "));
    lockSummary.setLockUserId(lockUser);

    // parse key fields
    StrTokenizer strTokenizer = new StrTokenizer(lockFieldsString, BCConstants.LOCK_STRING_DELIMITER);
    strTokenizer.setIgnoreEmptyTokens(false);
    String fiscalYear = strTokenizer.nextToken();
    if (fiscalYear != null) {
        lockSummary.setUniversityFiscalYear(Integer.parseInt(fiscalYear));
    }

    lockSummary.setChartOfAccountsCode(strTokenizer.nextToken());
    lockSummary.setAccountNumber(strTokenizer.nextToken());
    lockSummary.setSubAccountNumber(strTokenizer.nextToken());
    lockSummary.setPositionNumber(strTokenizer.nextToken());

    return lockSummary;
}