|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openprivacy.reptile.search.SearchRequest
A SearchRequest is used to represent a new search we want to run on a SearchProvider. All search query abstraction is handled here.
All options need to be specified here before a search can be executed.
In order to execute a search provider on you just need to specify the
fields you should search on.
getFields().add( "title" );
... and then specify a string or strings to search for as the criteria.
You can then specify the boolean operator for this request with the setBooleanOperator method.
In some situations this may not be enough information necessary for a SearchProvider to excute a search. For example if you need to restrict your information to a certain peergroup or some other functionaity which is specific to a provider.
There are two solutions for this:
Either strategy is acceptable, you should just make the most appropriate decision for your situation.
Field Summary | |
static java.lang.String |
ALL
Comparison type. |
static java.lang.String |
ALT_NOT_EQUAL
Comparison type. |
static int |
BOOLEAN_AND
Boolean AND operator |
static int |
BOOLEAN_OR
Boolean OR operator |
static java.lang.String |
CUSTOM
Comparison type. |
static java.lang.String |
DISTINCT
Comparison type. |
static java.lang.String |
EQUAL
Comparison type. |
static java.lang.String |
GREATER_EQUAL
Comparison type. |
static java.lang.String |
GREATER_THAN
Comparison type. |
static java.lang.String |
IN
Comparison type. |
static java.lang.String |
JOIN
Comparison type. |
static java.lang.String |
LESS_EQUAL
Comparison type. |
static java.lang.String |
LESS_THAN
Comparison type. |
static java.lang.String |
LIKE
Comparison type. |
static int |
NO_MAXCOUNT
|
static java.lang.String |
NOT_EQUAL
Comparison type. |
static java.lang.String |
NOT_IN
Comparison type. |
Constructor Summary | |
SearchRequest()
|
Method Summary | |
void |
addCriteria(java.lang.Long criteria)
Add a criteria to this request. |
void |
addCriteria(java.lang.String criteria)
Add a criteria to this request. |
void |
addSearchField(java.lang.String field)
Add a search field. |
void |
addSortOrder(java.lang.String field)
|
void |
assertValid()
Assert that this request is valid, that it specifies a criteria, etc. |
int |
getBooleanOperator()
Get the default type of boolean operation this should support. |
java.lang.String |
getComparator()
Get the value of comparator . |
java.util.List |
getCriteria()
This represents the data you are searching for. |
org.apache.commons.collections.ExtendedProperties |
getExtendedProperties()
Allows you to specify ExtendedProperties for this SearchRequest. |
int |
getMaxCount()
Get the value of maxCount . |
java.util.List |
getSearchFields()
Get the fields that this search applies to. |
java.util.List |
getSortOrder()
Get the sort order for this SearchRequest. |
org.jdom.Element |
serialize()
Serialize this as XML suitable for using as an XML results set. |
void |
setBooleanOperator(int booleanOperator)
Set the value of booleanOperator . |
void |
setComparator(java.lang.String comparator)
Set the value of comparator . |
void |
setCriteria(java.util.List criteria)
|
void |
setMaxCount(int maxCount)
Set the value of maxCount . |
void |
setSearchFields(java.util.List searchFields)
|
void |
setSortOrder(java.util.List sortOrder)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int BOOLEAN_OR
public static final int BOOLEAN_AND
public static final java.lang.String EQUAL
public static final java.lang.String NOT_EQUAL
public static final java.lang.String ALT_NOT_EQUAL
public static final java.lang.String GREATER_THAN
public static final java.lang.String LESS_THAN
public static final java.lang.String GREATER_EQUAL
public static final java.lang.String LESS_EQUAL
public static final java.lang.String LIKE
public static final java.lang.String CUSTOM
public static final java.lang.String DISTINCT
public static final java.lang.String IN
public static final java.lang.String NOT_IN
public static final java.lang.String ALL
public static final java.lang.String JOIN
public static final int NO_MAXCOUNT
Constructor Detail |
public SearchRequest()
Method Detail |
public java.util.List getCriteria()
This represents the data you are searching for.
For example if you want to search for 'linux' you would set the query to 'linux'.
In a lot of frameworks this is called a 'term'. I wanted to avoid use of that definition because it is slightly confusing in an API.
The way your criteria are handled is up to the SearchProvider. Generally it is a good idea to tokenize before hand but it is possible to let your SearchProvider to handle tokenizing for you.
This is required. By default it is 'null'
IMPLEMENTATION NOTE: Right now this only supports Strings. in the future we might create a ComplexSearchCriteria object so that you can specify more complex queries.
public void addCriteria(java.lang.String criteria)
This is required.
public void addCriteria(java.lang.Long criteria)
This is required.
public void setCriteria(java.util.List criteria)
getCriteria()
,
addCriteria(java.lang.String)
public java.util.List getSearchFields()
public void addSearchField(java.lang.String field)
getSearchFields()
public void setSearchFields(java.util.List searchFields)
getSearchFields()
public java.util.List getSortOrder()
Get the sort order for this SearchRequest.
Basically this is a list of fields that we need to sort by.
Note that all SearchProviders do not need to support this.
public void addSortOrder(java.lang.String field)
getSortOrder()
public void setSortOrder(java.util.List sortOrder)
getSortOrder()
public int getMaxCount()
maxCount
.
This is optional, by default we use NO_MAXCOUNT
Note that all SearchProviders may not implement this. For example at the time of this writing Lucene does not support this.
public void setMaxCount(int maxCount)
maxCount
.
getMaxCount()
public org.apache.commons.collections.ExtendedProperties getExtendedProperties()
Allows you to specify ExtendedProperties for this SearchRequest. A SearchProvider implementation can support any type of named search properties what can be set here.
It is up to the SearchProvider implementation to document these correctly.
public org.jdom.Element serialize()
public void assertValid() throws java.lang.Exception
java.lang.Exception
public int getBooleanOperator()
BOOLEAN_OR
,
BOOLEAN_AND
public void setBooleanOperator(int booleanOperator)
booleanOperator
.
public java.lang.String getComparator()
comparator
.
public void setComparator(java.lang.String comparator)
comparator
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |