final int page = table.getPageField();
if (TABLE_TYPE.equals(type)) {
String sql = table.getSqlField();
// System.err.println(sql);
final CommonTree ast = (CommonTree) parseTable(sql).getTree();
if (!isCreateVirtualTable(ast)) {
final SqlJetTableDef tableDef = new SqlJetTableDef(ast, page);
if (!name.equals(tableDef.getName())) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
tableDef.setRowId(table.getRowId());
tableDefs.put(name, tableDef);
} else {
final SqlJetVirtualTableDef virtualTableDef = new SqlJetVirtualTableDef(ast, page);
if (!name.equals(virtualTableDef.getTableName())) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
virtualTableDef.setRowId(table.getRowId());
virtualTableDefs.put(name, virtualTableDef);
}
} else if (INDEX_TYPE.equals(type)) {
final String tableName = table.getTableField();
final String sql = table.getSqlField();
if (null != sql) {
// System.err.println(sql);
final CommonTree ast = (CommonTree) parseIndex(sql).getTree();
final SqlJetIndexDef indexDef = new SqlJetIndexDef(ast, page);
if (!name.equals(indexDef.getName())) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
if (!tableName.equals(indexDef.getTableName())) {
throw new SqlJetException(SqlJetErrorCode.CORRUPT);
}
indexDef.setRowId(table.getRowId());
indexDefs.put(name, indexDef);
} else {
SqlJetBaseIndexDef indexDef = new SqlJetBaseIndexDef(name, tableName, page);
indexDef.setRowId(table.getRowId());
indexDefs.put(name, indexDef);
}
} else if (VIEW_TYPE.equals(type)) {
final String viewName = table.getTableField();
final String sql = table.getSqlField();
final CommonTree ast = (CommonTree) parseView(sql).getTree();
final SqlJetViewDef viewDef = new SqlJetViewDef(sql, ast);
viewDef.setRowId(table.getRowId());
viewDefs.put(viewName, viewDef);
} else if (TRIGGER_TYPE.equals(type)) {
final String triggerName = table.getNameField();
final String sql = table.getSqlField();
final CommonTree ast = (CommonTree) parseTrigger(sql).getTree();
final SqlJetTriggerDef triggerDef = new SqlJetTriggerDef(sql, ast);
triggerDef.setRowId(table.getRowId());
triggerDefs.put(triggerName, triggerDef);
}
}