Changeset: c9db0fdbfc53 for monetdb-java
URL: http://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=c9db0fdbfc53
Modified Files:
src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/IIncompleteResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/IResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/ResultSetResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/SchemaResponse.java
src/main/java/nl/cwi/monetdb/mcl/responses/UpdateResponse.java
Branch: embedded
Log Message:
Some documentation done, plus removed unnecessary instance variables.
diffs (truncated from 714 to 300 lines):
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/AbstractProtocol.java
@@ -22,7 +22,7 @@ public abstract class AbstractProtocol {
public abstract void waitUntilPrompt() throws IOException;
- public abstract void fetchNextResponseData() throws IOException; //UPDATE
currentData!!!
+ public abstract void fetchNextResponseData() throws IOException;
public abstract ServerResponses getCurrentServerResponseHeader();
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/ProtocolException.java
@@ -11,13 +11,10 @@ package nl.cwi.monetdb.mcl.protocol;
import java.text.ParseException;
/**
- * When an ProtocolException is thrown, the MCL protocol is violated by
- * the sender. In general a stream reader throws an
- * ProtocolException as soon as something that is read cannot be
- * understood or does not conform to the specifications (e.g. a
- * missing field). The instance that throws the exception will try to
- * give an error offset whenever possible. Alternatively it makes sure
- * that the error message includes the offending data read.
+ * When an ProtocolException is thrown, the underlying protocol is violated by
the sender. In general a stream reader
+ * throws an ProtocolException as soon as something that is read cannot be
understood or does not conform to the
+ * specifications (e.g. a missing field). The instance that throws the
exception will try to give an error offset
+ * whenever possible. Alternatively it makes sure that the error message
includes the offending data read.
*/
public class ProtocolException extends ParseException {
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/ServerResponses.java
@@ -8,6 +8,9 @@
package nl.cwi.monetdb.mcl.protocol;
+/**
+ * This enum represents the possible stages of a query response by the server.
+ */
public enum ServerResponses {
/* Please don't change the order */
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/StarterHeaders.java
@@ -8,6 +8,10 @@
package nl.cwi.monetdb.mcl.protocol;
+/**
+ * This enum lists the possible responses of a query by the server. Notice
that Q_PARSE is not used by neither a MAPI or
+ * embedded connection, so it's here for completeness.
+ */
public enum StarterHeaders {
/* Please don't change the order */
diff --git a/src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/TableResultHeaders.java
@@ -8,22 +8,38 @@
package nl.cwi.monetdb.mcl.protocol;
+/**
+ * This enum lists the result table headers returned by the server.
+ */
public enum TableResultHeaders {
/* Please don't change the order */
+
+ /** The column names */
NAME(1),
+ /** The column lengths */
LENGTH(2),
+ /** The column table and schemas names in format of schema.table */
TABLE(4),
+ /** The SQL name of the MonetDB data type of the column */
TYPE(8),
+ /** This header is returned by the JDBC embedded telling that it fetches
all the previous headers at once */
ALL(15),
+ /** When an unknown table header is returned on a MAPI connection */
UNKNOWN(0);
+ /** An integer value for the bitmap on the ResultSetResponse Class */
private final int valueForBitMap;
TableResultHeaders(int valueForBitMap) {
this.valueForBitMap = valueForBitMap;
}
+ /**
+ * Returns the integer value for the bitmap.
+ *
+ * @return The integer value for the bitmap.
+ */
public int getValueForBitMap() {
return valueForBitMap;
}
diff --git
a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
--- a/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/protocol/oldmapi/OldMapiProtocol.java
@@ -113,7 +113,7 @@ public class OldMapiProtocol extends Abs
public DataBlockResponse getNextDatablockResponse(Map<Integer,
ResultSetResponse> rsresponses)
throws ProtocolException {
int id = OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
//The order cannot be switched!!
- int columncount =
OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
+ OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this); //column
count
int rowcount =
OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
int offset = OldMapiStartOfHeaderParser.GetNextResponseDataAsInt(this);
@@ -121,7 +121,7 @@ public class OldMapiProtocol extends Abs
if (rs == null) {
return null;
}
- return rs.addDataBlockResponse(offset, rowcount, columncount, this);
+ return rs.addDataBlockResponse(offset, rowcount, this);
}
@Override
diff --git a/src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
b/src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
--- a/src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/responses/AutoCommitResponse.java
@@ -9,12 +9,15 @@
package nl.cwi.monetdb.mcl.responses;
/**
- * The AutoCommitResponse represents a transaction message. It
- * stores (a change in) the server side auto commit mode.<br />
+ * The AutoCommitResponse represents a transaction message. It stores (a
change in) the server side auto commit mode.
+ * <br />
* <tt>&4 (t|f)</tt>
*/
public class AutoCommitResponse extends SchemaResponse {
+ /**
+ * If the auto commit mode is set.
+ */
private final boolean autocommit;
public AutoCommitResponse(boolean ac) {
@@ -22,6 +25,11 @@ public class AutoCommitResponse extends
this.autocommit = ac;
}
+ /**
+ * The auto commit value
+ *
+ * @return The auto commit value
+ */
public boolean isAutocommit() {
return autocommit;
}
diff --git a/src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
b/src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
--- a/src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
+++ b/src/main/java/nl/cwi/monetdb/mcl/responses/DataBlockResponse.java
@@ -21,21 +21,18 @@ import java.util.Arrays;
import java.util.Calendar;
/**
- * The DataBlockResponse is tabular data belonging to a
- * ResultSetResponse. Tabular data from the server typically looks
- * like:
+ * The DataBlockResponse is tabular data belonging to a ResultSetResponse. On
a MAPI connection, tabular data from the
+ * server typically looks like:
* <pre>
* [ "value", 56 ]
* </pre>
- * where each column is separated by ",\t" and each tuple surrounded
- * by brackets ("[" and "]"). A DataBlockResponse object holds the
- * raw data as read from the server, in a parsed manner, ready for
- * easy retrieval.
+ * where each column is separated by ",\t" and each tuple surrounded by
brackets ("[" and "]"). A DataBlockResponse
+ * object holds the raw data as read from the server, in a parsed manner,
ready for easy retrieval. Meanwhile on an
+ * Embedded connection, the data is automatically parsed.
*
- * This object is not intended to be queried by multiple threads
- * synchronously. It is designed to work for one thread retrieving
- * rows from it. When multiple threads will retrieve rows from this
- * object, it is possible for threads to get the same data.
+ * This object is not intended to be queried by multiple threads
synchronously. It is designed to work for one thread
+ * retrieving rows from it. When multiple threads will retrieve rows from this
object, it is possible for threads to
+ * get the same data.
*/
public class DataBlockResponse implements IIncompleteResponse {
@@ -59,6 +56,8 @@ public class DataBlockResponse implement
*
* @param rowcount the number of rows
* @param columncount the number of columns
+ * @param protocol the underlying protocol
+ * @param JdbcSQLTypes an array of the JDBC mappings of the columns
*/
DataBlockResponse(int rowcount, int columncount, AbstractProtocol
protocol, int[] JdbcSQLTypes) {
this.pos = -1;
@@ -70,10 +69,9 @@ public class DataBlockResponse implement
}
/**
- * addLine adds a String of data to this object's data array. Note that an
IndexOutOfBoundsException can be thrown
- * when an attempt is made to add more than the original construction size
specified.
+ * addLines adds a batch of rows to the block. Before adding the first
line, the column arrays are allocated.
*
- * @param protocol The connection's protocol
+ * @param protocol The connection's protocol to fetch data from
* @throws ProtocolException If the result line is not expected
*/
@Override
@@ -169,54 +167,131 @@ public class DataBlockResponse implement
/* Methods to be called after the block construction has been completed */
+ /**
+ * Sets the current line number on the block.
+ *
+ * @param blockLine the block line number
+ */
void setBlockLine(int blockLine) {
this.blockLine = blockLine;
}
+ /**
+ * Sets the data on the block.
+ * This method is called by the MonetVirtualResultSet class which should
be eliminated on the future.
+ *
+ * @param data the data to set
+ */
public void setData(Object[] data) { /* For VirtualResultSet :( */
this.data = data;
}
+ /**
+ * Gets the data on the block.
+ * This method is called by the MonetVirtualResultSet class which should
be eliminated on the future.
+ *
+ * @return the result set data
+ */
public Object[] getData() { /* For VirtualResultSet :( */
return this.data;
}
+ /**
+ * Checks if a value in the current row is null.
+ *
+ * @param column The column index starting from 0
+ * @return If the value is null or not.
+ */
public boolean checkValueIsNull(int column) {
return this.nullMappings[column][this.blockLine];
}
+ /**
+ * Gets the current row value as a Java Boolean.
+ *
+ * @param column The column index starting from 0
+ * @return A Java Boolean if the column is a boolean, otherwise a
ClassCastException is thrown
+ */
public boolean getBooleanValue(int column) {
return ((boolean[]) this.data[column])[this.blockLine];
}
+ /**
+ * Gets the current row value as a Java Byte.
+ *
+ * @param column The column index starting from 0
+ * @return A Java Byte if the column is a tinyint, otherwise a
ClassCastException is thrown
+ */
public byte getByteValue(int column) {
return ((byte[]) this.data[column])[this.blockLine];
}
+ /**
+ * Gets the current row value as a Java Short.
+ *
+ * @param column The column index starting from 0
+ * @return A Java Short if the column is a smallint, otherwise a
ClassCastException is thrown
+ */
public short getShortValue(int column) {
return ((short[]) this.data[column])[this.blockLine];
}
+ /**
+ * Gets the current row value as a Java Integer.
+ *
+ * @param column The column index starting from 0
+ * @return A Java Integer if the column is an integer or month_interval,
otherwise a ClassCastException is thrown
+ */
public int getIntValue(int column) {
return ((int[]) this.data[column])[this.blockLine];
}
+ /**
+ * Gets the current row value as a Java Long.
+ *
+ * @param column The column index starting from 0
+ * @return A Java Long if the column is a bigint or second_interval,
otherwise a ClassCastException is thrown
+ */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list