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
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)) {
int parentId = (Integer)row.get(CAT_COL_PARENT_ID);
if((parentId == _tableParentId) && TYPE_TABLE.equals(type) &&
- !isSystemObject(flags)) {
+ (isSystemObject(flags) == systemTables)) {
tableNames.add(tableName);
}
}
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
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"));
assertNull(db.getSystemTable("MSysBogus"));
+
db.close();
}
}