public String[] getSQLArray() {
OrderedHashSet resolved = new OrderedHashSet();
OrderedHashSet unresolved = new OrderedHashSet();
HsqlArrayList list = new HsqlArrayList();
Iterator schemas = schemaMap.values().iterator();
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (SqlInvariants.isSystemSchemaName(schema.getName().name)) {
continue;
}
if (SqlInvariants.isLobsSchemaName(schema.getName().name)) {
continue;
}
list.add(schema.getSQL());
schema.addSimpleObjects(unresolved);
}
while (true) {
Iterator it = unresolved.iterator();
if (!it.hasNext()) {
break;
}
OrderedHashSet newResolved = new OrderedHashSet();
SchemaObjectSet.addAllSQL(resolved, unresolved, list, it,
newResolved);
unresolved.removeAll(newResolved);
if (newResolved.size() == 0) {
break;
}
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (SqlInvariants.isLobsSchemaName(schema.getName().name)) {
continue;
}
if (SqlInvariants.isSystemSchemaName(schema.getName().name)) {
continue;
}
list.addAll(schema.getSQLArray(resolved, unresolved));
}
while (true) {
Iterator it = unresolved.iterator();
if (!it.hasNext()) {
break;
}
OrderedHashSet newResolved = new OrderedHashSet();
SchemaObjectSet.addAllSQL(resolved, unresolved, list, it,
newResolved);
unresolved.removeAll(newResolved);
if (newResolved.size() == 0) {
break;
}
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
if (SqlInvariants.isLobsSchemaName(schema.getName().name)) {
continue;
}
if (SqlInvariants.isSystemSchemaName(schema.getName().name)) {
continue;
}
String[] t = schema.getTriggerSQL();
if (t.length > 0) {
list.add(Schema.getSetSchemaSQL(schema.getName()));
list.addAll(t);
}
list.addAll(schema.getSequenceRestartSQL());
}
schemas = schemaMap.values().iterator();
while (schemas.hasNext()) {
Schema schema = (Schema) schemas.next();
list.addAll(schema.getSequenceRestartSQL());
}
if (defaultSchemaHsqlName != null) {
StringBuffer sb = new StringBuffer();
sb.append(Tokens.T_SET).append(' ').append(Tokens.T_DATABASE);
sb.append(' ').append(Tokens.T_DEFAULT).append(' ');
sb.append(Tokens.T_INITIAL).append(' ').append(Tokens.T_SCHEMA);
sb.append(' ').append(defaultSchemaHsqlName.statementName);
list.add(sb.toString());
}
String[] array = new String[list.size()];
list.toArray(array);
return array;
}