Class SearchInfo
- java.lang.Object
-
- org.apache.jackrabbit.webdav.search.SearchInfo
-
- All Implemented Interfaces:
SearchConstants,XmlSerializable
public class SearchInfo extends Object implements SearchConstants, XmlSerializable
SearchInfoparses the 'searchrequest' element of a SEARCH request body and performs basic validation. Both query language and the query itself can be access from the resulting object.
NOTE: The query is expected to be represented by the text contained in the Xml element specifying the query language, thus the 'basicsearch' defined by the Webdav Search Internet Draft is not supported by this implementation.Example of a valid 'searchrequest' body
<d:searchrequest xmlns:d="DAV:" dcr:="http://www.day.com/jcr/webdav/1.0" > <dcr:xpath>//sv:node[@sv:name='myapp:paragraph'][1]</dcr:xpath> </d:searchrequest>Would return the following values:getLanguageName() -> xpath getQuery() -> //sv:node[@sv:name='myapp:paragraph'][1]
-
-
Field Summary
Fields Modifier and Type Field Description static longNRESULTS_UNDEFINEDstatic longOFFSET_UNDEFINED-
Fields inherited from interface org.apache.jackrabbit.webdav.search.SearchConstants
BASICSEARCH, HEADER_DASL, NAMESPACE, QUERY_GRAMMER_SET, XML_GRAMMER, XML_QUERY_GRAMMAR, XML_QUERY_SCHEMA_DISCOVERY, XML_SEARCHREQUEST
-
-
Constructor Summary
Constructors Constructor Description SearchInfo(String language, Namespace languageNamespace, String query)Create a newSearchInfoinstance.SearchInfo(String language, Namespace languageNamespace, String query, Map<String,String> namespaces)Create a newSearchInfoinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SearchInfocreateFromXml(Element searchRequest)Create a newSearchInfofrom the specifying document retrieved from the request body.StringgetLanguageName()Returns the name of the query language to be used.NamespacegetLanguageNameSpace()Returns the namespace of the language specified with the search request element.Map<String,String>getNamespaces()Returns the namespaces that have been re-mapped by the user.longgetNumberResults()Returns the maximal number of search results that should be returned.longgetOffset()Returns the desired offset in the total result set.StringgetQuery()Return the query string.voidsetNumberResults(long nresults)Sets the maximal number of search results that should be returned.voidsetOffset(long offset)Sets the desired offset in the total result set.ElementtoXml(Document document)Return the xml representation of thisSearchInfoinstance.
-
-
-
Field Detail
-
NRESULTS_UNDEFINED
public static final long NRESULTS_UNDEFINED
- See Also:
- Constant Field Values
-
OFFSET_UNDEFINED
public static final long OFFSET_UNDEFINED
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLanguageName
public String getLanguageName()
Returns the name of the query language to be used.- Returns:
- name of the query language
-
getLanguageNameSpace
public Namespace getLanguageNameSpace()
Returns the namespace of the language specified with the search request element.- Returns:
- namespace of the requested language.
-
getQuery
public String getQuery()
Return the query string.- Returns:
- query string
-
getNamespaces
public Map<String,String> getNamespaces()
Returns the namespaces that have been re-mapped by the user.- Returns:
- map of namespace to prefix mappings. Key=prefix, value=uri.
-
getNumberResults
public long getNumberResults()
Returns the maximal number of search results that should be returned.- Returns:
- the maximal number of search results that should be returned.
-
setNumberResults
public void setNumberResults(long nresults)
Sets the maximal number of search results that should be returned.- Parameters:
nresults- The maximal number of search results
-
getOffset
public long getOffset()
Returns the desired offset in the total result set.- Returns:
- the desired offset in the total result set.
-
setOffset
public void setOffset(long offset)
Sets the desired offset in the total result set.- Parameters:
offset- The desired offset in the total result set.
-
toXml
public Element toXml(Document document)
Return the xml representation of thisSearchInfoinstance.- Specified by:
toXmlin interfaceXmlSerializable- Parameters:
document-- Returns:
- xml representation
-
createFromXml
public static SearchInfo createFromXml(Element searchRequest) throws DavException
Create a newSearchInfofrom the specifying document retrieved from the request body.- Parameters:
searchRequest-- Throws:
DavException- if the root element's name is other than 'searchrequest' or if it does not contain a single child element specifying the query language to be used.
-
-