dk.netarkivet.common.utils.cdx
Class CDXReader

java.lang.Object
  extended by dk.netarkivet.common.utils.cdx.CDXReader

public class CDXReader
extends java.lang.Object

This class handles reading CDX files and finding entries in them. Furthermore it implements the possibillity to do filtering of searchresults


Field Summary
(package private) static java.lang.String SEPARATOR_REGEX
          The regular expression that defines seperation between fields.
 
Constructor Summary
CDXReader()
          Create a new CDXReader with no file.
CDXReader(java.io.File cdxFile)
          Create a new CDXReader that reads the given file.
 
Method Summary
 void addCDXFile(java.io.File cdxFile)
          Add another CDX file to those being searched.
 void addCDXRecordFilter(CDXRecordFilter cdxrecfilter)
          Add another CDXRecordFilter to the list of filters to use when searching.
 void clearCDXFiles()
          Forget about all CDX files.
 CDXRecordFilter getCDXRecordFilter(java.lang.String filtername)
          Get a specific filter by the name of the filter - if not found return null.
 java.util.Map<java.lang.String,CDXRecordFilter> getFilters()
          Get a table of all filters.
 ARCKey getKey(java.lang.String uri)
          Look up an entry in CDX files.
 void removeAllCDXRecordFilters()
          Remove all CDXRecordFilters.
 void removeCDXRecordFilter(java.lang.String filtername)
          Remove a specific filter by the name of the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR_REGEX

static final java.lang.String SEPARATOR_REGEX
The regular expression that defines seperation between fields.

See Also:
Constant Field Values
Constructor Detail

CDXReader

public CDXReader(java.io.File cdxFile)
Create a new CDXReader that reads the given file.

Parameters:
cdxFile - A CDX file to read.
Throws:
IOFailure - If the file cannot be found.

CDXReader

public CDXReader()
Create a new CDXReader with no file.

Method Detail

addCDXFile

public void addCDXFile(java.io.File cdxFile)
Add another CDX file to those being searched.

Parameters:
cdxFile - A CDX file to search.
Throws:
IOFailure - If the file cannot be found or read

clearCDXFiles

public void clearCDXFiles()
Forget about all CDX files.


addCDXRecordFilter

public void addCDXRecordFilter(CDXRecordFilter cdxrecfilter)
                        throws ArgumentNotValid
Add another CDXRecordFilter to the list of filters to use when searching.

Parameters:
cdxrecfilter - A CDXRecordFilter to use when searching.
Throws:
ArgumentNotValid - If the filter is invalid or another filter exists with the same name.

removeAllCDXRecordFilters

public void removeAllCDXRecordFilters()
Remove all CDXRecordFilters.


getFilters

public java.util.Map<java.lang.String,CDXRecordFilter> getFilters()
Get a table of all filters.

Returns:
a Hashtable with all the filters.

getCDXRecordFilter

public CDXRecordFilter getCDXRecordFilter(java.lang.String filtername)
Get a specific filter by the name of the filter - if not found return null.

Parameters:
filtername - The given filtername.
Returns:
the CDXRecordFilter

removeCDXRecordFilter

public void removeCDXRecordFilter(java.lang.String filtername)
Remove a specific filter by the name of the filter.

Parameters:
filtername - The given filtername.
Throws:
UnknownID - if there is no filter of that name.

getKey

public ARCKey getKey(java.lang.String uri)
Look up an entry in CDX files. Notice that only full match search is allowed, not prefix search.

Parameters:
uri - A URI to find in the CDX files.
Returns:
A key indicating the place where the entry can be found, or null if no such entry was found;