]> source.dussan.org Git - jackcess.git/commitdiff
add some convenience methods for new TableIterableBuilder; add change notes for linke...
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 4 Mar 2015 03:31:01 +0000 (03:31 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 4 Mar 2015 03:31:01 +0000 (03:31 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@918 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
src/main/java/com/healthmarketscience/jackcess/util/TableIterableBuilder.java
src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java

index 37b679b7b9bf1fa1d135cff97f84211cfeff4a38..78bf4ea17ad02f94f3ce1d4dc4e41ef2a7f3aade 100644 (file)
       <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">
index 414b43bb04a37e5ebc15dfcb475dd2963f1895c0..bb3bfacd5e85d777e457abd557aef3b453a53dd6 100644 (file)
@@ -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()));
index 0390ed085bbc51f88ac36569056e40c52ac2f371..9563cedc9c7ef5c6a6dee42345fe383d15cb30f6 100644 (file)
@@ -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);
index e2751cbb98e67611121d47269895eba3d2b76c02..e8cc98cfe7c3d3ce5cf40b6ab4ded78155ead75c 100644 (file)
@@ -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));