if (tokens != null) {
final Schema schema = getSchemaByToken(tokens[0]);
if (schema != null) {
final Table table = schema.getTableByName(tokens[1]);
if (table != null) {
final Column column = table.getColumnByName(tokens[2]);
if (column != null) {
return column;
}
}
}
}
Schema schema = null;
final String[] schemaNames = getSchemaNames();
for (final String schemaName : schemaNames) {
if (schemaName == null) {
// search without schema name (some databases have only a single
// schema with no name)
schema = getSchemaByName(null);
if (schema != null) {
Column column = getColumn(schema, columnName);
if (column != null) {
return column;
}
}
} else {
// Search case-sensitive
Column col = searchColumn(schemaName, columnName, columnName);
if (col != null) {
return col;
}
}
}
final String columnNameInLowerCase = columnName.toLowerCase();
for (final String schemaName : schemaNames) {
if (schemaName != null) {
// search case-insensitive
String schameNameInLowerCase = schemaName.toLowerCase();
Column col = searchColumn(schameNameInLowerCase, columnName, columnNameInLowerCase);
if (col != null) {
return col;
}
}
}
schema = getDefaultSchema();
if (schema != null) {
Column column = getColumn(schema, columnName);
if (column != null) {
return column;
}
}