public class Selector extends Object
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.
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.
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.
SelectorObject
,
SelectorObjectDefinition
Modifier and Type | Field and Description |
---|---|
protected long |
m_CursorId
Open cursor handle; used by open/next/close methods
|
protected Vector |
m_CursorItems
Vector containing items fetched by an open cursor, as LibraryObjects
|
protected int |
m_CursorPos
The last position of a cursor call
|
protected int |
m_MaxItemCount
The max number of items returned via getItems().
|
protected boolean |
m_RecursiveSearch
True if a recursive search (with respect to the specified class)
will be executed.
|
protected int |
m_ResolvedCursorPos
The last position of the resolved items cursor.
|
protected Vector |
m_ResolvedItems
Vector containing the selector results, as LibraryObjects
|
protected String |
m_SearchClass
Selector class.
|
protected String |
m_SearchSelection
Selector definition string (i.e. the SQL where clause).
|
protected LibrarySession |
m_Session
The current session
|
protected SortSpecification |
m_SortSpecification
Sort specification.
|
Constructor and Description |
---|
Selector(LibrarySession session)
Construct a Selector object.
|
Modifier and Type | Method and Description |
---|---|
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.
|
int |
getMaxItemCount()
Returns the setting of the maximum number of items that will be returned in a
getItems() invocation.
|
String |
getSearchClassname()
Returns the search class.
|
String |
getSearchSelection()
Returns the search selection.
|
protected int |
getSelectorItemCount()
Get the search item count.
|
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).
|
protected Vector |
listSelectorItems()
List the Selector items.
|
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.
|
protected void |
openSelector()
Opens a cursor on this Search ready for reading search results.
|
void |
resetItems()
Clears locally stored search results.
|
protected void |
resolveSortSpecification(LibrarySession session)
Force the SortSpecification (if specified) to be resolved and
verified.
|
void |
setMaxItemCount(int maxItemCount)
Sets the maximum number of items that will be returned in a
getItems() invocation.
|
void |
setRecursiveSearch(boolean recursive)
Enables/disables recursive searching with respect to classes.
|
void |
setSearchClassname(String searchClass)
Sets the search class.
|
void |
setSearchSelection(String searchSelection)
Sets the search selection.
|
void |
setSortSpecification(SortSpecification spec)
Sets the Sort Specification
|
LibrarySession |
verifyConnected()
Return the current LibrarySession if
the session is connected; otherwise raise
a "not connected" exception.
|
protected LibrarySession m_Session
protected SortSpecification m_SortSpecification
protected String m_SearchClass
protected String m_SearchSelection
protected boolean m_RecursiveSearch
protected int m_MaxItemCount
protected Vector m_ResolvedItems
protected Vector m_CursorItems
protected int m_CursorPos
protected int m_ResolvedCursorPos
protected long m_CursorId
public Selector(LibrarySession session) throws IfsException
session
- the current session.IfsException
- if operation fails.public String getSearchClassname() throws IfsException
IfsException
- if operation fails.public void setSearchClassname(String searchClass) throws IfsException
searchClass
- the search class.IfsException
- if operation fails.public String getSearchSelection() throws IfsException
IfsException
- if operation fails.public void setSearchSelection(String searchSelection) throws IfsException
searchSelection
- the search selection.IfsException
- if operation fails.public boolean isRecursiveSearch() throws IfsException
IfsException
- if the operation fails.public void setRecursiveSearch(boolean recursive) throws IfsException
recursive
- true for enabled.IfsException
- if the operation fails.public void setMaxItemCount(int maxItemCount) throws IfsException
maxItemCount
- maximum number of items that will
be returned from a getItems() invocationIfsException
- if the operation fails.public int getMaxItemCount() throws IfsException
IfsException
- if the operation fails.public SortSpecification getSortSpecification() throws IfsException
IfsException
- if the operation fails.public void setSortSpecification(SortSpecification spec) throws IfsException
spec
- the sort specification.IfsException
- if the operation fails.public LibraryObject[] getItems() throws IfsException
IfsException
- if operation fails.public LibraryObject getItems(int index) throws IfsException, IndexOutOfBoundsException
index
- the index of a search result.IfsException
- if operation fails.IndexOutOfBoundsException
- if the index is greater than the
number of items in the search.public int getItemCount() throws IfsException
IfsException
- if operation fails.public void openItems() throws IfsException
IfsException
- if the operation fails.closeItems()
protected void openSelector() throws IfsException
IfsException
- if the operation fails.public LibraryObject nextItem() throws IfsException
IfsException
- 22000 if no more items, or other
error code if the operation fails.public void closeItems() throws IfsException
IfsException
- if the operation fails.public void resetItems() throws IfsException
IfsException
- if operation fails.protected Vector listSelectorItems() throws IfsException
IfsException
- if the operation fails.protected int getSelectorItemCount() throws IfsException
IfsException
- if operation fails.public LibrarySession verifyConnected() throws IfsException
ConnectionException
- if not connectedIfsException
protected void resolveSortSpecification(LibrarySession session) throws IfsException
session
- the current LibrarySessionConnectionException
- if not connectedIfsException
Copyright © 2023. All rights reserved.