class RulesCanonicalizationPolicy 
    extends UriCanonicalizationPolicy
    implements HasKeyedProperties {
    private static Logger logger =
        Logger.getLogger(RulesCanonicalizationPolicy.class.getName());
    
    protected KeyedProperties kp = new KeyedProperties();
    public KeyedProperties getKeyedProperties() {
        return kp;
    }
    
    {
        setRules(getDefaultRules());
    }
    @SuppressWarnings("unchecked")
    public List<CanonicalizationRule> getRules() {
        return (List<CanonicalizationRule>) kp.get("rules");
    }
    public void setRules(List<CanonicalizationRule> rules) {
        kp.put("rules", rules);
    }
    
    /**
     * Run the passed uuri through the list of rules.
     * @param before Url to canonicalize.
     * @return Canonicalized URL.
     */
    public String canonicalize(String before) {<FILL_FUNCTION_BODY>}
    
    /**
     * A reasonable set of default rules to use, if no others are
     * provided by operator configuration.
     */
    public static List<CanonicalizationRule> getDefaultRules() {
        List<CanonicalizationRule> rules = new ArrayList<CanonicalizationRule>(6);
        rules.add(new LowercaseRule());
        rules.add(new StripUserinfoRule());
        rules.add(new StripWWWNRule());
        rules.add(new StripSessionIDs());
        rules.add(new StripSessionCFIDs());
        rules.add(new FixupQueryString());
        return rules;
    }
}

        String canonical = before;
        if (logger.isLoggable(Level.FINER)) {
            logger.finer("Canonicalizing: "+before);
        }
        for (CanonicalizationRule rule : getRules()) {
            if(rule.getEnabled()) {
                canonical = rule.canonicalize(canonical);
            }
            if (logger.isLoggable(Level.FINER)) {
                logger.finer(
                    "Rule " + rule.getClass().getName() + " "
                    + (rule.getEnabled()
                            ? canonical :" (disabled)"));
            }
        }
        return canonical;
    
<methods>public non-sealed void <init>() ,public abstract java.lang.String canonicalize(java.lang.String) <variables>