]> source.dussan.org Git - jackcess.git/commitdiff
minor refactor
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 23 Mar 2011 02:22:21 +0000 (02:22 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 23 Mar 2011 02:22:21 +0000 (02:22 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@535 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/Database.java

index f4bb69a82b3cdd741eb2921f892edaaac8a68ac7..5915d2c197db5b73b79dd4e0b0be30cfd7e9484e 100644 (file)
@@ -1886,12 +1886,6 @@ public class Database
    */
   private abstract class TableFinder
   {
-    protected abstract Cursor findRow(Integer parentId, String name)
-      throws IOException;
-
-    protected abstract Cursor findRow(Integer objectId) 
-      throws IOException;
-
     public Integer findObjectId(Integer parentId, String name) 
       throws IOException 
     {
@@ -1903,12 +1897,6 @@ public class Database
       return (Integer)cur.getCurrentRowValue(idCol);
     }
 
-    public abstract TableInfo lookupTable(String tableName)
-      throws IOException;
-    
-    public abstract void getTableNames(Set<String> tableNames) 
-      throws IOException;
-
     public Map<String,Object> getObjectRow(Integer parentId, String name,
                                            Collection<String> columns) 
       throws IOException 
@@ -1924,6 +1912,34 @@ public class Database
       Cursor cur = findRow(objectId);
       return ((cur != null) ? cur.getCurrentRow(columns) : null);
     }
+
+    public void getTableNames(Set<String> tableNames) throws IOException {
+
+      for(Map<String,Object> row : getTableNamesCursor().iterable(
+              SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
+
+        String tableName = (String)row.get(CAT_COL_NAME);
+        int flags = (Integer)row.get(CAT_COL_FLAGS);
+        Short type = (Short)row.get(CAT_COL_TYPE);
+        int parentId = (Integer)row.get(CAT_COL_PARENT_ID);
+
+        if((parentId == _tableParentId) && TYPE_TABLE.equals(type) && 
+           !isSystemObject(flags)) {
+          tableNames.add(tableName);
+        }
+      }
+    }
+
+    protected abstract Cursor findRow(Integer parentId, String name)
+      throws IOException;
+
+    protected abstract Cursor findRow(Integer objectId) 
+      throws IOException;
+
+    protected abstract Cursor getTableNamesCursor() throws IOException;
+
+    public abstract TableInfo lookupTable(String tableName)
+      throws IOException;
   }
 
   /**
@@ -1981,25 +1997,12 @@ public class Database
     }
     
     @Override
-    public void getTableNames(Set<String> tableNames) throws IOException {
-
-      IndexCursor tNameCursor = new CursorBuilder(_systemCatalog)
+    protected Cursor getTableNamesCursor() throws IOException {
+      return new CursorBuilder(_systemCatalog)
         .setIndex(_systemCatalogCursor.getIndex())
         .setStartEntry(_tableParentId, IndexData.MIN_VALUE)
         .setEndEntry(_tableParentId, IndexData.MAX_VALUE)
         .toIndexCursor();
-
-      for(Map<String,Object> row : tNameCursor.iterable(
-              SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
-
-        String tableName = (String)row.get(CAT_COL_NAME);
-        int flags = (Integer)row.get(CAT_COL_FLAGS);
-        Short type = (Short)row.get(CAT_COL_TYPE);
-
-        if(TYPE_TABLE.equals(type) && !isSystemObject(flags)) {
-          tableNames.add(tableName);
-        }
-      }
     }
   }
   
@@ -2063,21 +2066,8 @@ public class Database
     }
     
     @Override
-    public void getTableNames(Set<String> tableNames) throws IOException {
-
-      for(Map<String,Object> row : _systemCatalogCursor.iterable(
-              SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) {
-
-        String tableName = (String)row.get(CAT_COL_NAME);
-        int flags = (Integer)row.get(CAT_COL_FLAGS);
-        Short type = (Short)row.get(CAT_COL_TYPE);
-        int parentId = (Integer)row.get(CAT_COL_PARENT_ID);
-
-        if((parentId == _tableParentId) && TYPE_TABLE.equals(type) && 
-           !isSystemObject(flags)) {
-          tableNames.add(tableName);
-        }
-      }
+    protected Cursor getTableNamesCursor() throws IOException {
+      return _systemCatalogCursor;
     }
   }