conditionalprocedure
Class ResultsRecordSetHandler

java.lang.Object
  extended by com.wrq.vhi.script.api.RecordSetEventHandler
      extended by conditionalprocedure.ResultsRecordSetHandler
All Implemented Interfaces:
com.wrq.vhi.script.api.EventHandler

public class ResultsRecordSetHandler
extends com.wrq.vhi.script.api.RecordSetEventHandler

Recordset event handler which parses records and fields for a library catalog system.

This recordset event handler is called first to parse each screen into records, and then each record into fields.

Identifying the records on a screen is fairly simple, as is detailed in the parseScreen(com.wrq.vhi.script.api.ParseScreenEvent) event.

Identifying the fields within a record requires extensive pattern-matching. The parseRecord(com.wrq.vhi.script.api.ParseRecordEvent) event splits each record into fields. The job of determining whether an author name is present is handled by RSParser.isAuthor(java.lang.String).


Field Summary
private static int blankLength
           
private static int blankOffset
           
private static int bodyLength
           
private static int bodyOffset
           
static java.lang.String description
           
private static int maxTitleRows
           
private static int recordNumLength
           
private static int recordNumOffset
           
private static int rowLength
           
private static int yearLength
           
private static int yearOffset
           
 
Fields inherited from interface com.wrq.vhi.script.api.EventHandler
DEFAULT_TIMEOUT
 
Constructor Summary
ResultsRecordSetHandler()
           
 
Method Summary
 boolean isTerminated(com.wrq.vhi.script.api.IsTerminatedEvent event)
          Called to check if this is the last screen in a scroll direction.
 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
applyFilter, getCurrentHostRecord, getRecordType, insertRecord, updateRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

public static final java.lang.String description
See Also:
Constant Field Values

recordNumOffset

private static final int recordNumOffset
See Also:
Constant Field Values

recordNumLength

private static final int recordNumLength
See Also:
Constant Field Values

blankOffset

private static final int blankOffset
See Also:
Constant Field Values

blankLength

private static final int blankLength
See Also:
Constant Field Values

yearOffset

private static final int yearOffset
See Also:
Constant Field Values

yearLength

private static final int yearLength
See Also:
Constant Field Values

bodyOffset

private static final int bodyOffset
See Also:
Constant Field Values

bodyLength

private static final int bodyLength
See Also:
Constant Field Values

rowLength

private static final int rowLength
See Also:
Constant Field Values

maxTitleRows

private static final int maxTitleRows
See Also:
Constant Field Values
Constructor Detail

ResultsRecordSetHandler

public ResultsRecordSetHandler()
Method Detail

parseScreen

public java.util.List parseScreen(com.wrq.vhi.script.api.ParseScreenEvent event)
                           throws com.wrq.apptrieve.agent.ApptrieveException
Called to parse the current host screen into a set of records. The format of rows on the screen are:
  1. Each record stars with a record number.
  2. Each new screen starts with a record.
  3. No record crosses screen boundaries.
  4. A record consists of one or more lines.
  5. No records contain blank lines.

Overrides:
parseScreen in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
A list of RecordLocation objects
Throws:
com.wrq.apptrieve.agent.ApptrieveException

parseRecord

public java.util.Map parseRecord(com.wrq.vhi.script.api.ParseRecordEvent event)
                          throws com.wrq.apptrieve.agent.ApptrieveException

Called to parse a record into a set of fields.

The records have this form:

  1. A record number in the first three columns of the first line.
  2. A publishing date in column 67 on the first line.
  3. An author name may or may not appear on the first line.
  4. If no author appears, the title starting in column 6 of the first line, otherwise the title appears on column 6 of the second line.
  5. Multiple title lines may appear.

Notice that all field names present in the recordset definition must appear in the field map returned. Fields which are not present are denoted with a zero length.

The region containing the record starts at offset zero, and is considered to be a single contiguous string. This complicates the parsing task. For example, if no author appears, the title starts on the first row and continues on the second row. But between the two sections of the title the publication date appears. So while the title starts in the first row and continues on the second, a single field named "Title" is defined by a single offset and length, and would end up including the publication date. For this reason multiple title fields are defined in the recordset, and each row of the title is stored as a separate field member.

Overrides:
parseRecord in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
A map of field names to FieldLocation objects
Throws:
com.wrq.apptrieve.agent.ApptrieveException

isTerminated

public boolean isTerminated(com.wrq.vhi.script.api.IsTerminatedEvent event)
                     throws com.wrq.apptrieve.agent.ApptrieveException
Called to check if this is the last screen in a scroll direction. This event will only fire if a page up or page down operation is defined in the model. In this case scrolling down is terminated when the "Direction" attribute says that "Backward" is the only legal operation. Scrolling up is terminated when looking at the first record.

Overrides:
isTerminated in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
true if this is the last screen in the direction specified by IsTerminatedEvent.getScrollDirection()
Throws:
com.wrq.apptrieve.agent.ApptrieveException