aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2015-02-13 23:40:19 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2015-02-13 23:40:19 +0000
commit339c27868eb524dda6a36092c8e7e317a0243a69 (patch)
treeda24ca822e34e60d6f0e2e905767b5f209b3e1b8 /src
parent9a7e8daa15576c6db5f7933b2c96f0e55aa6c91d (diff)
downloadjackcess-339c27868eb524dda6a36092c8e7e317a0243a69.tar.gz
jackcess-339c27868eb524dda6a36092c8e7e317a0243a69.zip
add method to simplify testing whether or not a Table is linked to a Database, feature #28
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@914 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/Database.java8
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java16
2 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/Database.java b/src/main/java/com/healthmarketscience/jackcess/Database.java
index 24d291d..808dac7 100644
--- a/src/main/java/com/healthmarketscience/jackcess/Database.java
+++ b/src/main/java/com/healthmarketscience/jackcess/Database.java
@@ -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_
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
index 2afd394..aa75896 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java
@@ -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;
}