Sort the domain mappings once we've loaded them; fixed a SQL bug; wrote

toString() for the mapping object.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@411 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2001-11-02 00:57:47 +00:00
parent 44d534a2c0
commit 86fe064444
@@ -1,5 +1,5 @@
// //
// $Id: JDBCTableSiteIdentifier.java,v 1.1 2001/11/01 21:34:19 mdb Exp $ // $Id: JDBCTableSiteIdentifier.java,v 1.2 2001/11/02 00:57:47 mdb Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -26,6 +26,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.samskivert.io.PersistenceException; import com.samskivert.io.PersistenceException;
@@ -125,7 +126,7 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier
_sites = sites; _sites = sites;
// now load up the domain mappings // now load up the domain mappings
query = "select domain, siteId from sites"; query = "select domain, siteId from domains";
rs = stmt.executeQuery(query); rs = stmt.executeQuery(query);
ArrayList mappings = new ArrayList(); ArrayList mappings = new ArrayList();
while (rs.next()) { while (rs.next()) {
@@ -136,6 +137,9 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier
} }
_mappings = mappings; _mappings = mappings;
// sort the mappings in order of specificity
Collections.sort(_mappings);
// nothing to return // nothing to return
return null; return null;
@@ -183,6 +187,12 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier
return -1; return -1;
} }
} }
/** Returns a string representation of this site mapping. */
public String toString ()
{
return "[" + domain + " => " + siteId + "]";
}
} }
/** The repository through which we load up site identifier /** The repository through which we load up site identifier