summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2013-03-15 11:58:21 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2013-03-15 11:58:21 +0000
commit812bc21edd99f56d79b4a20c3a1cd006450ca100 (patch)
tree0acb9e5497810a468eee9ddfbb571ece9c4cf288 /src
parentc6cb796d10660aa617cfab6e52985a75750b1ad2 (diff)
downloadjackcess-812bc21edd99f56d79b4a20c3a1cd006450ca100.tar.gz
jackcess-812bc21edd99f56d79b4a20c3a1cd006450ca100.zip
adding explicit row type
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@685 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Cursor.java38
-rw-r--r--src/java/com/healthmarketscience/jackcess/CursorBuilder.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/IndexCursor.java8
-rw-r--r--src/java/com/healthmarketscience/jackcess/Row.java32
-rw-r--r--src/java/com/healthmarketscience/jackcess/Table.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java29
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java3
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java7
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/ComplexColumnSupport.java14
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java77
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java56
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/FKEnforcer.java13
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java23
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/RowImpl.java48
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/TableImpl.java34
-rw-r--r--src/java/com/healthmarketscience/jackcess/query/Query.java22
-rw-r--r--src/java/com/healthmarketscience/jackcess/util/ExportUtil.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/util/Joiner.java21
-rw-r--r--src/java/com/healthmarketscience/jackcess/util/RowFilter.java42
22 files changed, 298 insertions, 195 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Cursor.java b/src/java/com/healthmarketscience/jackcess/Cursor.java
index 622cc27..765685d 100644
--- a/src/java/com/healthmarketscience/jackcess/Cursor.java
+++ b/src/java/com/healthmarketscience/jackcess/Cursor.java
@@ -43,7 +43,7 @@ import com.healthmarketscience.jackcess.util.ColumnMatcher;
*
* @author James Ahlborn
*/
-public interface Cursor extends Iterable<Map<String, Object>>
+public interface Cursor extends Iterable<Row>
{
// FIXME, include iterable and iterator methods?
@@ -136,7 +136,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> reverseIterable();
+ public Iterable<Row> reverseIterable();
/**
* Returns an Iterable whose iterator() method calls <code>afterLast</code>
@@ -147,7 +147,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> reverseIterable(
+ public Iterable<Row> reverseIterable(
Collection<String> columnNames);
/**
@@ -158,7 +158,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> iterator();
+ public Iterator<Row> iterator();
/**
* Returns an Iterable whose iterator() method returns the result of a call
@@ -166,7 +166,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> iterable(
+ public Iterable<Row> iterable(
Collection<String> columnNames);
/**
@@ -177,7 +177,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> iterator(Collection<String> columnNames);
+ public Iterator<Row> iterator(Collection<String> columnNames);
/**
* Returns an Iterable whose iterator() method returns the result of a call
@@ -185,7 +185,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> columnMatchIterable(
+ public Iterable<Row> columnMatchIterable(
Column columnPattern, Object valuePattern);
/**
@@ -197,7 +197,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
Column columnPattern, Object valuePattern);
/**
@@ -210,7 +210,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
Collection<String> columnNames, Column columnPattern, Object valuePattern);
/**
@@ -219,7 +219,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> rowMatchIterable(
+ public Iterable<Row> rowMatchIterable(
Map<String,?> rowPattern);
/**
@@ -231,7 +231,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> rowMatchIterator(
+ public Iterator<Row> rowMatchIterator(
Map<String,?> rowPattern);
/**
@@ -240,7 +240,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String, Object>> rowMatchIterable(
+ public Iterable<Row> rowMatchIterable(
Collection<String> columnNames,
Map<String,?> rowPattern);
@@ -254,7 +254,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String, Object>> rowMatchIterator(
+ public Iterator<Row> rowMatchIterator(
Collection<String> columnNames, Map<String,?> rowPattern);
/**
@@ -276,7 +276,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @return The next row in this table (Column name -> Column value), or
* {@code null} if no next row is found
*/
- public Map<String, Object> getNextRow() throws IOException;
+ public Row getNextRow() throws IOException;
/**
* Moves to the next row in the table and returns it.
@@ -284,7 +284,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @return The next row in this table (Column name -> Column value), or
* {@code null} if no next row is found
*/
- public Map<String, Object> getNextRow(Collection<String> columnNames)
+ public Row getNextRow(Collection<String> columnNames)
throws IOException;
/**
@@ -292,7 +292,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @return The previous row in this table (Column name -> Column value), or
* {@code null} if no previous row is found
*/
- public Map<String, Object> getPreviousRow() throws IOException;
+ public Row getPreviousRow() throws IOException;
/**
* Moves to the previous row in the table and returns it.
@@ -300,7 +300,7 @@ public interface Cursor extends Iterable<Map<String, Object>>
* @return The previous row in this table (Column name -> Column value), or
* {@code null} if no previous row is found
*/
- public Map<String, Object> getPreviousRow(Collection<String> columnNames)
+ public Row getPreviousRow(Collection<String> columnNames)
throws IOException;
/**
@@ -413,13 +413,13 @@ public interface Cursor extends Iterable<Map<String, Object>>
/**
* Returns the current row in this cursor (Column name -> Column value).
*/
- public Map<String, Object> getCurrentRow() throws IOException;
+ public Row getCurrentRow() throws IOException;
/**
* Returns the current row in this cursor (Column name -> Column value).
* @param columnNames Only column names in this collection will be returned
*/
- public Map<String, Object> getCurrentRow(Collection<String> columnNames)
+ public Row getCurrentRow(Collection<String> columnNames)
throws IOException;
/**
diff --git a/src/java/com/healthmarketscience/jackcess/CursorBuilder.java b/src/java/com/healthmarketscience/jackcess/CursorBuilder.java
index 985f276..8c4a725 100644
--- a/src/java/com/healthmarketscience/jackcess/CursorBuilder.java
+++ b/src/java/com/healthmarketscience/jackcess/CursorBuilder.java
@@ -406,7 +406,7 @@ public class CursorBuilder {
* @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found.
*/
- public static Map<String,Object> findRow(Table table, Map<String,?> rowPattern)
+ public static Row findRow(Table table, Map<String,?> rowPattern)
throws IOException
{
Cursor cursor = createCursor(table);
@@ -457,8 +457,7 @@ public class CursorBuilder {
* @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found.
*/
- public static Map<String,Object> findRow(Table table, Index index,
- Map<String,?> rowPattern)
+ public static Row findRow(Table table, Index index, Map<String,?> rowPattern)
throws IOException
{
Cursor cursor = createCursor(table, index);
diff --git a/src/java/com/healthmarketscience/jackcess/IndexCursor.java b/src/java/com/healthmarketscience/jackcess/IndexCursor.java
index b8b4556..ebf1362 100644
--- a/src/java/com/healthmarketscience/jackcess/IndexCursor.java
+++ b/src/java/com/healthmarketscience/jackcess/IndexCursor.java
@@ -73,7 +73,7 @@ public interface IndexCursor extends Cursor
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String,Object>> entryIterator(Object... entryValues);
+ public Iterator<Row> entryIterator(Object... entryValues);
/**
* Returns a modifiable Iterator which will iterate through all the rows of
@@ -82,7 +82,7 @@ public interface IndexCursor extends Cursor
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterator<Map<String,Object>> entryIterator(
+ public Iterator<Row> entryIterator(
Collection<String> columnNames, Object... entryValues);
/**
@@ -91,7 +91,7 @@ public interface IndexCursor extends Cursor
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String,Object>> entryIterable(Object... entryValues);
+ public Iterable<Row> entryIterable(Object... entryValues);
/**
* Returns an Iterable whose iterator() method returns the result of a call
@@ -99,7 +99,7 @@ public interface IndexCursor extends Cursor
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String,Object>> entryIterable(
+ public Iterable<Row> entryIterable(
Collection<String> columnNames, Object... entryValues);
}
diff --git a/src/java/com/healthmarketscience/jackcess/Row.java b/src/java/com/healthmarketscience/jackcess/Row.java
new file mode 100644
index 0000000..1c5f985
--- /dev/null
+++ b/src/java/com/healthmarketscience/jackcess/Row.java
@@ -0,0 +1,32 @@
+/*
+Copyright (c) 2013 James Ahlborn
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+USA
+*/
+
+package com.healthmarketscience.jackcess;
+
+import java.util.Map;
+
+/**
+ * A row of data as column->value pairs.
+ *
+ * @author James Ahlborn
+ */
+public interface Row extends Map<String,Object>
+{
+
+}
diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java
index d398972..20d9e4f 100644
--- a/src/java/com/healthmarketscience/jackcess/Table.java
+++ b/src/java/com/healthmarketscience/jackcess/Table.java
@@ -33,7 +33,7 @@ import com.healthmarketscience.jackcess.util.ErrorHandler;
* @author James Ahlborn
* @usage _general_class_
*/
-public interface Table extends Iterable<Map<String, Object>>
+public interface Table extends Iterable<Row>
{
/**
* enum which controls the ordering of the columns in a table.
@@ -201,7 +201,7 @@ public interface Table extends Iterable<Map<String, Object>>
* the default cursor)
* @usage _general_method_
*/
- public Map<String, Object> getNextRow() throws IOException;
+ public Row getNextRow() throws IOException;
/**
* @return a simple Cursor, initialized on demand and held by this table.
diff --git a/src/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java b/src/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java
index 541c6d8..0a07e9d 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/AttachmentColumnInfo.java
@@ -23,9 +23,10 @@ import java.io.IOException;
import java.util.Date;
import java.util.Map;
-import com.healthmarketscience.jackcess.impl.ByteUtil;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.impl.ByteUtil;
/**
@@ -131,7 +132,7 @@ public class AttachmentColumnInfo extends ComplexColumnInfo<Attachment>
@Override
protected AttachmentImpl toValue(ComplexValueForeignKey complexValueFk,
- Map<String,Object> rawValue) {
+ Row rawValue) {
int id = (Integer)getPrimaryKeyColumn().getRowValue(rawValue);
String url = (String)getFileUrlColumn().getRowValue(rawValue);
String name = (String)getFileNameColumn().getRowValue(rawValue);
diff --git a/src/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java b/src/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java
index 05bd308..376c25a 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/ComplexColumnInfo.java
@@ -33,6 +33,7 @@ import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.Row;
/**
* Base class for the additional information tracked for complex columns.
@@ -120,13 +121,13 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
.size();
}
- public List<Map<String,Object>> getRawValues(int complexValueFk)
+ public List<Row> getRawValues(int complexValueFk)
throws IOException
{
return getRawValues(complexValueFk, null);
}
- private Iterator<Map<String,Object>> getComplexValFkIter(
+ private Iterator<Row> getComplexValFkIter(
int complexValueFk, Collection<String> columnNames)
throws IOException
{
@@ -139,17 +140,17 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
return _complexValIdCursor.entryIterator(columnNames, complexValueFk);
}
- public List<Map<String,Object>> getRawValues(int complexValueFk,
- Collection<String> columnNames)
+ public List<Row> getRawValues(int complexValueFk,
+ Collection<String> columnNames)
throws IOException
{
- Iterator<Map<String,Object>> entryIter =
+ Iterator<Row> entryIter =
getComplexValFkIter(complexValueFk, columnNames);
if(!entryIter.hasNext()) {
return Collections.emptyList();
}
- List<Map<String,Object>> values = new ArrayList<Map<String,Object>>();
+ List<Row> values = new ArrayList<Row>();
while(entryIter.hasNext()) {
values.add(entryIter.next());
}
@@ -160,7 +161,7 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
public List<V> getValues(ComplexValueForeignKey complexValueFk)
throws IOException
{
- List<Map<String,Object>> rawValues = getRawValues(complexValueFk.get());
+ List<Row> rawValues = getRawValues(complexValueFk.get());
if(rawValues.isEmpty()) {
return Collections.emptyList();
}
@@ -169,18 +170,18 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
}
protected List<V> toValues(ComplexValueForeignKey complexValueFk,
- List<Map<String,Object>> rawValues)
+ List<Row> rawValues)
throws IOException
{
List<V> values = new ArrayList<V>();
- for(Map<String,Object> rawValue : rawValues) {
+ for(Row rawValue : rawValues) {
values.add(toValue(complexValueFk, rawValue));
}
return values;
}
- public int addRawValue(Map<String,Object> rawValue) throws IOException {
+ public int addRawValue(Row rawValue) throws IOException {
Object[] row = _flatTable.asRow(rawValue);
_flatTable.addRow(row);
return (Integer)_pkCol.getRowValue(row);
@@ -200,7 +201,7 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
}
}
- public int updateRawValue(Map<String,Object> rawValue) throws IOException {
+ public int updateRawValue(Row rawValue) throws IOException {
Integer id = (Integer)_pkCol.getRowValue(rawValue);
updateRow(id, _flatTable.asUpdateRow(rawValue));
return id;
@@ -218,7 +219,7 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
}
}
- public void deleteRawValue(Map<String,Object> rawValue) throws IOException {
+ public void deleteRawValue(Row rawValue) throws IOException {
deleteRow((Integer)_pkCol.getRowValue(rawValue));
}
@@ -233,7 +234,7 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
}
public void deleteAllValues(int complexValueFk) throws IOException {
- Iterator<Map<String,Object>> entryIter =
+ Iterator<Row> entryIter =
getComplexValFkIter(complexValueFk, Collections.<String>emptySet());
try {
while(entryIter.hasNext()) {
@@ -325,7 +326,7 @@ public abstract class ComplexColumnInfo<V extends ComplexValue>
protected abstract V toValue(
ComplexValueForeignKey complexValueFk,
- Map<String,Object> rawValues)
+ Row rawValues)
throws IOException;
protected static abstract class ComplexValueImpl implements ComplexValue
diff --git a/src/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java b/src/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java
index 80735e3..a4b4d02 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/ComplexValueForeignKey.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Row;
/**
* Value which is returned for a complex column. This value corresponds to a
@@ -122,8 +123,7 @@ public class ComplexValueForeignKey extends Number
return getComplexInfo().countValues(get());
}
- public List<Map<String,Object>> getRawValues()
- throws IOException
+ public List<Row> getRawValues() throws IOException
{
return getComplexInfo().getRawValues(get());
}
diff --git a/src/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java b/src/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java
index 76f60bd..9add8c7 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/MultiValueColumnInfo.java
@@ -24,6 +24,7 @@ import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.Row;
/**
* Complex column info for a column holding multiple values per row.
@@ -56,7 +57,7 @@ public class MultiValueColumnInfo extends ComplexColumnInfo<SingleValue>
@Override
protected SingleValueImpl toValue(
ComplexValueForeignKey complexValueFk,
- Map<String,Object> rawValue)
+ Row rawValue)
{
int id = (Integer)getPrimaryKeyColumn().getRowValue(rawValue);
Object value = getValueColumn().getRowValue(rawValue);
diff --git a/src/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java b/src/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java
index 03bd8b1..071da06 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/UnsupportedColumnInfo.java
@@ -26,6 +26,8 @@ import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.impl.RowImpl;
/**
* Complex column info for an unsupported complex type.
@@ -55,7 +57,7 @@ public class UnsupportedColumnInfo extends ComplexColumnInfo<UnsupportedValue>
@Override
protected UnsupportedValueImpl toValue(
ComplexValueForeignKey complexValueFk,
- Map<String,Object> rawValue)
+ Row rawValue)
{
int id = (Integer)getPrimaryKeyColumn().getRowValue(rawValue);
diff --git a/src/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java b/src/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java
index 894e28a..e29dd38 100644
--- a/src/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java
+++ b/src/java/com/healthmarketscience/jackcess/complex/VersionHistoryColumnInfo.java
@@ -26,8 +26,9 @@ import java.util.List;
import java.util.Map;
import com.healthmarketscience.jackcess.Column;
-import com.healthmarketscience.jackcess.impl.ColumnImpl;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.impl.ColumnImpl;
/**
* Complex column info for a column which tracking the version history of an
@@ -114,7 +115,7 @@ public class VersionHistoryColumnInfo extends ComplexColumnInfo<Version>
@Override
protected List<Version> toValues(ComplexValueForeignKey complexValueFk,
- List<Map<String,Object>> rawValues)
+ List<Row> rawValues)
throws IOException
{
List<Version> versions = super.toValues(complexValueFk, rawValues);
@@ -127,7 +128,7 @@ public class VersionHistoryColumnInfo extends ComplexColumnInfo<Version>
@Override
protected VersionImpl toValue(ComplexValueForeignKey complexValueFk,
- Map<String,Object> rawValue) {
+ Row rawValue) {
int id = (Integer)getPrimaryKeyColumn().getRowValue(rawValue);
String value = (String)getValueColumn().getRowValue(rawValue);
Date modifiedDate = (Date)getModifiedDateColumn().getRowValue(rawValue);
diff --git a/src/java/com/healthmarketscience/jackcess/impl/ComplexColumnSupport.java b/src/java/com/healthmarketscience/jackcess/impl/ComplexColumnSupport.java
index 76a9f8f..f427247 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/ComplexColumnSupport.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/ComplexColumnSupport.java
@@ -26,6 +26,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.CursorBuilder;
+import com.healthmarketscience.jackcess.DataType;
+import com.healthmarketscience.jackcess.IndexCursor;
+import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.complex.AttachmentColumnInfo;
import com.healthmarketscience.jackcess.complex.ComplexColumnInfo;
import com.healthmarketscience.jackcess.complex.ComplexValue;
@@ -34,11 +40,7 @@ import com.healthmarketscience.jackcess.complex.UnsupportedColumnInfo;
import com.healthmarketscience.jackcess.complex.VersionHistoryColumnInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.Table;
-import com.healthmarketscience.jackcess.IndexCursor;
-import com.healthmarketscience.jackcess.CursorBuilder;
-import com.healthmarketscience.jackcess.Column;
+
/**
* Utility code for loading complex columns.
@@ -77,7 +79,7 @@ public class ComplexColumnSupport
"Could not find complex column info for complex column with id " +
complexTypeId);
}
- Map<String,Object> cColRow = cursor.getCurrentRow();
+ Row cColRow = cursor.getCurrentRow();
int tableId = (Integer)cColRow.get(COL_TABLE_ID);
if(tableId != column.getTable().getTableDefPageNumber()) {
throw new IOException(
diff --git a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
index fd5db70..7583034 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/CursorImpl.java
@@ -42,6 +42,7 @@ import com.healthmarketscience.jackcess.Cursor;
import com.healthmarketscience.jackcess.util.ErrorHandler;
import com.healthmarketscience.jackcess.util.ColumnMatcher;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.RowId;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.util.SimpleColumnMatcher;
@@ -195,7 +196,7 @@ public abstract class CursorImpl implements Cursor
* @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found.
*/
- public static Map<String,Object> findRow(TableImpl table,
+ public static Row findRow(TableImpl table,
Map<String,?> rowPattern)
throws IOException
{
@@ -247,7 +248,7 @@ public abstract class CursorImpl implements Cursor
* @param rowPattern pattern to be used to find the row
* @return the matching row or {@code null} if a match could not be found.
*/
- public static Map<String,Object> findRow(TableImpl table, IndexImpl index,
+ public static Row findRow(TableImpl table, IndexImpl index,
Map<String,?> rowPattern)
throws IOException
{
@@ -410,65 +411,65 @@ public abstract class CursorImpl implements Cursor
_rowState.reset();
}
- public Iterable<Map<String, Object>> reverseIterable() {
+ public Iterable<Row> reverseIterable() {
return reverseIterable(null);
}
- public Iterable<Map<String, Object>> reverseIterable(
+ public Iterable<Row> reverseIterable(
final Collection<String> columnNames)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return new RowIterator(columnNames, MOVE_REVERSE);
}
};
}
- public Iterator<Map<String, Object>> iterator()
+ public Iterator<Row> iterator()
{
return iterator(null);
}
- public Iterable<Map<String, Object>> iterable(
+ public Iterable<Row> iterable(
final Collection<String> columnNames)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return CursorImpl.this.iterator(columnNames);
}
};
}
- public Iterator<Map<String, Object>> iterator(Collection<String> columnNames)
+ public Iterator<Row> iterator(Collection<String> columnNames)
{
return new RowIterator(columnNames, MOVE_FORWARD);
}
- public Iterable<Map<String, Object>> columnMatchIterable(
+ public Iterable<Row> columnMatchIterable(
Column columnPattern, Object valuePattern)
{
return columnMatchIterable((ColumnImpl)columnPattern, valuePattern);
}
- public Iterable<Map<String, Object>> columnMatchIterable(
+ public Iterable<Row> columnMatchIterable(
ColumnImpl columnPattern, Object valuePattern)
{
return columnMatchIterable(null, columnPattern, valuePattern);
}
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
Column columnPattern, Object valuePattern)
{
return columnMatchIterator((ColumnImpl)columnPattern, valuePattern);
}
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
ColumnImpl columnPattern, Object valuePattern)
{
return columnMatchIterator(null, columnPattern, valuePattern);
}
- public Iterable<Map<String, Object>> columnMatchIterable(
+ public Iterable<Row> columnMatchIterable(
Collection<String> columnNames,
Column columnPattern, Object valuePattern)
{
@@ -476,19 +477,19 @@ public abstract class CursorImpl implements Cursor
valuePattern);
}
- public Iterable<Map<String, Object>> columnMatchIterable(
+ public Iterable<Row> columnMatchIterable(
final Collection<String> columnNames,
final ColumnImpl columnPattern, final Object valuePattern)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return CursorImpl.this.columnMatchIterator(
columnNames, columnPattern, valuePattern);
}
};
}
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
Collection<String> columnNames, Column columnPattern,
Object valuePattern)
{
@@ -496,38 +497,38 @@ public abstract class CursorImpl implements Cursor
valuePattern);
}
- public Iterator<Map<String, Object>> columnMatchIterator(
+ public Iterator<Row> columnMatchIterator(
Collection<String> columnNames, ColumnImpl columnPattern,
Object valuePattern)
{
return new ColumnMatchIterator(columnNames, columnPattern, valuePattern);
}
- public Iterable<Map<String, Object>> rowMatchIterable(
+ public Iterable<Row> rowMatchIterable(
Map<String,?> rowPattern)
{
return rowMatchIterable(null, rowPattern);
}
- public Iterator<Map<String, Object>> rowMatchIterator(
+ public Iterator<Row> rowMatchIterator(
Map<String,?> rowPattern)
{
return rowMatchIterator(null, rowPattern);
}
- public Iterable<Map<String, Object>> rowMatchIterable(
+ public Iterable<Row> rowMatchIterable(
final Collection<String> columnNames,
final Map<String,?> rowPattern)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return CursorImpl.this.rowMatchIterator(
columnNames, rowPattern);
}
};
}
- public Iterator<Map<String, Object>> rowMatchIterator(
+ public Iterator<Row> rowMatchIterator(
Collection<String> columnNames, Map<String,?> rowPattern)
{
return new RowMatchIterator(columnNames, rowPattern);
@@ -541,21 +542,21 @@ public abstract class CursorImpl implements Cursor
_table.updateRow(_rowState, _curPos.getRowId(), row);
}
- public Map<String, Object> getNextRow() throws IOException {
+ public Row getNextRow() throws IOException {
return getNextRow(null);
}
- public Map<String, Object> getNextRow(Collection<String> columnNames)
+ public Row getNextRow(Collection<String> columnNames)
throws IOException
{
return getAnotherRow(columnNames, MOVE_FORWARD);
}
- public Map<String, Object> getPreviousRow() throws IOException {
+ public Row getPreviousRow() throws IOException {
return getPreviousRow(null);
}
- public Map<String, Object> getPreviousRow(Collection<String> columnNames)
+ public Row getPreviousRow(Collection<String> columnNames)
throws IOException
{
return getAnotherRow(columnNames, MOVE_REVERSE);
@@ -570,7 +571,7 @@ public abstract class CursorImpl implements Cursor
* "next" may be backwards if moveForward is {@code false}, or
* {@code null} if there is not another row in the given direction.
*/
- private Map<String, Object> getAnotherRow(Collection<String> columnNames,
+ private Row getAnotherRow(Collection<String> columnNames,
boolean moveForward)
throws IOException
{
@@ -784,7 +785,7 @@ public abstract class CursorImpl implements Cursor
public boolean currentRowMatches(Map<String,?> rowPattern)
throws IOException
{
- Map<String,Object> row = getCurrentRow(rowPattern.keySet());
+ Row row = getCurrentRow(rowPattern.keySet());
if(rowPattern.size() != row.size()) {
return false;
@@ -872,12 +873,12 @@ public abstract class CursorImpl implements Cursor
return numMovedRows;
}
- public Map<String, Object> getCurrentRow() throws IOException
+ public Row getCurrentRow() throws IOException
{
return getCurrentRow(null);
}
- public Map<String, Object> getCurrentRow(Collection<String> columnNames)
+ public Row getCurrentRow(Collection<String> columnNames)
throws IOException
{
return _table.getRow(_rowState, _curPos.getRowId(), columnNames);
@@ -946,7 +947,7 @@ public abstract class CursorImpl implements Cursor
* Base implementation of iterator for this cursor, modifiable.
*/
protected abstract class BaseIterator
- implements Iterator<Map<String, Object>>
+ implements Iterator<Row>
{
protected final Collection<String> _columnNames;
protected Boolean _hasNext;
@@ -969,12 +970,12 @@ public abstract class CursorImpl implements Cursor
return _hasNext;
}
- public Map<String, Object> next() {
+ public Row next() {
if(!hasNext()) {
throw new NoSuchElementException();
}
try {
- Map<String, Object> rtn = getCurrentRow(_columnNames);
+ Row rtn = getCurrentRow(_columnNames);
_hasNext = null;
return rtn;
} catch(IOException e) {
diff --git a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 75cd01d..2083c47 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -57,23 +57,25 @@ import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
-import com.healthmarketscience.jackcess.query.Query;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import com.healthmarketscience.jackcess.Database;
-import com.healthmarketscience.jackcess.util.ErrorHandler;
-import com.healthmarketscience.jackcess.Table;
-import com.healthmarketscience.jackcess.util.LinkResolver;
import com.healthmarketscience.jackcess.ColumnBuilder;
-import com.healthmarketscience.jackcess.IndexBuilder;
-import com.healthmarketscience.jackcess.Relationship;
-import com.healthmarketscience.jackcess.PropertyMap;
import com.healthmarketscience.jackcess.Cursor;
-import com.healthmarketscience.jackcess.IndexCursor;
-import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.DataType;
+import com.healthmarketscience.jackcess.Database;
+import com.healthmarketscience.jackcess.IndexBuilder;
+import com.healthmarketscience.jackcess.IndexCursor;
+import com.healthmarketscience.jackcess.PropertyMap;
+import com.healthmarketscience.jackcess.Relationship;
+import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.query.Query;
+import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
+import com.healthmarketscience.jackcess.util.ErrorHandler;
+import com.healthmarketscience.jackcess.util.LinkResolver;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
*
@@ -891,7 +893,7 @@ public class DatabaseImpl implements Database
}
// lookup table info from system catalog
- Map<String,Object> objectRow = _tableFinder.getObjectRow(
+ Row objectRow = _tableFinder.getObjectRow(
tableDefPageNumber, SYSTEM_CATALOG_COLUMNS);
if(objectRow == null) {
return null;
@@ -1065,10 +1067,10 @@ public class DatabaseImpl implements Database
}
// find all the queries from the system catalog
- List<Map<String,Object>> queryInfo = new ArrayList<Map<String,Object>>();
+ List<Row> queryInfo = new ArrayList<Row>();
Map<Integer,List<Query.Row>> queryRowMap =
new HashMap<Integer,List<Query.Row>>();
- for(Map<String,Object> row :
+ for(Row row :
CursorImpl.createCursor(_systemCatalog).iterable(SYSTEM_CATALOG_COLUMNS))
{
String name = (String) row.get(CAT_COL_NAME);
@@ -1080,7 +1082,7 @@ public class DatabaseImpl implements Database
}
// find all the query rows
- for(Map<String,Object> row : CursorImpl.createCursor(_queries)) {
+ for(Row row : CursorImpl.createCursor(_queries)) {
Query.Row queryRow = new Query.Row(row);
List<Query.Row> queryRows = queryRowMap.get(queryRow.objectId);
if(queryRows == null) {
@@ -1093,7 +1095,7 @@ public class DatabaseImpl implements Database
// lastly, generate all the queries
List<Query> queries = new ArrayList<Query>();
- for(Map<String,Object> row : queryInfo) {
+ for(Row row : queryInfo) {
String name = (String) row.get(CAT_COL_NAME);
Integer id = (Integer)row.get(CAT_COL_ID);
int flags = (Integer)row.get(CAT_COL_FLAGS);
@@ -1137,7 +1139,7 @@ public class DatabaseImpl implements Database
public PropertyMaps getPropertiesForObject(int objectId)
throws IOException
{
- Map<String,Object> objectRow = _tableFinder.getObjectRow(
+ Row objectRow = _tableFinder.getObjectRow(
objectId, SYSTEM_CATALOG_PROPS_COLUMNS);
byte[] propsBytes = null;
if(objectRow != null) {
@@ -1161,7 +1163,7 @@ public class DatabaseImpl implements Database
}
}
- Map<String,Object> objectRow = _tableFinder.getObjectRow(
+ Row objectRow = _tableFinder.getObjectRow(
_dbParentId, dbName, SYSTEM_CATALOG_PROPS_COLUMNS);
byte[] propsBytes = null;
int objectId = -1;
@@ -1226,7 +1228,7 @@ public class DatabaseImpl implements Database
Cursor cursor, TableImpl fromTable, TableImpl toTable,
List<Relationship> relationships)
{
- for(Map<String,Object> row : cursor) {
+ for(Row row : cursor) {
String fromName = (String)row.get(REL_COL_FROM_TABLE);
String toName = (String)row.get(REL_COL_TO_TABLE);
@@ -1351,7 +1353,7 @@ public class DatabaseImpl implements Database
Cursor cursor = createCursorWithOptionalIndex(
getAccessControlEntries(), ACE_COL_OBJECT_ID, _tableParentId);
- for(Map<String, Object> row : cursor) {
+ for(Row row : cursor) {
Integer objId = (Integer)row.get(ACE_COL_OBJECT_ID);
if(_tableParentId.equals(objId)) {
_newTableSIDs.add((byte[])row.get(ACE_COL_SID));
@@ -1791,7 +1793,7 @@ public class DatabaseImpl implements Database
return (Integer)cur.getCurrentRowValue(idCol);
}
- public Map<String,Object> getObjectRow(Integer parentId, String name,
+ public Row getObjectRow(Integer parentId, String name,
Collection<String> columns)
throws IOException
{
@@ -1799,7 +1801,7 @@ public class DatabaseImpl implements Database
return ((cur != null) ? cur.getCurrentRow(columns) : null);
}
- public Map<String,Object> getObjectRow(
+ public Row getObjectRow(
Integer objectId, Collection<String> columns)
throws IOException
{
@@ -1811,7 +1813,7 @@ public class DatabaseImpl implements Database
boolean systemTables)
throws IOException
{
- for(Map<String,Object> row : getTableNamesCursor().iterable(
+ for(Row row : getTableNamesCursor().iterable(
SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
String tableName = (String)row.get(CAT_COL_NAME);
@@ -1893,7 +1895,7 @@ public class DatabaseImpl implements Database
return null;
}
- Map<String,Object> row = _systemCatalogCursor.getCurrentRow(
+ Row row = _systemCatalogCursor.getCurrentRow(
SYSTEM_CATALOG_COLUMNS);
Integer pageNumber = (Integer)row.get(CAT_COL_ID);
String realName = (String)row.get(CAT_COL_NAME);
@@ -1969,7 +1971,7 @@ public class DatabaseImpl implements Database
@Override
public TableInfo lookupTable(String tableName) throws IOException {
- for(Map<String,Object> row : _systemCatalogCursor.iterable(
+ for(Row row : _systemCatalogCursor.iterable(
SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
Short type = (Short)row.get(CAT_COL_TYPE);
diff --git a/src/java/com/healthmarketscience/jackcess/impl/FKEnforcer.java b/src/java/com/healthmarketscience/jackcess/impl/FKEnforcer.java
index fcd654f..e0efe15 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/FKEnforcer.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/FKEnforcer.java
@@ -29,13 +29,14 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
-import com.healthmarketscience.jackcess.util.ColumnMatcher;
-import com.healthmarketscience.jackcess.util.Joiner;
-import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
-import com.healthmarketscience.jackcess.IndexCursor;
-import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.Index;
+import com.healthmarketscience.jackcess.IndexCursor;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
+import com.healthmarketscience.jackcess.util.ColumnMatcher;
+import com.healthmarketscience.jackcess.util.Joiner;
/**
* Utility class used by Table to enforce foreign-key relationships (if
@@ -248,7 +249,7 @@ final class FKEnforcer
List<? extends Index.Column> toCols = joiner.getToIndex().getColumns();
Object[] toRow = new Object[joiner.getToTable().getColumnCount()];
- for(Iterator<Map<String,Object>> iter = joiner.findRows(
+ for(Iterator<Row> iter = joiner.findRows(
oldFromRow, Collections.<String>emptySet()); iter.hasNext(); ) {
iter.next();
diff --git a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
index d262e2a..f6c49e3 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
@@ -27,14 +27,15 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import com.healthmarketscience.jackcess.impl.TableImpl.RowState;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import com.healthmarketscience.jackcess.IndexCursor;
-import com.healthmarketscience.jackcess.util.ColumnMatcher;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.RowId;
+import com.healthmarketscience.jackcess.impl.TableImpl.RowState;
import com.healthmarketscience.jackcess.util.CaseInsensitiveColumnMatcher;
+import com.healthmarketscience.jackcess.util.ColumnMatcher;
import com.healthmarketscience.jackcess.util.SimpleColumnMatcher;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Cursor backed by an index with extended traversal options.
@@ -207,27 +208,27 @@ public class IndexCursorImpl extends CursorImpl implements IndexCursor
return currentRowMatchesEntryImpl(toRowValues(entryValues));
}
- public Iterator<Map<String,Object>> entryIterator(Object... entryValues)
+ public Iterator<Row> entryIterator(Object... entryValues)
{
return entryIterator((Collection<String>)null, entryValues);
}
- public Iterator<Map<String,Object>> entryIterator(
+ public Iterator<Row> entryIterator(
Collection<String> columnNames, Object... entryValues)
{
return new EntryIterator(columnNames, toRowValues(entryValues));
}
- public Iterable<Map<String,Object>> entryIterable(Object... entryValues)
+ public Iterable<Row> entryIterable(Object... entryValues)
{
return entryIterable((Collection<String>)null, entryValues);
}
- public Iterable<Map<String,Object>> entryIterable(
+ public Iterable<Row> entryIterable(
final Collection<String> columnNames, final Object... entryValues)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return new EntryIterator(columnNames, toRowValues(entryValues));
}
};
@@ -389,7 +390,7 @@ public class IndexCursorImpl extends CursorImpl implements IndexCursor
}
// check the next row to see if it actually matches
- Map<String,Object> row = getCurrentRow(_indexEntryPattern);
+ Row row = getCurrentRow(_indexEntryPattern);
for(IndexData.ColumnDescriptor col : getIndex().getColumns()) {
String columnName = col.getName();
diff --git a/src/java/com/healthmarketscience/jackcess/impl/RowImpl.java b/src/java/com/healthmarketscience/jackcess/impl/RowImpl.java
new file mode 100644
index 0000000..9ab06a9
--- /dev/null
+++ b/src/java/com/healthmarketscience/jackcess/impl/RowImpl.java
@@ -0,0 +1,48 @@
+/*
+Copyright (c) 2013 James Ahlborn
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+USA
+*/
+
+package com.healthmarketscience.jackcess.impl;
+
+import java.util.LinkedHashMap;
+
+import com.healthmarketscience.jackcess.Row;
+
+/**
+ * A row of data as column->value pairs.
+ *
+ * @author James Ahlborn
+ */
+public class RowImpl extends LinkedHashMap<String,Object> implements Row
+{
+ private static final long serialVersionUID = 20130314L;
+
+ public RowImpl()
+ {
+ }
+
+ public RowImpl(int expectedSize)
+ {
+ super(expectedSize);
+ }
+
+ public RowImpl(Row row)
+ {
+ super(row);
+ }
+}
diff --git a/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
index 5d7f05d..382c755 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/TableImpl.java
@@ -43,17 +43,18 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import com.healthmarketscience.jackcess.Table;
-import com.healthmarketscience.jackcess.util.ErrorHandler;
-import com.healthmarketscience.jackcess.PropertyMap;
-import com.healthmarketscience.jackcess.RowId;
-import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.ColumnBuilder;
-import com.healthmarketscience.jackcess.IndexBuilder;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.ColumnBuilder;
+import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.Index;
+import com.healthmarketscience.jackcess.IndexBuilder;
+import com.healthmarketscience.jackcess.PropertyMap;
+import com.healthmarketscience.jackcess.Row;
+import com.healthmarketscience.jackcess.RowId;
+import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.util.ErrorHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* A single database table
@@ -524,7 +525,7 @@ public class TableImpl implements Table
updateTableDefinition(-1);
}
- public Map<String, Object> getNextRow() throws IOException {
+ public Row getNextRow() throws IOException {
return getDefaultCursor().getNextRow();
}
@@ -558,7 +559,7 @@ public class TableImpl implements Table
* @param columnNames Only column names in this collection will be returned
* @usage _advanced_method_
*/
- public Map<String, Object> getRow(
+ public RowImpl getRow(
RowState rowState, RowIdImpl rowId, Collection<String> columnNames)
throws IOException
{
@@ -575,16 +576,15 @@ public class TableImpl implements Table
* Reads the row data from the given row buffer. Leaves limit unchanged.
* Saves parsed row values to the given rowState.
*/
- private static Map<String, Object> getRow(
- JetFormat format,
+ private static RowImpl getRow(
+ JetFormat format,
RowState rowState,
ByteBuffer rowBuffer,
Collection<ColumnImpl> columns,
Collection<String> columnNames)
throws IOException
{
- Map<String, Object> rtn = new LinkedHashMap<String, Object>(
- columns.size());
+ RowImpl rtn = new RowImpl(columns.size());
for(ColumnImpl column : columns) {
if((columnNames == null) || (columnNames.contains(column.getName()))) {
@@ -876,7 +876,7 @@ public class TableImpl implements Table
* operations, the actual exception will be contained within
* @usage _general_method_
*/
- public Iterator<Map<String, Object>> iterator()
+ public Iterator<Row> iterator()
{
reset();
return getDefaultCursor().iterator();
@@ -1870,7 +1870,7 @@ public class TableImpl implements Table
}
}
rtn.append("\n");
- Map<String, Object> row;
+ Row row;
int rowCount = 0;
while ((rowCount++ < limit) && (row = getNextRow()) != null) {
for(Iterator<Object> iter = row.values().iterator(); iter.hasNext(); ) {
diff --git a/src/java/com/healthmarketscience/jackcess/query/Query.java b/src/java/com/healthmarketscience/jackcess/query/Query.java
index 15189b3..4fb562c 100644
--- a/src/java/com/healthmarketscience/jackcess/query/Query.java
+++ b/src/java/com/healthmarketscience/jackcess/query/Query.java
@@ -30,7 +30,6 @@ package com.healthmarketscience.jackcess.query;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -39,6 +38,7 @@ import java.util.Map;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import com.healthmarketscience.jackcess.impl.RowImpl;
import static com.healthmarketscience.jackcess.query.QueryFormat.*;
@@ -54,8 +54,7 @@ public abstract class Query
{
protected static final Log LOG = LogFactory.getLog(Query.class);
- private static final Row EMPTY_ROW =
- new Row(Collections.<String,Object>emptyMap());
+ private static final Row EMPTY_ROW = new Row();
public enum Type
{
@@ -593,7 +592,18 @@ public abstract class Query
public final Integer objectId;
public final byte[] order;
- public Row(Map<String,Object> tableRow) {
+ private Row() {
+ this.attribute = null;
+ this.expression = null;
+ this.flag = null;
+ this.extra = null;
+ this.name1 = null;
+ this.name2= null;
+ this.objectId = null;
+ this.order = null;
+ }
+
+ public Row(com.healthmarketscience.jackcess.Row tableRow) {
this((Byte)tableRow.get(COL_ATTRIBUTE),
(String)tableRow.get(COL_EXPRESSION),
(Short)tableRow.get(COL_FLAG),
@@ -618,9 +628,9 @@ public abstract class Query
this.order = order;
}
- public Map<String,Object> toTableRow()
+ public com.healthmarketscience.jackcess.Row toTableRow()
{
- Map<String,Object> tableRow = new LinkedHashMap<String,Object>();
+ com.healthmarketscience.jackcess.Row tableRow = new RowImpl();
tableRow.put(COL_ATTRIBUTE, attribute);
tableRow.put(COL_EXPRESSION, expression);
diff --git a/src/java/com/healthmarketscience/jackcess/util/ExportUtil.java b/src/java/com/healthmarketscience/jackcess/util/ExportUtil.java
index 20949ba..81bf6da 100644
--- a/src/java/com/healthmarketscience/jackcess/util/ExportUtil.java
+++ b/src/java/com/healthmarketscience/jackcess/util/ExportUtil.java
@@ -36,13 +36,13 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.regex.Pattern;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.Cursor;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.Database;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.impl.ByteUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -339,8 +339,8 @@ public class ExportUtil {
}
// print the data rows
- Map<String, Object> row;
Object[] unfilteredRowData = new Object[columns.size()];
+ Row row;
while ((row = cursor.getNextRow(columnNames)) != null) {
// fill raw row data in array
diff --git a/src/java/com/healthmarketscience/jackcess/util/Joiner.java b/src/java/com/healthmarketscience/jackcess/util/Joiner.java
index 3b12c36..df11fd3 100644
--- a/src/java/com/healthmarketscience/jackcess/util/Joiner.java
+++ b/src/java/com/healthmarketscience/jackcess/util/Joiner.java
@@ -30,6 +30,7 @@ import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.Table;
+import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.impl.IndexImpl;
/**
@@ -147,7 +148,7 @@ public class Joiner
* @param fromRow row from the "from" table (which must include the relevant
* columns for this join relationship)
*/
- public Map<String,Object> findFirstRow(Map<String,?> fromRow)
+ public Row findFirstRow(Map<String,?> fromRow)
throws IOException
{
return findFirstRow(fromRow, null);
@@ -162,7 +163,7 @@ public class Joiner
* columns for this join relationship)
* @param columnNames desired columns in the from table row
*/
- public Map<String,Object> findFirstRow(Map<String,?> fromRow,
+ public Row findFirstRow(Map<String,?> fromRow,
Collection<String> columnNames)
throws IOException
{
@@ -176,7 +177,7 @@ public class Joiner
* @param fromRow row from the "from" table (which must include the relevant
* columns for this join relationship)
*/
- public Iterator<Map<String,Object>> findRows(Map<String,?> fromRow)
+ public Iterator<Row> findRows(Map<String,?> fromRow)
{
return findRows(fromRow, null);
}
@@ -189,7 +190,7 @@ public class Joiner
* columns for this join relationship)
* @param columnNames desired columns in the from table row
*/
- public Iterator<Map<String,Object>> findRows(Map<String,?> fromRow,
+ public Iterator<Row> findRows(Map<String,?> fromRow,
Collection<String> columnNames)
{
toEntryValues(fromRow);
@@ -205,7 +206,7 @@ public class Joiner
* @param columnNames desired columns in the from table row
* @usage _intermediate_method_
*/
- public Iterator<Map<String,Object>> findRows(Object[] fromRow,
+ public Iterator<Row> findRows(Object[] fromRow,
Collection<String> columnNames)
{
toEntryValues(fromRow);
@@ -221,7 +222,7 @@ public class Joiner
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String,Object>> findRowsIterable(Map<String,?> fromRow)
+ public Iterable<Row> findRowsIterable(Map<String,?> fromRow)
{
return findRowsIterable(fromRow, null);
}
@@ -236,11 +237,11 @@ public class Joiner
* @throws IllegalStateException if an IOException is thrown by one of the
* operations, the actual exception will be contained within
*/
- public Iterable<Map<String,Object>> findRowsIterable(
+ public Iterable<Row> findRowsIterable(
final Map<String,?> fromRow, final Collection<String> columnNames)
{
- return new Iterable<Map<String, Object>>() {
- public Iterator<Map<String, Object>> iterator() {
+ return new Iterable<Row>() {
+ public Iterator<Row> iterator() {
return findRows(fromRow, columnNames);
}
};
@@ -277,7 +278,7 @@ public class Joiner
* Deletes all the rows and returns whether or not any "to"" rows were
* deleted.
*/
- private static boolean deleteRowsImpl(Iterator<Map<String,Object>> iter)
+ private static boolean deleteRowsImpl(Iterator<Row> iter)
throws IOException
{
boolean removed = false;
diff --git a/src/java/com/healthmarketscience/jackcess/util/RowFilter.java b/src/java/com/healthmarketscience/jackcess/util/RowFilter.java
index 5a73dd8..fd13c13 100644
--- a/src/java/com/healthmarketscience/jackcess/util/RowFilter.java
+++ b/src/java/com/healthmarketscience/jackcess/util/RowFilter.java
@@ -32,6 +32,7 @@ import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import org.apache.commons.lang.ObjectUtils;
+import com.healthmarketscience.jackcess.Row;
/**
@@ -49,7 +50,7 @@ public abstract class RowFilter
* {@code false} otherwise.
* @param row current row to test for inclusion in the filter
*/
- public abstract boolean matches(Map<String, Object> row);
+ public abstract boolean matches(Row row);
/**
* Returns an iterable which filters the given iterable based on this
@@ -59,8 +60,7 @@ public abstract class RowFilter
*
* @return a filtering iterable
*/
- public Iterable<Map<String, Object>> apply(
- Iterable<Map<String, Object>> iterable)
+ public Iterable<Row> apply(Iterable<? extends Row> iterable)
{
return new FilterIterable(iterable);
}
@@ -76,13 +76,13 @@ public abstract class RowFilter
* @return a filter which matches table rows which match the values in the
* row pattern
*/
- public static RowFilter matchPattern(final Map<String, Object> rowPattern)
+ public static RowFilter matchPattern(final Map<String,?> rowPattern)
{
return new RowFilter() {
@Override
- public boolean matches(Map<String, Object> row)
+ public boolean matches(Row row)
{
- for(Map.Entry<String,Object> e : rowPattern.entrySet()) {
+ for(Map.Entry<String,?> e : rowPattern.entrySet()) {
if(!ObjectUtils.equals(e.getValue(), row.get(e.getKey()))) {
return false;
}
@@ -107,7 +107,7 @@ public abstract class RowFilter
{
return new RowFilter() {
@Override
- public boolean matches(Map<String, Object> row)
+ public boolean matches(Row row)
{
return ObjectUtils.equals(valuePattern, columnPattern.getRowValue(row));
}
@@ -127,7 +127,7 @@ public abstract class RowFilter
{
return new RowFilter() {
@Override
- public boolean matches(Map<String, Object> row)
+ public boolean matches(Row row)
{
return !filter.matches(row);
}
@@ -145,22 +145,23 @@ public abstract class RowFilter
* @return a filtering iterable (or the given iterable if a {@code null}
* filter was given)
*/
- public static Iterable<Map<String, Object>> apply(
- RowFilter rowFilter,
- Iterable<Map<String, Object>> iterable)
+ @SuppressWarnings("unchecked")
+ public static Iterable<Row> apply(RowFilter rowFilter,
+ Iterable<? extends Row> iterable)
{
- return((rowFilter != null) ? rowFilter.apply(iterable) : iterable);
+ return((rowFilter != null) ? rowFilter.apply(iterable) :
+ (Iterable<Row>)iterable);
}
/**
* Iterable which creates a filtered view of a another row iterable.
*/
- private class FilterIterable implements Iterable<Map<String, Object>>
+ private class FilterIterable implements Iterable<Row>
{
- private final Iterable<Map<String, Object>> _iterable;
+ private final Iterable<? extends Row> _iterable;
- private FilterIterable(Iterable<Map<String, Object>> iterable)
+ private FilterIterable(Iterable<? extends Row> iterable)
{
_iterable = iterable;
}
@@ -171,12 +172,11 @@ public abstract class RowFilter
* iterable, returning only rows for which the {@link RowFilter#matches}
* method returns {@code true}
*/
- public Iterator<Map<String, Object>> iterator()
+ public Iterator<Row> iterator()
{
- return new Iterator<Map<String, Object>>() {
- private final Iterator<Map<String, Object>> _iter =
- _iterable.iterator();
- private Map<String, Object> _next;
+ return new Iterator<Row>() {
+ private final Iterator<? extends Row> _iter = _iterable.iterator();
+ private Row _next;
public boolean hasNext() {
while(_iter.hasNext()) {
@@ -189,7 +189,7 @@ public abstract class RowFilter
return false;
}
- public Map<String, Object> next() {
+ public Row next() {
return _next;
}