org.rivetlogic.scar.util
Class SearchContext

java.lang.Object
  extended by org.rivetlogic.scar.util.SearchContext
All Implemented Interfaces:
java.io.Serializable

public class SearchContext
extends java.lang.Object
implements java.io.Serializable

Holds the context required to build a search query and can return the populated query. Builds a lucene format search string from each of the supplied attributes and terms.

Author:
Rivet Logic Corporation
See Also:
Serialized Form

Field Summary
static int SEARCH_ALL
           
static int SEARCH_FILE_NAMES
           
static int SEARCH_FILE_NAMES_CONTENTS
           
static int SEARCH_SPACE_NAMES
           
protected  java.util.List<org.alfresco.service.namespace.QName> simpleSearchAdditionalAttrs
           
 
Constructor Summary
SearchContext()
           
 
Method Summary
 void addAttributeQuery(org.alfresco.service.namespace.QName qname, java.lang.String value)
          Add an additional attribute to search against
 void addFixedValueQuery(org.alfresco.service.namespace.QName qname, java.lang.String value)
          Add an additional fixed value attribute to search against
 void addRangeQuery(org.alfresco.service.namespace.QName qname, java.lang.String lower, java.lang.String upper, boolean inclusive)
          Add an additional range attribute to search against
 void addSimpleAttributeQuery(org.alfresco.service.namespace.QName qname)
          Add an additional attribute to search against for simple searches
 java.lang.String buildQuery(int minimum)
          Build the search query string based on the current search context members.
 java.lang.String getAttributeQuery(org.alfresco.service.namespace.QName qname)
           
 java.lang.String[] getCategories()
           
 java.lang.String getContentType()
           
 java.lang.String getFixedValueQuery(org.alfresco.service.namespace.QName qname)
           
 java.lang.String getFolderType()
           
 boolean getForceAndTerms()
           
 java.lang.String getLocation()
           
 java.lang.String getMimeType()
           
 int getMode()
           
 org.rivetlogic.scar.util.SearchContext.RangeProperties getRangeProperty(org.alfresco.service.namespace.QName qname)
           
 java.lang.String getText()
           
 void setCategories(java.lang.String[] categories)
           
 void setContentType(java.lang.String contentType)
           
 void setFolderType(java.lang.String folderType)
           
 void setForceAndTerms(boolean forceAndTerms)
           
 void setLocation(java.lang.String location)
           
 void setMimeType(java.lang.String mimeType)
           
 void setMode(int mode)
           
 void setSimpleSearchAdditionalAttributes(java.util.List<org.alfresco.service.namespace.QName> attrs)
          Sets the additional attribute to search against for simple searches.
 void setText(java.lang.String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simpleSearchAdditionalAttrs

protected java.util.List<org.alfresco.service.namespace.QName> simpleSearchAdditionalAttrs

SEARCH_ALL

public static final int SEARCH_ALL
See Also:
Constant Field Values

SEARCH_FILE_NAMES_CONTENTS

public static final int SEARCH_FILE_NAMES_CONTENTS
See Also:
Constant Field Values

SEARCH_FILE_NAMES

public static final int SEARCH_FILE_NAMES
See Also:
Constant Field Values

SEARCH_SPACE_NAMES

public static final int SEARCH_SPACE_NAMES
See Also:
Constant Field Values
Constructor Detail

SearchContext

public SearchContext()
Method Detail

buildQuery

public java.lang.String buildQuery(int minimum)
Build the search query string based on the current search context members.

Parameters:
minimum - smallest possible textual string used for a match. This does not effect fixed values searches (e.g. boolean and int values) or date ranges
Returns:
prepared search query string

getCategories

public java.lang.String[] getCategories()
Returns:
Returns the categories to use for the search

setCategories

public void setCategories(java.lang.String[] categories)
Parameters:
categories - The categories to set as a list of search XPATHs

getLocation

public java.lang.String getLocation()
Returns:
Returns the node XPath to search in or null for all.

setLocation

public void setLocation(java.lang.String location)
Parameters:
location - The node XPATH to search from or null for all..

getMode

public int getMode()
Returns:
Returns the mode to use during the search (see constants)

setMode

public void setMode(int mode)
Parameters:
mode - The mode to use during the search (see constants)

getText

public java.lang.String getText()
Returns:
Returns the search text string.

setText

public void setText(java.lang.String text)
Parameters:
text - The search text string.

getContentType

public java.lang.String getContentType()
Returns:
Returns the contentType.

setContentType

public void setContentType(java.lang.String contentType)
Parameters:
contentType - The content type to restrict attribute search against.

getFolderType

public java.lang.String getFolderType()
Returns:
Returns the folderType.

setFolderType

public void setFolderType(java.lang.String folderType)
Parameters:
folderType - The folder type to restrict attribute search against.

getMimeType

public java.lang.String getMimeType()
Returns:
Returns the mimeType.

setMimeType

public void setMimeType(java.lang.String mimeType)
Parameters:
mimeType - The mimeType to set.

addSimpleAttributeQuery

public void addSimpleAttributeQuery(org.alfresco.service.namespace.QName qname)
Add an additional attribute to search against for simple searches

Parameters:
qname - QName of the attribute to search against

setSimpleSearchAdditionalAttributes

public void setSimpleSearchAdditionalAttributes(java.util.List<org.alfresco.service.namespace.QName> attrs)
Sets the additional attribute to search against for simple searches.

Parameters:
attrs - The list of attributes to search against

addAttributeQuery

public void addAttributeQuery(org.alfresco.service.namespace.QName qname,
                              java.lang.String value)
Add an additional attribute to search against

Parameters:
qname - QName of the attribute to search against
value - Value of the attribute to use

getAttributeQuery

public java.lang.String getAttributeQuery(org.alfresco.service.namespace.QName qname)

addRangeQuery

public void addRangeQuery(org.alfresco.service.namespace.QName qname,
                          java.lang.String lower,
                          java.lang.String upper,
                          boolean inclusive)
Add an additional range attribute to search against

Parameters:
qname - QName of the attribute to search against
lower - Lower value for range
upper - Upper value for range
inclusive - True for inclusive within the range, false otherwise

getRangeProperty

public org.rivetlogic.scar.util.SearchContext.RangeProperties getRangeProperty(org.alfresco.service.namespace.QName qname)

addFixedValueQuery

public void addFixedValueQuery(org.alfresco.service.namespace.QName qname,
                               java.lang.String value)
Add an additional fixed value attribute to search against

Parameters:
qname - QName of the attribute to search against
value - Fixed value of the attribute to use

getFixedValueQuery

public java.lang.String getFixedValueQuery(org.alfresco.service.namespace.QName qname)

getForceAndTerms

public boolean getForceAndTerms()
Returns:
Returns if AND is forced between text terms. False (OR terms) is the default.

setForceAndTerms

public void setForceAndTerms(boolean forceAndTerms)
Parameters:
forceAndTerms - Set true to force AND between text terms. Otherwise OR is the default.


Copyright 2008, Rivet Logic Corporation.