Mercurial > hg > monetdb-java
view src/main/java/nl/cwi/monetdb/mcl/io/AbstractMCLReader.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/connection/AbstractBufferedReader.java@f1de7262d8d9 |
children | 6325594f01af |
line wrap: on
line source
package nl.cwi.monetdb.mcl.io; import java.io.BufferedReader; import java.io.IOException; import java.io.Reader; /** * Created by ferreira on 11/24/16. */ public abstract class AbstractMCLReader extends BufferedReader { /** The type of the last line read */ protected int lineType; /** "there is currently no line", or the the type is unknown is represented by UNKNOWN */ public final static int UNKNOWN = 0; /** a line starting with ! indicates ERROR */ public final static int ERROR = '!'; /** a line starting with % indicates HEADER */ public final static int HEADER = '%'; /** a line starting with [ indicates RESULT */ public final static int RESULT = '['; /** a line which matches the pattern of prompt1 is a PROMPT */ public final static int PROMPT = '.'; /** a line which matches the pattern of prompt2 is a MORE */ public final static int MORE = ','; /** a line starting with & indicates the start of a header block */ public final static int SOHEADER = '&'; /** a line starting with ^ indicates REDIRECT */ public final static int REDIRECT = '^'; /** a line starting with # indicates INFO */ public final static int INFO = '#'; public AbstractMCLReader(Reader in) { super(in); } /** * getLineType returns the type of the last line read. * * @return an integer representing the kind of line this is, one of the * following constants: UNKNOWN, HEADER, ERROR, PROMPT, * RESULT, REDIRECT, INFO */ public int getLineType() { return lineType; } /** * Sets the linetype to the type of the string given. If the string * is null, lineType is set to UNKNOWN. * * @param line the string to examine */ public void setLineType(String line) { lineType = UNKNOWN; if (line == null || line.length() == 0) return; switch (line.charAt(0)) { case '!': lineType = ERROR; break; case '&': lineType = SOHEADER; break; case '%': lineType = HEADER; break; case '[': lineType = RESULT; break; case '=': lineType = RESULT; break; case '^': lineType = REDIRECT; break; case '#': lineType = INFO; break; case '.': lineType = PROMPT; break; case ',': lineType = MORE; break; } } public abstract String waitForPrompt() throws IOException; }