rtn = new Region[rs.getRow()];
rs.beforeFirst();
while (rs.next())
{
Region region = null;
Index[] indexes = null;
int regionType = rs.getInt("RegionType");
for (RegionType rt : RegionType.values())
{
if (rt.ordinal() == regionType) type = rt;
}
region = new Region(rs.getInt("RegionId"), type);
indexes = IndexProvider.getIndexesForRegion(conn, region);
if (type == null) throw new IllegalArgumentException(
"Region type is null.");
for (Index index : indexes)
{
addIndex(region.getIndexes(), index);
}
rtn[i] = region;
i++;
}
return rtn;