dataRecord

Overview

This object gives access to the most recently extracted data record. This will most likely only be used in scripts that get accessed after each time an extractor pattern is applied. This object simply extends Hashtable (documentation on its methods can be found in Java's documentation).

The dataRecord is populated using the token names in the extractor patterns. You'll find a few of the most commonly used methods below. DataRecord objects can also be created from scratch, and subsequently added to DataSet objects using the addDataRecord method.

See example usage: Iterate over DataSets & DataRecords.

DataRecord

DataRecord DataRecord ( )

Description

Create a new DataRecord object.

Parameters

This method does not receive any parameters.

Return Values

Returns DataRecord object.

Change Log

Version Description
4.5 Available for all editions.

Class Location

com.screenscraper.common.DataRecord

Examples

Create New DataRecord

 // Create a new DataRecord object.
 myDataRecord = new DataRecord();

 // Populate it with a few fields.
 myDataRecord.put( "CITY", "Los Angeles" );
 myDataRecord.put( "ZIP", "90001" );
 myDataRecord.put( "STATE", "CA" );

 // Add it to an existing dataSet object.
 dataSet.addDataRecord( myDataRecord );

See additional example usage: Iterate over DataSets & DataRecords.

get

Object dataRecord.get ( Object key )

Description

Get the value of a DataRecord field.

Parameters

  • key The name of the associative key, usually a string but, if you have manually added fields, it can be an integer, etc.

Return Values

Returns the value associated with the specified key. Usually it will be a string but, if you have manually added fields, it can be an integer, boolean, long, or other object.

Change Log

Version Description
4.5 Available for all editions.

Examples

Retrieve DataRecord Information

 // Gets the value of the "CITY" field
 // and outputs it to the log.

 city = dataRecord.get( "CITY" );
 session.log( "City: " + city );

put

Object dataRecord.put ( Object key, Object value )

Description

Add a new field to the DataRecord or update the value of an existing field.

Parameters

  • key The name of the associative key, usually a string but, if you have manually added fields, it can be an integer, etc.
  • value The new value to be associated with the key.

Return Values

Returns the value previously associated with the specified key. If the key did not exist then it will return null.

Change Log

Version Description
4.5 Available for all editions.

Examples

Add/Change DataRecord Field

 // Adds a field called "CITY" with
 // the value "Los Angeles".

 dataRecord.put( "CITY", "Los Angeles" );

See additional example usage: Iterate over DataSets & DataRecords.

remove

Object dataRecord.remove ( Object key )

Description

Remove a field from the DataRecord.

Parameters

  • key The name of the associative key, usually a string but, if you have manually added fields, it can be an integer, etc.

Return Values

Returns the value previously associated with the specified key. If the key did not exist then it will return null.

Change Log

Version Description
4.5 Available for all editions.

Examples

Add/Change DataRecord Field

 // Removes the "CITY" field from the dataRecord.
 dataRecord.remove( "CITY" );