Oracle Content Management SDK

oracle.ifs.beans
Class Selector

java.lang.Object
  |
  +--oracle.ifs.beans.Selector

public class Selector
extends java.lang.Object

The Selector class creates and executes SIMPLE searches. The search is simple because it only searches one class (no "joins" are supported).
A search is performed by constructing a Selector object, setting the search class and search selection, then calling getItems()to run the query. The search class represents a Library class type, i.e. FOLDER. The search selection takes the form of a SQL WHERE clause (without the word "WHERE"). In addition, the sort order defines the manner in which the query is sorted. Lastly, the RecursiveSearch option determines whether or not sublcasses are searched as well.
The search results will be locally cached, and a call to resetItems() is required before the query will be executed again. Calls to item attribute, sort order, selection and class methods will all clear the cache automatically.
Query results are accessed by using the JavaBeans compliant getItems() methods, or by using the openItems(), nextItems(), closeItems() methods.

Using only nextItem() to access selected objects keeps the memory footprint of the selector class low, as it does not cache any objects. When you have potentially large number of objects selected, use nextItem() style of access.

If you use getItems() or getItems(index), the Selector class starts caching the fetched objects in memory. Use this as a convenience when you are certain that the number of selected objects will be a small.

Mixing nextItem() style of access with getItems() style is to be avoided. In case of mixed style access, the Selector class falls back to getItems() mode of operation, where it starts caching all fetched results.

Note that instances of this class do not persist. If you wish to use the same selector in more than one session, consider using a SelectorObject, which can be saved.

See Also:
SelectorObject, SelectorObjectDefinition

Constructor Summary
Selector(LibrarySession session)
          Construct a Selector object.
 
Method Summary
 void closeItems()
          Closes the search after cursor based access.
 int getItemCount()
          Returns the number of items in the search results.
 LibraryObject[] getItems()
          Returns the entire search results as an array.
 LibraryObject getItems(int index)
          Returns a single search result item from the search results with an index relative the the search sort order.
 java.lang.String getSearchClassname()
          Returns the search class.
 java.lang.String getSearchSelection()
          Returns the search selection.
 SortSpecification getSortSpecification()
          Returns the Sort Specification
 boolean isRecursiveSearch()
          Returns true if recursive searching is enabled with respect to classes (i.e., true if this selector will search all subclasses of the specific class).
 LibraryObject nextItem()
          Gets the next item using an open cursor on the search.
 void openItems()
          Opens a cursor on this Search ready for reading search results.
 void resetItems()
          Clears locally stored search results.
 void setRecursiveSearch(boolean recursive)
          Enables/disables recursive searching with respect to classes.
 void setSearchClassname(java.lang.String searchClass)
          Sets the search class.
 void setSearchSelection(java.lang.String searchSelection)
          Sets the search selection.
 void setSortSpecification(SortSpecification spec)
          Sets the Sort Specification
 

Constructor Detail


Selector

public Selector(LibrarySession session)
         throws IfsException
Construct a Selector object.
Parameters:
session - the current session.
Throws:
IfsException - if operation fails.
Method Detail

getSearchClassname

public java.lang.String getSearchClassname()
                                    throws IfsException
Returns the search class.
Returns:
the search class.
Throws:
IfsException - if operation fails.

setSearchClassname

public void setSearchClassname(java.lang.String searchClass)
                        throws IfsException
Sets the search class.
Parameters:
searchClass - the search class.
Throws:
IfsException - if operation fails.

getSearchSelection

public java.lang.String getSearchSelection()
                                    throws IfsException
Returns the search selection.
Returns:
the search selection.
Throws:
IfsException - if operation fails.

setSearchSelection

public void setSearchSelection(java.lang.String searchSelection)
                        throws IfsException
Sets the search selection.
Parameters:
searchSelection - the search selection.
Throws:
IfsException - if operation fails.

isRecursiveSearch

public boolean isRecursiveSearch()
                          throws IfsException
Returns true if recursive searching is enabled with respect to classes (i.e., true if this selector will search all subclasses of the specific class).
Returns:
true is enabled.
Throws:
IfsException - if the operation fails.

setRecursiveSearch

public void setRecursiveSearch(boolean recursive)
                        throws IfsException
Enables/disables recursive searching with respect to classes. The default is set true, which means that subclasses are search as well as the specified class. Setting it to false retricts the search to the single specified class.
Parameters:
recursive - true for enabled.
Throws:
IfsException - if the operation fails.

getSortSpecification

public SortSpecification getSortSpecification()
                                       throws IfsException
Returns the Sort Specification
Returns:
the search item sort specificaion.
Throws:
IfsException - if the operation fails.

setSortSpecification

public void setSortSpecification(SortSpecification spec)
                          throws IfsException
Sets the Sort Specification
Parameters:
the - sort specification.
Throws:
IfsException - if the operation fails.

getItems

public LibraryObject[] getItems()
                         throws IfsException
Returns the entire search results as an array. If the Selector instance was used with only nextItem() style of access prior to this, then the cursor will be re-opened.
Returns:
the search results. Returns null if no items found.
Throws:
IfsException - if operation fails.

getItems

public LibraryObject getItems(int index)
                       throws IfsException,
                              java.lang.IndexOutOfBoundsException
Returns a single search result item from the search results with an index relative the the search sort order. If the Selector instance was used with only nextItem() style of access prior to this, then the cursor will be re-opened.
Parameters:
index - the index of a search result.
Returns:
a search result.
Throws:
IfsException - if operation fails.
java.lang.IndexOutOfBoundsException - if the index is greater than the number of items in the search.

getItemCount

public int getItemCount()
                 throws IfsException
Returns the number of items in the search results. If the items have already been fetched then this simply returns the size of the locally stored vector. Otherwise this gets the count from the IFS server.
Returns:
the number of items.
Throws:
IfsException - if operation fails.

openItems

public void openItems()
               throws IfsException
Opens a cursor on this Search ready for reading search results. This method is used if you expect the search to return a large number of items and you don't want to get them all at once (cursor style).
Note: You must call closeItems() to close the open cursor.
Throws:
IfsException - if the operation fails.
See Also:
closeItems()

nextItem

public LibraryObject nextItem()
                       throws IfsException
Gets the next item using an open cursor on the search.
Returns:
The Item. Throws IfsException 22000 if no more items.
Throws:
IfsException - 22000 if no more items, or other error code if the operation fails.

closeItems

public void closeItems()
                throws IfsException
Closes the search after cursor based access.
Throws:
IfsException - if the operation fails.

resetItems

public void resetItems()
                throws IfsException
Clears locally stored search results. A subsequent call to getItems() will re-fetch the search results from the server. Any calls to search class, search selection, or attribute methods will call this method internally.
Returns:
true if valid cached results were cleared.
Throws:
IfsException - if operation fails.

Oracle Content Management SDK

(c) 2002 Copyright Oracle Corporation. All rights reserved.