From 86fe064444bda97a769e1ce4f891978c22335445 Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 2 Nov 2001 00:57:47 +0000 Subject: [PATCH] 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 --- .../servlet/JDBCTableSiteIdentifier.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java b/projects/samskivert/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java index 50af1f7a..0de10cbd 100644 --- a/projects/samskivert/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java +++ b/projects/samskivert/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java @@ -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 // Copyright (C) 2001 Michael Bayne @@ -26,6 +26,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import javax.servlet.http.HttpServletRequest; import com.samskivert.io.PersistenceException; @@ -125,7 +126,7 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier _sites = sites; // now load up the domain mappings - query = "select domain, siteId from sites"; + query = "select domain, siteId from domains"; rs = stmt.executeQuery(query); ArrayList mappings = new ArrayList(); while (rs.next()) { @@ -136,6 +137,9 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier } _mappings = mappings; + // sort the mappings in order of specificity + Collections.sort(_mappings); + // nothing to return return null; @@ -183,6 +187,12 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier 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