com.sas.services.information
Class Filter

com.sas.services.information.Filter
All Implemented Interfaces:
FilterInterface, java.io.Serializable
Direct Known Subclasses:
AuthorFilter, ContentSubscriberFilter, EventSubscriberFilter, GuidFilter, HttpServerFilter, IdFilter, KeywordFilter, LogicalServerFilter, MessageQueueFilter, PathFilter, PersonFilter, PhysicalTableFilter, ServerFilter, SubscriberFilter

public class Filter
implements FilterInterface, java.io.Serializable

The Filter class describes a means for setting and getting information used to limit the results of a search against a repository. While it would be nice to make it completely repository-neutral, there are concepts and mechanisms that just don't translate.

Since:
1.0
See Also:
Serialized Form

Field Summary
protected  FilterComponent _component
          The component to filter on.
 
Fields inherited from interface com.sas.services.information.FilterInterface
BASE_SCOPE, FILTERCOMPONENT_UNSUPPORTED, FLAG_OVERRIDE, ONELEVEL_SCOPE, PROTOCOL_DAV, PROTOCOL_HIBERNATE, PROTOCOL_IPOD, PROTOCOL_LDAP, PROTOCOL_OMI, SUBTREE_SCOPE
 
Constructor Summary
Filter()
          Default Constructor.
Filter(java.lang.String key, int relation, java.lang.String value)
          Construct a new Filter using the provided key, relation and value to create a component for this Filter.
 
Method Summary
 void addProtocol(java.lang.String protocol)
          Add a protocol string to the list to be searched (e.g., "omi", "dav").
 void addSearchOption(java.lang.String name, java.lang.Object option)
          Add a search option.
protected  java.lang.String component2JCRXPath(FilterComponent component)
           
protected  java.lang.String component2Select(FilterComponent component)
          For 9.3, this method is used for backwards compatibility only.
 java.lang.String getDAVBase()
          Get the DAV search base.
 java.lang.String getDAVBasicSearchString()
          Get the filter in the form of a DAV basicsearch XML request.
 int getDAVScope()
          Get the scope of the search for DAV searches.
 java.lang.String getDAVSQLString()
          Get the filter in the form of a DAV SQL request.
 java.lang.String getDAVType()
          Get the DAV type string.
 java.lang.String getExplicitSearchString()
          Get the explicit search string set by the client.
 FilterComponent getFilterComponent()
          Get the FilterComponent for this filter.
 java.lang.String getFilterString()
          Get the filter in a generic string form.
 java.lang.String getJCRType()
          Get the type string.
 java.lang.String getJCRXPathString()
          Get an XPath string to use to filter a search against a Java Content Repository.
 java.lang.String getName()
          Get the name of the object to look for.
 int getOMRFlags()
          Get the flags to add to the OMI request.
 java.lang.String getOMROption()
          Get the OMR option string.
 java.lang.String getOMRRepository()
          Get the string representing the OMR repository name or ID to perform the search in.
 java.lang.String getOMRSearchString()
          Returns the OMR specific search string for this filter.
 java.lang.String getOMRTemplate()
          Get a template string used to format the data coming back from OMR.
 java.lang.String getOMRType()
          Get the OMR type.
 java.util.List getProtocols()
          Get the List of protocols that were set to be searched.
 java.lang.String getRdbmsTable()
          Get the relational database table to search.
 java.util.Map getSearchOptions()
          Get the Map of search options for this Filter.
 java.lang.String getType()
          Get the type of object to search for.
 java.lang.String getXMLSelectString()
          Get the filter in the form of an XMLSelect statement.
 java.lang.String getXPathString()
          Deprecated. in favor of getXMLSelect().
 void removeProtocol(java.lang.String protocol)
          Remove a protocol from the list.
 void removeSearchOption(java.lang.String name)
          Remove the named search option.
 void setDAVBase(java.lang.String base)
          Set the DAV search base.
 void setDAVScope(int scope)
          Set the DAV search scope.
 void setExplicitSearchString(java.lang.String protocol, java.lang.String searchString)
          If the client knows exactly the search string they want to use, they may set it here.
 void setFilterComponent(FilterComponent component)
          Set the component to use with this filter.
 void setName(java.lang.String name)
          Set the name of the object to search for.
 void setOMRFlags(int flags)
          Set flags on the OMI request sent to the OMR server.
 void setOMROption(java.lang.String option)
          Set the OMR option string.
 void setOMRRepository(java.lang.String reposid)
          Set the repository name or ID to perform the search in.
 void setOMRTemplate(java.lang.String template)
          Set the OMR template.
 void setProtocols(java.util.List protocols)
          Set the list of protocols to search.
 void setRdbmsTable(java.lang.String table)
          For Relational searches, set the table name to search.
 void setType(java.lang.String type)
          Set the type to search for.
 java.lang.String toString()
          Get a string representation of the filter suitable for output.
 

Field Detail

_component

protected FilterComponent _component
The component to filter on. Since components can contain components, this can still be a complex filter.

Constructor Detail

Filter

public Filter()
Default Constructor. The basic filter has no components, type, or repository-specific information, and isn't a lot of use.


Filter

public Filter(java.lang.String key,
              int relation,
              java.lang.String value)
Construct a new Filter using the provided key, relation and value to create a component for this Filter. This is an easy way to construct a new simple filter in one operation.

Parameters:
key - The key to use for comparison.
relation - The relationship between the key and value to test for. Usually FilterComponent.EQUALS.
value - The value to test for.
Method Detail

getFilterString

public java.lang.String getFilterString()
Get the filter in a generic string form.

Specified by:
getFilterString in interface FilterInterface
Returns:
A string representation of the filter.

toString

public java.lang.String toString()
Get a string representation of the filter suitable for output.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the filter.

setFilterComponent

public void setFilterComponent(FilterComponent component)
Set the component to use with this filter. The filter component has the information describing what conditions entries should meet in order to be returned. Components can be joined to form complex queries.

Specified by:
setFilterComponent in interface FilterInterface
Parameters:
component - The new component to add to this filter.

getFilterComponent

public FilterComponent getFilterComponent()
Description copied from interface: FilterInterface
Get the FilterComponent for this filter.

Specified by:
getFilterComponent in interface FilterInterface
Returns:
The FilterComponent.

setType

public void setType(java.lang.String type)
Set the type to search for.

Specified by:
setType in interface FilterInterface
Parameters:
type - The object type to search for.

getType

public java.lang.String getType()
Get the type of object to search for.

Specified by:
getType in interface FilterInterface
Returns:
The object type to search for.

getOMRType

public java.lang.String getOMRType()
Get the OMR type. Return the type by default. subclasses may override this to return a different string. This method is mostly for use by the OMIRepository class.

Specified by:
getOMRType in interface FilterInterface
Returns:
The OMR specific type to search for.

getDAVType

public java.lang.String getDAVType()
Get the DAV type string. Return the type by default. Subclasses may override this to return a different string. This method is for use by the DAVRepository class.

Specified by:
getDAVType in interface FilterInterface
Returns:
the DAV specific type to search for.

getJCRType

public java.lang.String getJCRType()
Get the type string. Return the type by default. Subclasses may override this to return a different string. This method is for use by the JCRRepository class.

Returns:
the JCR specific type to search for.

setName

public void setName(java.lang.String name)
Set the name of the object to search for.

Specified by:
setName in interface FilterInterface
Parameters:
name - The object name.

getName

public java.lang.String getName()
Get the name of the object to look for.

Specified by:
getName in interface FilterInterface
Returns:
The object name.

getOMRSearchString

public java.lang.String getOMRSearchString()
Returns the OMR specific search string for this filter. This string is identical to the the xml select statement, just minus the XMLSelect begin and end tags. This allows the search string to be plugged into either an xml select string or a template search.

Specified by:
getOMRSearchString in interface FilterInterface
Returns:
a search string to be used within an xml select statement or template search

getXMLSelectString

public java.lang.String getXMLSelectString()
Get the filter in the form of an XMLSelect statement.

Specified by:
getXMLSelectString in interface FilterInterface
Returns:
An XMLSelect string to pass to OMR.

component2Select

protected java.lang.String component2Select(FilterComponent component)
For 9.3, this method is used for backwards compatibility only. Ideally, subclasses should not override this method.


component2JCRXPath

protected java.lang.String component2JCRXPath(FilterComponent component)

getXPathString

public java.lang.String getXPathString()
Deprecated. in favor of getXMLSelect().

Get an XPath string to use to filter a search against OMR.

Specified by:
getXPathString in interface FilterInterface
Returns:
An XPath selection string.

getJCRXPathString

public java.lang.String getJCRXPathString()
Get an XPath string to use to filter a search against a Java Content Repository.

Specified by:
getJCRXPathString in interface FilterInterface
Returns:
A JSR170 XPath selection string.

getOMRTemplate

public java.lang.String getOMRTemplate()
Get a template string used to format the data coming back from OMR. This can be overridden by subclasses to return a template that may help filter results using the search mechanism in the templates.

Specified by:
getOMRTemplate in interface FilterInterface
Returns:
A data template to pass to OMR.

setOMRTemplate

public void setOMRTemplate(java.lang.String template)
Set the OMR template. The template should be of the form
   
     
     
   
 
The template will be passed to the metadata server and can control the total set of associated objects that will be returned from the query.

Specified by:
setOMRTemplate in interface FilterInterface
Parameters:
template - The template to pass to OMR to format results.

getOMROption

public java.lang.String getOMROption()
Get the OMR option string. This isn't likely to be used for now. The only options that OMR supports are the XMLSelect and templates, and they're set separately.

Specified by:
getOMROption in interface FilterInterface
Returns:
An option string to pass to OMR.

setOMROption

public void setOMROption(java.lang.String option)
Set the OMR option string.

Specified by:
setOMROption in interface FilterInterface
Parameters:
option - The string to pass to OMR as options.

setOMRFlags

public void setOMRFlags(int flags)
Set flags on the OMI request sent to the OMR server. These flags are added to the flags that are normally used, they don't replace them.

Specified by:
setOMRFlags in interface FilterInterface
Parameters:
flags - The OMI flags to add to the normal search flags.

getOMRFlags

public int getOMRFlags()
Get the flags to add to the OMI request.

Specified by:
getOMRFlags in interface FilterInterface
Returns:
The OMI flags.

getOMRRepository

public java.lang.String getOMRRepository()
Get the string representing the OMR repository name or ID to perform the search in. If this is left null, the default repository is used, if set.

Specified by:
getOMRRepository in interface FilterInterface
Returns:
The repository to search.

setOMRRepository

public void setOMRRepository(java.lang.String reposid)
Set the repository name or ID to perform the search in. If this is left unset, the default repository set in the RepositoryInterface instance will be searched.

This option is used by OMR repository instances to set the repository to search. It does not limit the search to that one repository, or even to OMR repositories. To perform a search against a single repository, get a handle to that repository through the UserContext, or use the repositiory grouping mechanism of the Information Service.

Specified by:
setOMRRepository in interface FilterInterface
Parameters:
reposid - The repository name or ID to search.

getDAVBase

public java.lang.String getDAVBase()
Get the DAV search base.

Specified by:
getDAVBase in interface FilterInterface
Returns:
The search base to use for this search. If _DAVbase is null then return an empty string

setDAVBase

public void setDAVBase(java.lang.String base)
Set the DAV search base.

Specified by:
setDAVBase in interface FilterInterface
Parameters:
base - The search base for searches represented by this filter.

setRdbmsTable

public void setRdbmsTable(java.lang.String table)
Description copied from interface: FilterInterface
For Relational searches, set the table name to search.

Specified by:
setRdbmsTable in interface FilterInterface
Parameters:
table - The relational table to search for objects.

getRdbmsTable

public java.lang.String getRdbmsTable()
Description copied from interface: FilterInterface
Get the relational database table to search.

Specified by:
getRdbmsTable in interface FilterInterface
Returns:
The relational table String.

setDAVScope

public void setDAVScope(int scope)
Set the DAV search scope.

Specified by:
setDAVScope in interface FilterInterface
Parameters:
scope - The new scope of the search.

getDAVScope

public int getDAVScope()
Get the scope of the search for DAV searches.

Specified by:
getDAVScope in interface FilterInterface
Returns:
The search scope.

getDAVBasicSearchString

public java.lang.String getDAVBasicSearchString()
Get the filter in the form of a DAV basicsearch XML request. This is described in the WebDAV SEARCH proposal.

Specified by:
getDAVBasicSearchString in interface FilterInterface
Returns:
An XML basicsearch request to pass to a DAV server.

getDAVSQLString

public java.lang.String getDAVSQLString()
Get the filter in the form of a DAV SQL request. This is aimed at the Microsoft servers - Internet Information Server, SharePoint Portal Server and Exchange server.

Specified by:
getDAVSQLString in interface FilterInterface
Returns:
An XML DAV SQL request to pass to a DAV server.

addProtocol

public void addProtocol(java.lang.String protocol)
Description copied from interface: FilterInterface
Add a protocol string to the list to be searched (e.g., "omi", "dav"). Repositories whose protocol is not in this list will not perform the search. If the protocol list is empty, it will be ignored.

Specified by:
addProtocol in interface FilterInterface
Parameters:
protocol - A protocol string to control the types of repositories to search.

removeProtocol

public void removeProtocol(java.lang.String protocol)
Description copied from interface: FilterInterface
Remove a protocol from the list.

Specified by:
removeProtocol in interface FilterInterface
Parameters:
protocol - The protocol string to remove.

setProtocols

public void setProtocols(java.util.List protocols)
Description copied from interface: FilterInterface
Set the list of protocols to search. This list controls the types of repositories that will be searched. Repository instances whose protocol does not match any in the list will ignore the search request.

Specified by:
setProtocols in interface FilterInterface
Parameters:
protocols - A List of protocol Strings (e.g., "omi", "dav").

getProtocols

public java.util.List getProtocols()
Description copied from interface: FilterInterface
Get the List of protocols that were set to be searched.

Specified by:
getProtocols in interface FilterInterface
Returns:
A List of protocol Strings.

setExplicitSearchString

public void setExplicitSearchString(java.lang.String protocol,
                                    java.lang.String searchString)
Description copied from interface: FilterInterface
If the client knows exactly the search string they want to use, they may set it here. The FilterComponents will be ignored in favor of this string. Since search strings are specific to a given repository implementation, the protocol is required.

Specified by:
setExplicitSearchString in interface FilterInterface
Parameters:
protocol - The protocol for which the search string is to be used.
searchString - The search string to be used for the search.

getExplicitSearchString

public java.lang.String getExplicitSearchString()
Description copied from interface: FilterInterface
Get the explicit search string set by the client. This overrides the filter components.

Specified by:
getExplicitSearchString in interface FilterInterface
Returns:
The search String to use.

addSearchOption

public void addSearchOption(java.lang.String name,
                            java.lang.Object option)
Description copied from interface: FilterInterface
Add a search option. Search options are generally protocol-specific, so details of what options are supported are described in the repository implementation documentation.

Specified by:
addSearchOption in interface FilterInterface
Parameters:
name - The name of the option to be added.
option - The option value. This is usually a String, but may be other object types.

removeSearchOption

public void removeSearchOption(java.lang.String name)
Description copied from interface: FilterInterface
Remove the named search option.

Specified by:
removeSearchOption in interface FilterInterface
Parameters:
name - The name of the option to remove.

getSearchOptions

public java.util.Map getSearchOptions()
Description copied from interface: FilterInterface
Get the Map of search options for this Filter.

Specified by:
getSearchOptions in interface FilterInterface
Returns:
The search options Map.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.