Example usage for org.apache.commons.lang3.text StrTokenizer setDelimiterMatcher

List of usage examples for org.apache.commons.lang3.text StrTokenizer setDelimiterMatcher

Introduction

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

Prototype

public StrTokenizer setDelimiterMatcher(final StrMatcher delim) 

Source Link

Document

Sets the field delimiter matcher.

Usage

From source file:org.kalypso.model.wspm.pdb.internal.gaf.GafReader.java

private GafLine parseLine(final String line) throws CoreException {
    final StrTokenizer tokenizer = new StrTokenizer(line);
    tokenizer.setDelimiterMatcher(StrMatcher.trimMatcher());
    tokenizer.setQuoteMatcher(StrMatcher.noneMatcher());
    tokenizer.setIgnoredMatcher(StrMatcher.noneMatcher());
    tokenizer.setTrimmerMatcher(StrMatcher.noneMatcher());
    tokenizer.setEmptyTokenAsNull(false);
    tokenizer.setIgnoreEmptyTokens(false);
    final String[] tokens = tokenizer.getTokenArray();

    if (tokens.length < 9)
        throw failLine(IStatus.INFO, Messages.getString("GafReader.5")); //$NON-NLS-1$

    final Object[] items = parseTokens(tokens);
    checkCommentLine(items);//from   w w w  .  j  ava  2s  .  c o m

    final BigDecimal station = asDecimal(items[0], Messages.getString("GafReader.6")); //$NON-NLS-1$
    final String pointId = asString(tokens[1]);
    final BigDecimal width = asDecimalOrNull(items[2], Messages.getString("GafReader.7")); //$NON-NLS-1$
    final BigDecimal height = asDecimal(items[3], Messages.getString("GafReader.8")); //$NON-NLS-1$
    final String code = asString(tokens[4]).toUpperCase();
    final String roughnessClass = asString(tokens[5]);
    final String vegetationClass = asString(tokens[6]);
    final BigDecimal hw = asDecimal(items[7], Messages.getString("GafReader.9")); //$NON-NLS-1$
    final BigDecimal rw = asDecimal(items[8], Messages.getString("GafReader.10")); //$NON-NLS-1$
    final String hyk = tokens.length < 10 ? StringUtils.EMPTY : asString(tokens[9]).toUpperCase();

    return new GafLine(station, pointId, width, height, code, roughnessClass, vegetationClass, rw, hw, hyk,
            Status.OK_STATUS);
}