git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@570 f203690c-595d-4dc9-a70b-905162fa7fd2tags/jackcess-1.2.5
@@ -18,6 +18,10 @@ | |||
<action dev="jahlborn" type="update"> | |||
Add methods to approximate table size. | |||
</action> | |||
<action dev="jahlborn" type="update"> | |||
Add Database.getSystemTableNames to enable retrieving the list of | |||
system/hidden tables. | |||
</action> | |||
</release> | |||
<release version="1.2.4" date="2011-05-14"> | |||
<action dev="jahlborn" type="update"> |
@@ -980,12 +980,25 @@ public class Database | |||
if(_tableNames == null) { | |||
Set<String> tableNames = | |||
new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); | |||
_tableFinder.getTableNames(tableNames); | |||
_tableFinder.getTableNames(tableNames, false); | |||
_tableNames = tableNames; | |||
} | |||
return _tableNames; | |||
} | |||
/** | |||
* @return The names of all of the system tables (String). Note, in order | |||
* to read these tables, you must use {@link #getSystemTable}. | |||
* <i>Extreme care should be taken if modifying these tables | |||
* directly!</i>. | |||
*/ | |||
public Set<String> getSystemTableNames() throws IOException { | |||
Set<String> sysTableNames = | |||
new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); | |||
_tableFinder.getTableNames(sysTableNames, true); | |||
return sysTableNames; | |||
} | |||
/** | |||
* @return an unmodifiable Iterator of the user Tables in this Database. | |||
* @throws IllegalStateException if an IOException is thrown by one of the | |||
@@ -2015,8 +2028,10 @@ public class Database | |||
return ((cur != null) ? cur.getCurrentRow(columns) : null); | |||
} | |||
public void getTableNames(Set<String> tableNames) throws IOException { | |||
public void getTableNames(Set<String> tableNames, | |||
boolean systemTables) | |||
throws IOException | |||
{ | |||
for(Map<String,Object> row : getTableNamesCursor().iterable( | |||
SYSTEM_CATALOG_TABLE_NAME_COLUMNS)) { | |||
@@ -2026,7 +2041,7 @@ public class Database | |||
int parentId = (Integer)row.get(CAT_COL_PARENT_ID); | |||
if((parentId == _tableParentId) && TYPE_TABLE.equals(type) && | |||
!isSystemObject(flags)) { | |||
(isSystemObject(flags) == systemTables)) { | |||
tableNames.add(tableName); | |||
} | |||
} |
@@ -51,12 +51,12 @@ import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.TreeSet; | |||
import java.util.UUID; | |||
import junit.framework.TestCase; | |||
import static com.healthmarketscience.jackcess.Database.*; | |||
import static com.healthmarketscience.jackcess.JetFormatTest.*; | |||
import junit.framework.TestCase; | |||
/** | |||
* @author Tim McCune | |||
@@ -997,13 +997,39 @@ public class DatabaseTest extends TestCase { | |||
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) { | |||
Database db = create(fileFormat); | |||
Set<String> sysTables = new TreeSet<String>( | |||
String.CASE_INSENSITIVE_ORDER); | |||
sysTables.addAll( | |||
Arrays.asList("MSysObjects", "MSysQueries", "MSysACES", | |||
"MSysRelationships")); | |||
if (fileFormat.ordinal() < FileFormat.V2003.ordinal()) { | |||
assertNotNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); | |||
sysTables.add("MSysAccessObjects"); | |||
} else { | |||
// v2003+ template files have no "MSysAccessObjects" table | |||
assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); | |||
sysTables.addAll( | |||
Arrays.asList("MSysNavPaneGroupCategories", | |||
"MSysNavPaneGroups", "MSysNavPaneGroupToObjects", | |||
"MSysNavPaneObjectIDs", "MSysAccessStorage")); | |||
if(fileFormat.ordinal() >= FileFormat.V2007.ordinal()) { | |||
sysTables.addAll( | |||
Arrays.asList( | |||
"MSysComplexColumns", "MSysComplexType_Attachment", | |||
"MSysComplexType_Decimal", "MSysComplexType_GUID", | |||
"MSysComplexType_IEEEDouble", "MSysComplexType_IEEESingle", | |||
"MSysComplexType_Long", "MSysComplexType_Short", | |||
"MSysComplexType_Text", "MSysComplexType_UnsignedByte")); | |||
} | |||
if(fileFormat.ordinal() >= FileFormat.V2010.ordinal()) { | |||
sysTables.add("f_12D7448B56564D8AAE333BCC9B3718E5_Data"); | |||
sysTables.add("MSysResources"); | |||
} | |||
} | |||
assertEquals(sysTables, db.getSystemTableNames()); | |||
assertNotNull(db.getSystemTable("MSysObjects")); | |||
assertNotNull(db.getSystemTable("MSysQueries")); | |||
assertNotNull(db.getSystemTable("MSysACES")); | |||
@@ -1011,6 +1037,7 @@ public class DatabaseTest extends TestCase { | |||
assertNull(db.getSystemTable("MSysBogus")); | |||
db.close(); | |||
} | |||
} |