Enterprise Information Portal APIs

com.ibm.gcs.db.component
Class DB2Queue

java.lang.Object
  |
  +--com.ibm.gcs.db.component.DB2Pool
        |
        +--com.ibm.gcs.db.component.DB2Queue
Direct Known Subclasses:
DB2HiddenQueue, DB2PriorityQueue, DB2RevisitQueue

public class DB2Queue
extends DB2Pool

DB2Queue represents the URLs in the database which must be crawled. It represents all DB2 URL records that satisfy the SQL query

SELECT * 
     FROM urlpoolstable
     WHERE urlpoolstable.state_id=1 AND urlpoolstable.hide=0
     ORDER BY TIME
  

The method setOrderBy may be used to specify a different column for the ORDER BY clause.

The constructor creates the SQL SELECT and SQL SELECT COUNT(*) statements by calling the following methods

  1. buildSQLSelect()
  2. buildSQLCount()
These methods use getSQLPredicate() and getSQLOrderBy() to build the statements. Extending classes may override getSQLPredicate() and getSQLOrderBy() to refine the properties of the queue. For example, DB2PriorityQueue overrides getSQLPredicate and append the " AND priority=p" to the predicate. These classes also override insert(), and contains() to reflect the changes.


Fields inherited from class com.ibm.gcs.db.component.DB2Pool
debug
 
Constructor Summary
DB2Queue()
          Constructor.
 
Method Summary
 boolean contains(DB2URLContainer urlC, Transaction t)
          Checks to see if the specified URL must be crawled.
 java.lang.String getSQLCount()
          Return the SQL SELECT COUNT(*) statement.
 java.lang.String getSQLSelect()
          Return the SQL SELECT statement.
 void insert(DB2URLContainer urlC)
          Updates the state information of the java URL object to reflect a URL in this DB2Queue but does not save this information in the database.
static void main(java.lang.String[] args)
          Simple test.
 void setOrderBy(java.lang.String columnNames)
          Specify how to order the urls when selected.
 
Methods inherited from class com.ibm.gcs.db.component.DB2Pool
getURLContainers, num, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DB2Queue

public DB2Queue()
Constructor.

Sets order by column to default order and calls buildSQLSelect() and buildSQLCount() to build the SQL statements.

Method Detail

contains

public boolean contains(DB2URLContainer urlC,
                        Transaction t)
                 throws TransactionException
Checks to see if the specified URL must be crawled.

A URL must be crawled if it is in the state_id=0 and hide=0.

Overrides:
contains in class DB2Pool
Parameters:
urlC - The DB2URLContainer to check.
t - The transaction object for DB2 access.
Returns:
true if the URL container must be crawled, false otherwise.
Throws:
TransactionException - on failed SQL execution.

insert

public void insert(DB2URLContainer urlC)
Updates the state information of the java URL object to reflect a URL in this DB2Queue but does not save this information in the database. (The URL object must be saved explicitly.)

Sets state_id=1 and hide=0.

Overrides:
insert in class DB2Pool
Parameters:
urlC - The DB2URLContainer to check.

getSQLSelect

public java.lang.String getSQLSelect()
Return the SQL SELECT statement. The statement has the form:
      SELECT *
      	FROM urlcrawltable
      	WHERE state_id=1 AND hide=0
	      ORDER BY <column name>
 
Overrides:
getSQLSelect in class DB2Pool
Returns:
the SQL select statement

getSQLCount

public java.lang.String getSQLCount()
Return the SQL SELECT COUNT(*) statement. The statement has the form:
      SELECT COUNT(*) 
      	FROM urlcrawltable
      	WHERE state_id=1 AND hide=0
 
Overrides:
getSQLCount in class DB2Pool

setOrderBy

public void setOrderBy(java.lang.String columnNames)
Specify how to order the urls when selected.

Rebuilds the SQL select statement with the new ORDER BY clause.

Parameters:
columnNames - A comma separated list of column names to order the urls by.

main

public static void main(java.lang.String[] args)
Simple test.

EIP Web Crawler APIs

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.