aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2015-03-04 03:31:01 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2015-03-04 03:31:01 +0000
commitbabfdb1947d35dc0fa98bd5dc15f2330e956c1f4 (patch)
treec9cda6e16353082155f8dadb143fca500e3ea1df
parent4ffcf30a2a07d0ff79e68e40210f850110694eee (diff)
downloadjackcess-babfdb1947d35dc0fa98bd5dc15f2330e956c1f4.tar.gz
jackcess-babfdb1947d35dc0fa98bd5dc15f2330e956c1f4.zip
add some convenience methods for new TableIterableBuilder; add change notes for linked table updates
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@918 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/changes/changes.xml9
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java4
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java19
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java6
4 files changed, 32 insertions, 6 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 37b679b..78bf4ea 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -12,6 +12,15 @@
<action dev="jahlborn" type="update">
Handle input String boolean values.
</action>
+ <action dev="jahlborn" type="add" system="SourceForge2Features" issue="28">
+ Added Database.isLinkedTable method to identify if the given Table is
+ linked to the database.
+ </action>
+ <action dev="jahlborn" type="add" system="SourceForge2Features" issue="28">
+ Added TableIterableBuilder for advanced Table iteration. This allows
+ selectively including different table types when iterating the tables
+ in a Database.
+ </action>
</release>
<release version="2.0.8" date="2014-12-26">
<action dev="jahlborn" type="fix" system="SourceForge2" issue="113">
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 414b43b..bb3bfac 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -620,8 +620,8 @@ public class DatabaseImpl implements Database
return _tableFinder.isLinkedTable(table);
}
- boolean matchesLinkedTable(Table table, String linkedTableName,
- String linkedDbName) {
+ private boolean matchesLinkedTable(Table table, String linkedTableName,
+ String linkedDbName) {
return (table.getName().equalsIgnoreCase(linkedTableName) &&
(_linkedDbs != null) &&
(_linkedDbs.get(linkedDbName) == table.getDatabase()));
diff --git a/src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java b/src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java
index 0390ed0..9563ced 100644
--- a/src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java
+++ b/src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java
@@ -70,6 +70,25 @@ public class TableIterableBuilder implements Iterable<Table>
_includeLinkedTables = includeLinkedTables;
return this;
}
+
+ /**
+ * Convenience method to set the flags to include only non-linked (local)
+ * user tables.
+ */
+ public TableIterableBuilder withLocalUserTablesOnly() {
+ setIncludeNormalTables(true);
+ setIncludeSystemTables(false);
+ return setIncludeLinkedTables(false);
+ }
+
+ /**
+ * Convenience method to set the flags to include only system tables.
+ */
+ public TableIterableBuilder withSystemTablesOnly() {
+ setIncludeNormalTables(false);
+ setIncludeSystemTables(true);
+ return setIncludeLinkedTables(false);
+ }
public Iterator<Table> iterator() {
return ((DatabaseImpl)_db).iterator(this);
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index e2751cb..e8cc98c 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -1463,16 +1463,14 @@ public class DatabaseTest extends TestCase
assertTrue(tables.contains(t3));
assertFalse(tables.contains(((DatabaseImpl)db).getSystemCatalog()));
- tables = getTables(db.newIterable().setIncludeLinkedTables(false));
+ tables = getTables(db.newIterable().withLocalUserTablesOnly());
assertEquals(1, tables.size());
assertTrue(tables.contains(t1));
assertFalse(tables.contains(t2));
assertFalse(tables.contains(t3));
assertFalse(tables.contains(((DatabaseImpl)db).getSystemCatalog()));
- tables = getTables(db.newIterable().setIncludeLinkedTables(false)
- .setIncludeNormalTables(false)
- .setIncludeSystemTables(true));
+ tables = getTables(db.newIterable().withSystemTablesOnly());
assertTrue(tables.size() > 5);
assertFalse(tables.contains(t1));
assertFalse(tables.contains(t2));