diff src/main/java/org/monetdb/mcl/net/MapiSocket.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 788984342ae3
children 4cfe4991ee63
line wrap: on
line diff
--- a/src/main/java/org/monetdb/mcl/net/MapiSocket.java
+++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java
@@ -31,6 +31,7 @@ import java.util.List;
 import org.monetdb.mcl.MCLException;
 import org.monetdb.mcl.io.BufferedMCLReader;
 import org.monetdb.mcl.io.BufferedMCLWriter;
+import org.monetdb.mcl.io.LineType;
 import org.monetdb.mcl.parser.MCLParseException;
 
 /**
@@ -293,7 +294,7 @@ public class MapiSocket {	/* cannot (yet
 		final ArrayList<String> redirects = new ArrayList<String>();
 		final List<String> warns = new ArrayList<String>();
 		String err = "", tmp;
-		int lineType;
+		LineType lineType;
 		do {
 			tmp = reader.readLine();
 			if (tmp == null)
@@ -301,14 +302,14 @@ public class MapiSocket {	/* cannot (yet
 						con.getInetAddress().getHostName() + ":" +
 						con.getPort() + ": End of stream reached");
 			lineType = reader.getLineType();
-			if (lineType == BufferedMCLReader.ERROR) {
+			if (lineType == LineType.ERROR) {
 				err += "\n" + tmp.substring(7);
-			} else if (lineType == BufferedMCLReader.INFO) {
+			} else if (lineType == LineType.INFO) {
 				warns.add(tmp.substring(1));
-			} else if (lineType == BufferedMCLReader.REDIRECT) {
+			} else if (lineType == LineType.REDIRECT) {
 				redirects.add(tmp.substring(1));
 			}
-		} while (lineType != BufferedMCLReader.PROMPT);
+		} while (lineType != LineType.PROMPT);
 
 		if (err.length() > 0) {
 			close();
@@ -984,7 +985,7 @@ public class MapiSocket {	/* cannot (yet
 					block[blockLen++] = '\n';
 				}
 				// insert 'fake' flush
-				block[blockLen++] = BufferedMCLReader.PROMPT;
+				block[blockLen++] = LineType.PROMPT.chr();
 				block[blockLen++] = '\n';
 				if (debug)
 					log("RD ", "inserting prompt", true);