public class TdbSearchSet extends TdbSessionObject implements java.lang.Iterable<TdbRecord>, com.tietoenator.trip.jxp.internal.utils.DOMSink
This class is able to enumerate the records in the search set. Records are fetched in blocks of 10 from the server as required.
The TdbSearchSet class employs a cache of configurable size that holds blocks of records recently accessed. When a record is accessed that is not available in the cache, it is fetched from the server. If the cache is full at that time, the least recently used region of records is removed and replaced with the new one.
Modifier and Type | Method and Description |
---|---|
org.w3c.dom.Document |
asFragmentSet(java.lang.String xpathExpression,
int from,
int to,
boolean hitMarkup)
Get this search set as an XML fragment set.
|
void |
cancel()
Cancel xml transaction
|
void |
clearCache()
Clears the record cache.
|
void |
delete()
Delete the current search set.
|
int |
getCacheSize()
Get the size of the record cache.
|
java.lang.String |
getDatabase()
Retrieve the name of the database or cluster that was used
with the search.
|
java.lang.String |
getDidYouMean()
Returns a "did-you-mean" suggestion for the command just executed.
|
int |
getHitCount()
The total number of hits in the search set.
|
long |
getLongHitCount()
The total number of hits in the search set.
|
long |
getLongRecordCount()
The number of records in the search set.
|
java.lang.String |
getParsedCommand()
Retrieve a constructed version of the command with fully expanded
tokens, suitable for display to an end user.
|
TdbRecord |
getRecord(int index)
Returns a TdbRecord instance for a record in the current search set.
|
TdbRecord |
getRecord(long index)
Returns a TdbRecord instance for a record in the current search set.
|
int |
getRecordCount()
The number of records in the search set.
|
TdbRecord |
getRetrievalTemplate()
Get the retrieval template for records to retrieve.
|
boolean |
getRetrieveReversed()
Get whether to retrieve the result set in reverse.
|
int |
getSearchId()
The numeric ID of the search set.
|
java.lang.String |
getSortKeys()
Get a comma-separated list of field names to use as sort criteria.
|
TdbSortMergeType |
getSortMerge()
Returns the order in which records from different databases should
be ordered when sorting a search result from a database cluster.
|
boolean |
getSortRanked()
Get whether results should be sorted by relevance.
|
java.util.Iterator<TdbRecord> |
iterator()
Returns an iterator over the records in the current search set.
|
void |
setCacheSize(int maxBlocks)
Set the size of the record cache.
|
void |
setCancelable(boolean cancelable)
Set cancelable state
|
void |
setRetrievalTemplate(TdbRecord newTemplate)
Set the retrieval template for records to retrieve.
|
void |
setRetrieveReversed(boolean reversed)
Set whether to retrieve the result set in reverse.
|
void |
setSortKeys(java.lang.String newSortKeys)
Get a comma-separated list of field names to use as sort criteria.
|
void |
setSortMerge(TdbSortMergeType mergetype)
Define the order in which records from different databases should
be ordered when sorting a search result from a database cluster.
|
void |
setSortRanked(boolean ranked)
Get whether results should be sorted by relevance.
|
getSession, isCancelable
public int getSearchId()
public int getRecordCount()
public long getLongRecordCount()
public int getHitCount()
public long getLongHitCount()
public java.lang.String getDatabase()
This property requires TRIPsystem 7.2-1 or later on the server. For older TRIPsystem versions, this property will return an empty string.
public java.lang.String getParsedCommand()
public java.lang.String getDidYouMean()
public java.lang.String getSortKeys()
public void setSortKeys(java.lang.String newSortKeys)
newSortKeys
- Sort key specificationpublic boolean getRetrieveReversed()
public void setRetrieveReversed(boolean reversed)
reversed
- True to retrieve records from the set in reverse order.public boolean getSortRanked()
public void setSortRanked(boolean ranked)
ranked
- True to sort by relevancepublic void setSortMerge(TdbSortMergeType mergetype)
mergetype
- The merge type to use for the request.public TdbSortMergeType getSortMerge()
public org.w3c.dom.Document asFragmentSet(java.lang.String xpathExpression, int from, int to, boolean hitMarkup) throws TdbException
This method can only be used when the current search set contains records from an XML database and the server to which the current session is connected runs TRIPsystem 6.2-7 or later and TRIPxml 3.0 or later.
Note that the retrieved fragments will only be those matched by the supplied XPATH expression; if this expression does not match a certain record in the current search set, no fragments (and hence no information) from that record will be retrived.
Please refer to the TRIPxml documentation for information on valid XPath syntax for TRIP.
xpathExpression
- An XPath expression that evaulates to the node set to use as fragment rootsfrom
- The lower bound of the range of records in the search set that will be covered by the fragment set. Pass -1 for no lower bound.to
- The upper bound of the range of records in the search set that will be covered by the fragment set. Pass -1 for no upper bound.hitMarkup
- Set to true to apply hit markup to the fragments.TdbException
public int getCacheSize()
public void setCacheSize(int maxBlocks) throws TdbException
maxBlocks
- The new cache size in number of blocks of 10 records.TdbException
- If the value assigned is not a positive integer.public void clearCache()
public TdbRecord getRetrievalTemplate()
This property will default to the retrieval template defined for the TdbSearch instance that provided this object. If the retrieval template is not set, either in the associated TdbSearch object, or directly on this object using the setRetrievalTemplate method, no field values will be returned for the records accessible via this object.
public void setRetrievalTemplate(TdbRecord newTemplate)
This property will default to the retrieval template defined for the TdbSearch instance that provided this object. If the retrieval template is not set, either in the associated TdbSearch object, or directly on this object using this property, no field values will be returned for the records accessible via this object.
If you wish to change the retrieval template after having retrieved some records, you must first call the clearCache method. This makes sure that the records you access after having changed the retreival template actually will be retrieved according to the new template specification.
newTemplate
- The new retrieval template to assign.public void delete() throws TdbException
After a successful call to this method, the current TdbSearchSet instance is no longer valid and must no longer be used.
TdbException
- If the delete operation failed.public TdbRecord getRecord(int index) throws TdbException
index
- The zero-based index of the record in the search set.TdbException
TdbSearchSet.getRecord(long)
public TdbRecord getRecord(long index) throws TdbException
index
- The zero-based index of the record in the search set.TdbException
public java.util.Iterator<TdbRecord> iterator()
iterator
in interface java.lang.Iterable<TdbRecord>
public void setCancelable(boolean cancelable) throws TdbException
TdbSessionObject
setCancelable
in class TdbSessionObject
cancelable
- true if object is cancelableTdbException
public void cancel() throws TdbException
TdbSessionObject
cancel
in class TdbSessionObject
TdbException