diff --git a/src/main/java/com/exxeleron/qjava/QKeyedTable.java b/src/main/java/com/exxeleron/qjava/QKeyedTable.java
index ab3ec39..b09ae2f 100644
--- a/src/main/java/com/exxeleron/qjava/QKeyedTable.java
+++ b/src/main/java/com/exxeleron/qjava/QKeyedTable.java
@@ -20,7 +20,7 @@
/**
* Represents a q keyed table type.
*/
-public class QKeyedTable implements Iterable
* Returns an iterator over a key/value pairs stored in the keyed table.
diff --git a/src/main/java/com/exxeleron/qjava/QTable.java b/src/main/java/com/exxeleron/qjava/QTable.java
index d07f7eb..a4595a1 100644
--- a/src/main/java/com/exxeleron/qjava/QTable.java
+++ b/src/main/java/com/exxeleron/qjava/QTable.java
@@ -24,7 +24,7 @@
/**
* Represents a q table type.
*/
-public final class QTable implements Iterablenull
if column doesn't exist in the table.
*
* @param column
* Name of the column
- * @return 0 based column index
+ * @return 0 based column index, null
if column with given name is not defined
*/
- public int getColumnIndex( final String column ) {
+ public Integer getColumnIndex( final String column ) {
return columnsMap.get(column);
}
- /**
- * Gets a number of rows in current {@link QTable}.
- *
- * @return a number of rows
+ /* (non-Javadoc)
+ * @see com.exxeleron.qjava.Table#size()
*/
public int getRowsCount() {
return rowsCount;
}
- /**
- * Gets a number of columns in current {@link QTable}.
- *
- * @return a number of columns
+ /* (non-Javadoc)
+ * @see com.exxeleron.qjava.Table#getColumnsCount()
*/
public int getColumnsCount() {
return columns.length;
diff --git a/src/main/java/com/exxeleron/qjava/Table.java b/src/main/java/com/exxeleron/qjava/Table.java
new file mode 100644
index 0000000..853fa00
--- /dev/null
+++ b/src/main/java/com/exxeleron/qjava/Table.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2011-2015 Exxeleron GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.exxeleron.qjava;
+
+/**
+ * Common interface for tables.
+ */
+public interface Table {
+
+ /**
+ * Gets a number of rows in current {@link QKeyedTable}.
+ *
+ * @return a number of rows
+ */
+ public abstract int getRowsCount();
+
+ /**
+ * @return a number of columns
+ */
+ public abstract int getColumnsCount();
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/exxeleron/qjava/TestCollections.java b/src/test/java/com/exxeleron/qjava/TestCollections.java
new file mode 100644
index 0000000..8821af6
--- /dev/null
+++ b/src/test/java/com/exxeleron/qjava/TestCollections.java
@@ -0,0 +1,149 @@
+/**
+ * Copyright (c) 2011-2015 Exxeleron GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.exxeleron.qjava;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
+
+import java.lang.reflect.Array;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+import com.exxeleron.qjava.QKeyedTable.KeyValuePair;
+import com.exxeleron.qjava.QTable.Row;
+
+public class TestCollections {
+
+ private static QTable getTestTable() {
+ final String[] columns = new String[] { "f", "i", "s" };
+ final Object[] data = new Object[] { new double[] { -1.1, 0.0, 10.32 }, new int[] { 10, 0, -2 }, new String[] { "foo", "bar", "" } };
+ final QTable table = new QTable(columns, data);
+ return table;
+ }
+
+ @Test
+ public void testQTable() {
+ final QTable t = getTestTable();
+
+ assertEquals(null, t.getColumnIndex("unknown"));
+ assertEquals(Integer.valueOf(0), t.getColumnIndex("f"));
+
+ assertEquals(t, t);
+ assertEquals(t, getTestTable());
+
+ int i = 0;
+ final Iterator