diff src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java @ 497:aed7f32e029a onclient

Refactor LineType to be an enum Makes it easier to catch them all when changing things.
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Fri, 13 Aug 2021 10:26:56 +0200 (2021-08-13)
parents bf9f6b6ecf40
children 4cfe4991ee63
line wrap: on
line diff
--- a/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java
+++ b/src/main/java/org/monetdb/mcl/io/BufferedMCLReader.java
@@ -14,6 +14,8 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 
+import static org.monetdb.mcl.io.LineType.*;
+
 /**
  * Read text from a character-input stream, buffering characters so as
  * to provide a means for efficient reading of characters, arrays and
@@ -41,27 +43,9 @@ import java.io.UnsupportedEncodingExcept
  * @see org.monetdb.mcl.io.BufferedMCLWriter
  */
 public final class BufferedMCLReader extends BufferedReader {
-	/** "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 &amp; 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     = '#';
 
 	/** The type of the last line read */
-	private int lineType = UNKNOWN;
+	private LineType lineType = UNKNOWN;
 
 	/**
 	 * Create a buffering character-input stream that uses a
@@ -162,7 +146,7 @@ public final class BufferedMCLReader ext
 	 *         following constants: UNKNOWN, HEADER, ERROR, PROMPT, MORE,
 	 *         RESULT, SOHEADER, REDIRECT, INFO
 	 */
-	public int getLineType() {
+	public LineType getLineType() {
 		return lineType;
 	}