]> source.dussan.org Git - jackcess.git/commitdiff
add method to simplify testing whether or not a Table is linked to a Database, featur...
authorJames Ahlborn <jtahlborn@yahoo.com>
Fri, 13 Feb 2015 23:40:19 +0000 (23:40 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Fri, 13 Feb 2015 23:40:19 +0000 (23:40 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@914 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/Database.java
src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java

index 24d291d791498b4c69ef6fa16920c52798806182..808dac76b4cddb160130f822d74204912427987d 100644 (file)
@@ -329,6 +329,14 @@ public interface Database extends Iterable<Table>, Closeable, Flushable
    */
   public Map<String,Database> getLinkedDatabases();
 
+  
+  /**
+   * Returns {@code true} if this Database links to the given Table, {@code
+   * false} otherwise.
+   * @usage _general_method_
+   */
+  public boolean isLinkedTable(Table table) throws IOException;
+  
   /**
    * Gets currently configured TimeZone (always non-{@code null}).
    * @usage _intermediate_method_
index 2afd394f558e20baf7710c685d779d2ef10f858d..aa7589660e10a1d9aa689128078d5bd95a66a845 100644 (file)
@@ -599,6 +599,22 @@ public class DatabaseImpl implements Database
             Collections.unmodifiableMap(_linkedDbs));
   }
 
+  public boolean isLinkedTable(Table table) throws IOException {
+    
+    if((table == null) || (this == table.getDatabase())) {
+      // if the table is null or this db owns the table, not linked
+      return false;
+    }
+
+    TableInfo tableInfo = lookupTable(table.getName());
+    
+    return((tableInfo != null) &&
+           tableInfo.isLinked() &&
+           (_linkedDbs != null) &&
+           (_linkedDbs.get(((LinkedTableInfo)tableInfo).linkedDbName) ==
+            table.getDatabase()));
+  }  
+  
   public TimeZone getTimeZone() {
     return _timeZone;
   }