|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.wrq.vhi.script.api.RecordSetEventHandler variablerecordsets.AuthorDetailsRecordsetHandler
public class AuthorDetailsRecordsetHandler
Parse author search results for the Yale Orbis Library catalog.
Each library record contains an author name, followed by one or more titles of works by that author. A publication date may be present, using the syntax "<1989>": that is a four-digit year surrounded by angle brackets.
Some author records (denoted by an "*" as the first title character) simply redirect a search for an author's works to a different name.
The work of parsing is divided between several events:
parseScreen(com.wrq.vhi.script.api.ParseScreenEvent)
event handles dividing each screen
into a set of records, one record per title.parseRecord(com.wrq.vhi.script.api.ParseRecordEvent)
event handles binding each title
and date to the author name.getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent)
event removes records that do not
contain titles (that is, the redirect records).applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent)
event does any post-fetch filtering
required based upon the publication date.The readField
event handler
is used to remove extra blanks included in multi-line titles.
Field Summary | |
---|---|
static int |
applyFilterTimeout
Timeout in seconds for the applyFilter() event. |
static java.lang.String |
description
|
static int |
getCurrentHostRecordTimeout
Timeout in seconds for the getCurrentHostRecord() event. |
static int |
getRecordTypeTimeout
Timeout in seconds for the getRecordType() event. |
static int |
insertRecordTimeout
Timeout in seconds for the insertRecord() event. |
static int |
isTerminatedTimeout
Timeout in seconds for the isTerminated() event. |
static int |
parseRecordTimeout
Timeout in seconds for the parseRecord() event. |
static int |
parseScreenTimeout
Timeout in seconds for the parseScreen() event. |
static int |
updateRecordTimeout
Timeout in seconds for the updateRecord() event. |
Fields inherited from interface com.wrq.vhi.script.api.EventHandler |
---|
DEFAULT_TIMEOUT |
Constructor Summary | |
---|---|
AuthorDetailsRecordsetHandler()
|
Method Summary | |
---|---|
boolean |
applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent event)
Called to apply a filter to a record. |
int |
getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent event)
Called to identify the type of record. |
java.util.Map |
parseRecord(com.wrq.vhi.script.api.ParseRecordEvent event)
Called to parse a record into a set of fields. |
java.util.List |
parseScreen(com.wrq.vhi.script.api.ParseScreenEvent event)
Called to parse the current host screen into a set of records. |
Methods inherited from class com.wrq.vhi.script.api.RecordSetEventHandler |
---|
getCurrentHostRecord, insertRecord, isTerminated, updateRecord |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String description
public static final int parseScreenTimeout
public static final int parseRecordTimeout
public static final int isTerminatedTimeout
public static final int getRecordTypeTimeout
public static final int applyFilterTimeout
public static final int getCurrentHostRecordTimeout
public static final int updateRecordTimeout
public static final int insertRecordTimeout
Constructor Detail |
---|
public AuthorDetailsRecordsetHandler()
Method Detail |
---|
public java.util.List parseScreen(com.wrq.vhi.script.api.ParseScreenEvent event) throws com.wrq.apptrieve.agent.ApptrieveException
The strategy here is to define each record as starting with
the author and ending with the latest book. This means for authors
with multiple books, we just define the prior books as part of
this record and then ignore the extra data later when parsing
the fields within each record (parseRecord(com.wrq.vhi.script.api.ParseRecordEvent)
).
parseScreen
in class com.wrq.vhi.script.api.RecordSetEventHandler
event
- the event instance
RecordLocation
objects
com.wrq.apptrieve.agent.ApptrieveException
public java.util.Map parseRecord(com.wrq.vhi.script.api.ParseRecordEvent event) throws com.wrq.apptrieve.agent.ApptrieveException
Each record passed to this method begins with an author name on the first line. Following that is a set of zero or more book titles. Following each book title is a publication date with the form "<2004>".
This event handler builds a single record by locating the author's first and last names, the last book title in the record, and the publication date (if any) for the last title.
parseRecord
in class com.wrq.vhi.script.api.RecordSetEventHandler
event
- the event instance
FieldLocation
objects
com.wrq.apptrieve.agent.ApptrieveException
public int getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent event) throws com.wrq.apptrieve.agent.ApptrieveException
Records in which the title starts with an asterisk ("*") or for which the title is zero-length are excluded from the result recordset. A record containing an asterisk does not contain a book, but simply redirects searches for that author to another author record.
getRecordType
in class com.wrq.vhi.script.api.RecordSetEventHandler
event
- the event instance
GetRecordTypeEvent.NORMAL_RECORD
GetRecordTypeEvent.BLANK_RECORD
GetRecordTypeEvent.EXCLUDED_RECORD
GetRecordTypeEvent.EXCLUDED_BLANK_RECORD
com.wrq.apptrieve.agent.ApptrieveException
public boolean applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent event) throws com.wrq.apptrieve.agent.ApptrieveException
The filtering provided allows selecting records based upon comparing the publication date with a numeric literal using an "=", "<", or ">" comparison. And the field name (BookDate) must appear first. Records which satisfy the condition are included in the fetch results. Other books are not.
Notice that applying a filter requires first parsing the filter expression, and then performing the comparison on a single record. Each event handler defines its own filter syntax.
applyFilter
in class com.wrq.vhi.script.api.RecordSetEventHandler
event
- the event instance
com.wrq.apptrieve.agent.ApptrieveException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |