edu.ucsb.adl.middleware
Class DateRanker

java.lang.Object
  |
  +--edu.ucsb.adl.middleware.DateRanker
All Implemented Interfaces:
Ranker, XmlHandler

public final class DateRanker
extends java.lang.Object
implements Ranker, XmlHandler

Ranks query results by date. Dates are drawn from mappings to the adl:dates bucket; items lacking any such mappings are assigned a minimal rank.

Version:
$Header: /export/home/gjanee/middleware/edu/ucsb/adl/middleware/RCS/DateRanker.java,v 1.3 2004/09/05 21:48:13 gjanee Exp $

$Log: DateRanker.java,v $ Revision 1.3 2004/09/05 21:48:13 gjanee
Bug fix.

Revision 1.2 2003/06/10 04:14:51 gjanee
Almost total rewrite to conform to the new ADL bucket view and to the new Ranker interface, and to employ the new validating XML parser.

Revision 1.1 2000/03/01 05:32:27 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Method Summary
 void characters(char[] string, int start, int length)
          For use by ValidatingXmlParser only.
static edu.ucsb.adl.middleware.DateRanker createRanker(java.lang.String order)
          Creates a DateRanker.
 void endElement(int elementCode)
          For use by ValidatingXmlParser only.
static void main(java.lang.String[] args)
          Test driver.
 double rank(edu.ucsb.adl.middleware.Result result, edu.ucsb.adl.middleware.Query query)
          Ranks a query result.
 void startElement(int elementCode, java.lang.String[] attributes)
          For use by ValidatingXmlParser only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createRanker

public static edu.ucsb.adl.middleware.DateRanker createRanker(java.lang.String order)
                                                       throws InternalErrorException
Creates a DateRanker. The ranker may be invoked multiple times, but is not multithread-safe.

Parameters:
order - The order of the ranking. "ascending" ("descending") indicates that later (earlier) results have higher rank.
Returns:
A DateRanker.
Throws:
InternalErrorException - If order is invalid.

rank

public double rank(edu.ucsb.adl.middleware.Result result,
                   edu.ucsb.adl.middleware.Query query)
            throws InternalErrorException
Ranks a query result. This method is not multithread-safe.

Specified by:
rank in interface Ranker
Parameters:
result - The result.
query - Unused.
Returns:
The result's rank.
Throws:
InternalErrorException - If an error occurs parsing the report.

startElement

public void startElement(int elementCode,
                         java.lang.String[] attributes)
For use by ValidatingXmlParser only.

Specified by:
startElement in interface XmlHandler
Parameters:
elementCode - The element's code.
attributes - Element attribute values, indexed by attribute code. All of the element's declared attributes are represented in the array; attributes for which a value is specified in the document or for which there is a DTD-specified default have non-null values. The handler should reference the array for the duration of the call only, as it is reused by the parser. Also, the array may be longer than necessary.

endElement

public void endElement(int elementCode)
                throws XmlException
For use by ValidatingXmlParser only.

Specified by:
endElement in interface XmlHandler
Parameters:
elementCode - The element's code.
Throws:
XmlException - If any error occurs.

characters

public void characters(char[] string,
                       int start,
                       int length)
For use by ValidatingXmlParser only.

Specified by:
characters in interface XmlHandler
Parameters:
string - The textual content.
start - The index in string at which the textual content starts.
length - The length of the content.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        InternalErrorException
Test driver.

java.io.IOException
InternalErrorException