atg.multisite
Class SiteURLManager.SiteURLComparator

java.lang.Object
  extended by atg.multisite.SiteURLManager.SiteURLComparator
All Implemented Interfaces:
java.util.Comparator
Enclosing class:
SiteURLManager

public class SiteURLManager.SiteURLComparator
extends java.lang.Object
implements java.util.Comparator

a comparator to sort URLs using the following priority: 1. Full URLs containing domain name and path, are more specific than domain names alone, are more specific than paths alone. 2. Paths with more directory levels are considered more specific than paths with fewer directory levels 3. domain names all share the same level of specificity. A domain name with fewer name levels is not less specific than a domain name with more name levels. Example: foobar.com is the same level of specificity as example.foobar.com 4. If a URL comes in with domain name and path, and there is no match based on domain name plus path, but both domain name and path have separate matches for different sites, then domain name wins out.


Constructor Summary
SiteURLManager.SiteURLComparator()
          public constructor
 
Method Summary
 int compare(java.lang.Object p1, java.lang.Object p2)
          compare two URLs
protected  int compareLevels(java.lang.String pURL1, java.lang.String pURL2)
          compare level counts for two URLs
 boolean equals(java.lang.Object pComparator)
          see if another comparator is equal to this one
protected  java.lang.String getDomainPortion(java.lang.String pURL)
          get the domain name portion of a url
protected  int getLevelCount(java.lang.String pURL)
          get the number of levels in a URL
protected  int getPriority(java.lang.String pURL)
          get the priority of a given URL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SiteURLManager.SiteURLComparator

public SiteURLManager.SiteURLComparator()
public constructor

Method Detail

compare

public int compare(java.lang.Object p1,
                   java.lang.Object p2)
compare two URLs

Specified by:
compare in interface java.util.Comparator

compareLevels

protected int compareLevels(java.lang.String pURL1,
                            java.lang.String pURL2)
compare level counts for two URLs

Parameters:
pURL1 - the first URL
pURL2 - the second URL
Returns:
-1 if pURL1 has more levels than pURL2, 0 if pURL1 and pURL2 have the same number of levels, or 1 if pURL2 has fewer levels than pURL2

getDomainPortion

protected java.lang.String getDomainPortion(java.lang.String pURL)
get the domain name portion of a url

Parameters:
pURL - the url
Returns:
the domain name portion string

getLevelCount

protected int getLevelCount(java.lang.String pURL)
get the number of levels in a URL

Parameters:
pURL - the url to count levels in
Returns:
the number of directory levels in pURL

getPriority

protected int getPriority(java.lang.String pURL)
get the priority of a given URL

Parameters:
pURL - the url to get the int priority for
Returns:
the int priority of the URL

equals

public boolean equals(java.lang.Object pComparator)
see if another comparator is equal to this one

Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class java.lang.Object