From e1511474746336064aadd2bf490a162280e1e4d0 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 23 Mar 2011 02:22:21 +0000 Subject: [PATCH] minor refactor git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@535 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/Database.java | 74 ++++++++----------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index f4bb69a..5915d2c 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -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 tableNames) - throws IOException; - public Map getObjectRow(Integer parentId, String name, Collection 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 tableNames) throws IOException { + + for(Map 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 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 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 tableNames) throws IOException { - - for(Map 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; } } -- 2.39.5