view src/main/java/nl/cwi/monetdb/mcl/io/EmbeddedMCLReader.java @ 62:b66003555560 embedded

Split parsers and cleaned the MCL layer.
author Pedro Ferreira <pedro.ferreira@monetdbsolutions.com>
date Fri, 25 Nov 2016 12:05:10 +0100 (2016-11-25)
parents src/main/java/nl/cwi/monetdb/mcl/embedded/EmbeddedReader.java@f1de7262d8d9
children 6325594f01af
line wrap: on
line source
package nl.cwi.monetdb.mcl.io;

import java.io.*;

/**
 * Created by ferreira on 11/24/16.
 */
public class EmbeddedMCLReader extends AbstractMCLReader {

    public EmbeddedMCLReader() {
        super(null);
    }

    @Override
    public String readLine() throws IOException {
        String res = this.readLineInternal(); //this readline will never wait!!
        setLineType(res);
        if (lineType == ERROR && !res.matches("^![0-9A-Z]{5}!.+"))
            res = "!22000!" + res.substring(1);
        return res;
    }

    @Override
    public synchronized String waitForPrompt() throws IOException {
        try {
            this.wait(); //must mimic the socket readline with the wait/notify methods
        } catch (InterruptedException e) {
            throw new IOException(e);
        }
        return null;
    }

    private native String readLineInternal();
}