X-Git-Url: http://secure.phpeclipse.com

diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/StringMatrix.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/StringMatrix.java
index f87f14d..85c6b92 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/StringMatrix.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/StringMatrix.java
@@ -9,8 +9,9 @@ import java.util.Vector;
 /**
  * @author jparrai
  * Generic class to hold a Matrix of Strings, that is a Vector of Vectors of Strings.
- * The first Vector "line" is supposed to have headers to the values of the rest.
+ * The first StringMatrix "line" is supposed to have headers to the values of the rest.
  * Those headers will always be case insensitive
+ * Rows start at 0
  */
 public class StringMatrix {
 	private final int DEFAULT_COLUMNS = 10;
@@ -44,7 +45,7 @@ public class StringMatrix {
 	 */
 	public void addMatrixHeader(String header[]){
 			for (int i = 0; i < header.length; i++) {	
-				String element = (String) header[i];
+				String element = header[i];
 				this.header.add(element);			
 			}
 	}
@@ -94,19 +95,33 @@ public class StringMatrix {
 		matrix.clear();
 	}
 	/**
-	* Adds a String to the row indicated, to the column that matches the key 
+	* Adds a String to the row indicated, to the column that matches the key
+	* The matrix will grow to acomodate the indexes, so be careful 
 	* @param value : The string to be added
-	* @param row : The row to 
+	* @param row : The row to update 
 	*/
 	public void addAt(String key, String value, int row) {
 		grow(row);
 		Vector rowVector = (Vector) matrix.get(row);
 		int ind = header.indexOf(key);
 		if (ind < 0) return;
-		if (rowVector.size() < ind+1) rowVector.setSize(ind);
+		if (rowVector.size() <= ind) rowVector.setSize(ind);
 		rowVector.add(ind, value);
 	}
 	/**
+	 * Adds a String in the location specified.
+	 * The matrix will grow to acomodate the indexes, so be careful 
+	 * @param column	Column selected
+	 * @param row		row selected
+	 * @param value		value to add
+	 */
+	public void addAt(int column, int row, String value) {
+		grow(row);
+		Vector rowVector = (Vector) matrix.get(row);
+		if (column >= rowVector.size()) rowVector.setSize(column);
+		rowVector.add(column, value);
+	}
+	/**
 	 * Adds a whole vector to the end of the row indicated
 	 * @param value : The vector to be added
 	 * @param row : The row to 
@@ -233,11 +248,13 @@ public class StringMatrix {
 	 * @param row : 0-index column
 	 * @return
 	 */
-	private String get(int col, int row){
+	public String get(int col, int row){
 		if (col < 0 || row < 0) return null; 
 		Vector rowVector = (Vector) matrix.get(row);
 		if (rowVector ==  null) return null;
-		return (String) rowVector.get(col);
+		if (col < rowVector.size())
+			return (String) rowVector.get(col);
+		else return null;
 	}
 	
 	// Generic interfaces
@@ -275,14 +292,28 @@ public class StringMatrix {
 	public int size() {
 		return matrix.size();
 	}
+	/**
+	 * @return The number of columns of the StringMatrix
+	 */
 	public int getNumColumns() {
 		return header.size();
 	}
+	/**
+	 * @param i
+	 * @return The name of the header column in the "i" position. Null if no such position.
+	 */
 	public String getHeaderColumn(int i){
-		return (String) header.get(i);
+		if (i < header.size())
+			return (String) header.get(i);
+		return null;
 	}
+	/**
+	 * Deletes the row number i
+	 * @param i
+	 */
 	public void deleteRow(int i){
-		matrix.remove(i);
+		if (i < matrix.size())
+			matrix.remove(i);
 	}