public class SearchContext extends Object implements Serializable
Builds a lucene format search string from each of the supplied attributes and terms. Can be serialized to and from XML format for saving and restoring of previous searches.
Modifier and Type | Field and Description |
---|---|
static int |
SEARCH_ALL
Search mode constants
|
static int |
SEARCH_FILE_NAMES |
static int |
SEARCH_FILE_NAMES_CONTENTS |
static int |
SEARCH_SPACE_NAMES |
protected List<org.alfresco.service.namespace.QName> |
simpleSearchAdditionalAttrs
any extra simple query attributes to add to the search
|
Constructor and Description |
---|
SearchContext() |
Modifier and Type | Method and Description |
---|---|
void |
addAttributeQuery(org.alfresco.service.namespace.QName qname,
String value)
Add an additional attribute to search against
|
void |
addFixedValueQuery(org.alfresco.service.namespace.QName qname,
String value)
Add an additional fixed value attribute to search against
|
void |
addRangeQuery(org.alfresco.service.namespace.QName qname,
String lower,
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
|
String |
buildQuery(int minimum)
Build the search query string based on the current search context members.
|
SearchContext |
fromXML(String xml)
Restore a SearchContext from an XML definition
|
String |
getAttributeQuery(org.alfresco.service.namespace.QName qname) |
String[] |
getCategories() |
String |
getContentType() |
String |
getFixedValueQuery(org.alfresco.service.namespace.QName qname) |
String |
getFolderType() |
boolean |
getForceAndTerms() |
String |
getLocation() |
String |
getMimeType() |
int |
getMode() |
static String |
getPathFromSpaceRef(org.alfresco.service.cmr.repository.NodeRef ref,
boolean children)
Generate a search XPATH pointing to the specified node, optionally return an XPATH
that includes the child nodes.
|
org.alfresco.web.bean.search.SearchContext.RangeProperties |
getRangeProperty(org.alfresco.service.namespace.QName qname) |
String |
getSearchText() |
String |
getText() |
void |
setCategories(String[] categories) |
void |
setContentType(String contentType) |
void |
setFolderType(String folderType) |
void |
setForceAndTerms(boolean forceAndTerms) |
void |
setLocation(String location) |
void |
setMimeType(String mimeType) |
void |
setMode(int mode) |
void |
setSimpleSearchAdditionalAttributes(List<org.alfresco.service.namespace.QName> attrs)
Sets the additional attribute to search against for simple searches.
|
void |
setText(String text) |
String |
toXML() |
public static final int SEARCH_ALL
public static final int SEARCH_FILE_NAMES_CONTENTS
public static final int SEARCH_FILE_NAMES
public static final int SEARCH_SPACE_NAMES
protected List<org.alfresco.service.namespace.QName> simpleSearchAdditionalAttrs
public String buildQuery(int minimum)
minimum
- small possible textual string used for a match
this does not effect fixed values searches (e.g. boolean, int values) or date rangespublic static String getPathFromSpaceRef(org.alfresco.service.cmr.repository.NodeRef ref, boolean children)
ref
- Of the node to generate path toochildren
- Whether to include children of the nodepublic String[] getCategories()
public void setCategories(String[] categories)
categories
- The categories to set as a list of search XPATHspublic String getLocation()
public void setLocation(String location)
location
- The node XPATH to search from or null for all..public int getMode()
public void setMode(int mode)
mode
- The mode to use during the search (see constants)public String getSearchText()
public String getText()
public void setText(String text)
text
- The search text string.public String getContentType()
public void setContentType(String contentType)
contentType
- The content type to restrict attribute search against.public String getFolderType()
public void setFolderType(String folderType)
folderType
- The folder type to restrict attribute search against.public String getMimeType()
public void setMimeType(String mimeType)
mimeType
- The mimeType to set.public void addSimpleAttributeQuery(org.alfresco.service.namespace.QName qname)
qname
- QName of the attribute to search againstpublic void setSimpleSearchAdditionalAttributes(List<org.alfresco.service.namespace.QName> attrs)
attrs
- The list of attributes to search againstpublic void addAttributeQuery(org.alfresco.service.namespace.QName qname, String value)
qname
- QName of the attribute to search againstvalue
- Value of the attribute to usepublic String getAttributeQuery(org.alfresco.service.namespace.QName qname)
public void addRangeQuery(org.alfresco.service.namespace.QName qname, String lower, String upper, boolean inclusive)
qname
- QName of the attribute to search againstlower
- Lower value for rangeupper
- Upper value for rangeinclusive
- True for inclusive within the range, false otherwisepublic org.alfresco.web.bean.search.SearchContext.RangeProperties getRangeProperty(org.alfresco.service.namespace.QName qname)
public void addFixedValueQuery(org.alfresco.service.namespace.QName qname, String value)
qname
- QName of the attribute to search againstvalue
- Fixed value of the attribute to usepublic String getFixedValueQuery(org.alfresco.service.namespace.QName qname)
public boolean getForceAndTerms()
public void setForceAndTerms(boolean forceAndTerms)
forceAndTerms
- Set true to force AND between text terms. Otherwise OR is the default.public String toXML()
CDATA
int
XPath
XPath
String
String
String
String
String
String
boolean
String
CDATA
public SearchContext fromXML(String xml)
xml
- XML format SearchContext @see #toXML()Copyright © 2005–2017 Alfresco Software. All rights reserved.