|
Jive Forums API (5.5.20.2-oracle) Core Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Query
Encapsulates a search for content in a forum. Use the factory method forum.createQuery() to get a handle on a Query object. From there, set the properties that you're interested in searching on. For example, to search a forum for "Jive is cool", you would use the following code:
Query query = forum.createQuery(); query.setQueryString("Jive is cool"); Iterator iter = query.results(); while (iter.hasNext()) { ForumMessage message = (ForumMessage)iter.nextElement(); //print results... }
All search properties are optional. You can mix and match them depending on what kind of query you'd like to perform.
You can also use the filter methods to restrict searches to messages from a particular user, messages between a date range, or messages in a particular thread.
Instructions for those that wish to implement this interface to provide
a custom implementation appear in red. If you wish to use a custom implementation, you
must set the Jive property Query.className with the name of your Query class.
Your class must have a public constructor which accepts an array of Forum objects as
an argument.
If you are using Jive Silver/Gold and are using a custom implementation of this interface
you should also provide a custom QueryLogger implementation if your custom implementation plans
on logging search queries as the default implementation of the QueryLogger interface will only
work correctly with the default implementation of this interface. See QueryLoggerFactory
for details.
Forum.createQuery()
,
ForumFactory.createQuery()
Field Summary | |
---|---|
static int |
ASCENDING
Ascending sort (ie 3, 4, 5...). |
static int |
DATE
Sort by date |
static int |
DESCENDING
Descending sort (ie 3, 2, 1...). |
static int |
RATING
Sort by rating |
static int |
RELEVANCE
Sort by relevance |
static int |
SUBJECT
Sort by message subject |
Method Summary | |
---|---|
boolean |
equals(Query query)
Return true if the query is equal to the current query, false otherwise. |
void |
filterOnThread(ForumThread thread)
Restricts the querty results to messages posted in a specified thread. |
void |
filterOnUser(User user)
Restricts the query results to messages posted by a specified user. |
java.util.Date |
getAfterDate()
Returns the earliest date for search results. |
java.util.Date |
getBeforeDate()
Returns the latest date for search results. |
ForumThread |
getFilteredThread()
Returns the thread that query results are restricted to. |
User |
getFilteredUser()
Returns the user that query results are restricted to. |
long[] |
getForumIDs()
Returns an array of forumID's denoting the forums that will be searched within. |
long |
getID()
Retrieve the unique identifier for the query. |
int |
getObjectType()
Return the object type of the query. |
java.lang.String |
getQueryString()
Returns the query string for the Query object. |
int |
getResultByThreadCount()
Returns the total number of threads that contain query results. |
int |
getResultCount()
Returns the total number of results of the query. |
int |
getResultForumCount(Forum forum)
Returns the number of results in the search that match the given forum. |
int |
getResultForumCountByThread(Forum forum)
Returns the number of results in the search that match the given forum where search results are grouped by thread. |
java.util.Iterator |
getResultForums()
Returns an Iterator of the Forums that search results are from. |
java.util.Iterator |
getResults()
Returns the results of the query as an Iterator of QueryResult objects. |
java.util.Iterator |
getResults(int startIndex,
int numResults)
Returns the results of the Query as an Iterator of QueryResult objects. |
java.util.Iterator |
getResultsByThread()
Returns the results of the Query as an Iterator of QueryResult objects. |
java.util.Iterator |
getResultsByThread(int startIndex,
int numResults)
Returns the results of the Query as an Iterator of QueryResult objects. |
int |
getSortField()
Returns the currently selected sort field. |
int |
getSortOrder()
Returns the sort order, which will be Query.ASCENDING for ascending sorting, or Query.DESCENDING for descending sorting. |
User |
getUser()
Returns the user that is executing the search. |
java.lang.String[] |
highlightResult(QueryResult result,
java.lang.String preTag,
java.lang.String postTag)
Returns a title and summary with search words highlighted appropriate to the search query string. |
long |
logQuery(User user)
Logs the query for later statistical analysis. |
void |
logSearchClick(long searchID,
long messageID)
Logs a search result clickthrough. |
void |
setAfterDate(java.util.Date afterDate)
Sets the earliest date for search results. |
void |
setBeforeDate(java.util.Date beforeDate)
Sets the latest date for search results. |
void |
setQueryString(java.lang.String queryString)
Sets the query string for the Query object. |
void |
setSortField(int sortField)
Sets the sort field to use. |
void |
setSortOrder(int sortOrder)
Sets the sort type. |
Field Detail |
---|
static final int RELEVANCE
static final int RATING
static final int DATE
static final int SUBJECT
static final int DESCENDING
static final int ASCENDING
Method Detail |
---|
long getID()
int getObjectType()
java.lang.String getQueryString()
void setQueryString(java.lang.String queryString)
queryString
- a new query string.java.util.Date getBeforeDate()
If the "before date" has not been set, this method will return null.
void setBeforeDate(java.util.Date beforeDate)
beforeDate
- an upper date boundary for search results.java.util.Date getAfterDate()
If the "after date" has not been set, this method will return null.
void setAfterDate(java.util.Date afterDate)
afterDate
- a lower date boundary for search results.long[] getForumIDs()
User getUser()
User getFilteredUser()
void filterOnUser(User user)
getUserMessages
method for a user's
messages among all forums.
user
- a User to restrict query results to.ResultFilter
ForumThread getFilteredThread()
void filterOnThread(ForumThread thread)
thread
- the ForumThread to restrict query results to.int getSortField()
void setSortField(int sortField)
sortField
- the field that will be used for sorting.int getSortOrder()
void setSortOrder(int sortOrder)
sortOrder
- the order that results will be sorted in.int getResultCount()
java.util.Iterator getResults()
QueryResult
java.util.Iterator getResults(int startIndex, int numResults)
If startIndex or numResults does not fall within the range of results, the number of messages returned may be smaller than expected. For example, suppose a query has a total of 17 results. If startIndex is 0 and numResults is 25, only 17 results can be returned.
startIndex
- the index in the results that the iterator will start at.numResults
- the max number of results that should be returned.
QueryResult
java.util.Iterator getResultsByThread()
java.util.Iterator getResultsByThread(int startIndex, int numResults)
If startIndex or numResults does not fall within the range of results, the number of messages returned may be smaller than expected. For example, suppose a query has a total of 17 results. If startIndex is 0 and numResults is 25, only 17 results can be returned.
startIndex
- the index in the results that the iterator will start at.numResults
- the maximum number of results that should be returned.
int getResultByThreadCount()
java.util.Iterator getResultForums()
int getResultForumCount(Forum forum)
forum
-
int getResultForumCountByThread(Forum forum)
forum
-
java.lang.String[] highlightResult(QueryResult result, java.lang.String preTag, java.lang.String postTag)
getResults()
or
getResults(int, int)
.
result
- the QueryResult to highlightpreTag
- a tag to be used to mark the beginning of highlighted text eg <B%gt;postTag
- a tag to be used to mark the beginning of highlighted text eg </B%gt;
long logQuery(User user)
Note: This method is a noop in Jive Forums Lite and Professional.
user
- the user performing the query, or null if a guest is performing the search.
void logSearchClick(long searchID, long messageID)
Note: This method is a noop in Jive Forums Lite and Professional.
searchID
- the searchID of the search associated with the clickthrough.messageID
- the messageID of the search result that was clickedboolean equals(Query query)
query
- the query to compare to the current query
|
Jive Forums Project Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |