Example usage for java.io StreamTokenizer quoteChar

List of usage examples for java.io StreamTokenizer quoteChar

Introduction

In this page you can find the example usage for java.io StreamTokenizer quoteChar.

Prototype

public void quoteChar(int ch) 

Source Link

Document

Specifies that matching pairs of this character delimit string constants in this tokenizer.

Usage

From source file:org.yestech.jmlnitrate.transformation.inbound.BaseInboundTransformation.java

/**
 *  Parses a Parameter Request String and return a array of the tokens in the
 *  string. The default delimeters are ^ and ;
 *
 * @param  rawRequest the Parameter Request
 * @return  Array of the tokens/*from  w w w.j  av a  2  s.  c o  m*/
 * @throws  Exception if an error happens
 */
private Object[] parseParameterRequest(String rawRequest) throws Exception {
    StreamTokenizer tokenStream = new StreamTokenizer(
            new BufferedReader(new StringReader(rawRequest), BUFFER_SIZE));
    //reset the stream
    tokenStream.resetSyntax();
    //configure tokens
    tokenStream.lowerCaseMode(false);
    tokenStream.eolIsSignificant(false);

    //add word chars
    tokenStream.wordChars(32, 58);
    tokenStream.wordChars(60, 93);
    tokenStream.wordChars(95, 126);

    //add <CR>\r <LF>\n
    tokenStream.wordChars(10, 10);
    tokenStream.wordChars(13, 13);

    //set ^ AND ; as delimeters to string tokens
    tokenStream.quoteChar(94);

    //removed ;
    //tokenStream.quoteChar(59);

    //set up the temp arraylist
    ArrayList tokens = new ArrayList();

    int result = tokenStream.ttype;
    while (result != StreamTokenizer.TT_EOF) {
        result = tokenStream.nextToken();
        switch (result) {
        case StreamTokenizer.TT_EOF:
            break;
        default:
            tokens.add(tokenStream.sval);
            break;
        }
    }
    return tokens.toArray();
}