org.apache.commons.scaffold.sql
Class ScrollerBeanBase

java.lang.Object
  extended by org.apache.commons.scaffold.util.ProcessBeanBase
      extended by org.apache.commons.scaffold.sql.StorageBeanBase
          extended by org.apache.commons.scaffold.sql.ScrollerBeanBase
All Implemented Interfaces:
ProcessBean, ScrollerBean, Storable, StorageBean

public class ScrollerBeanBase
extends StorageBeanBase
implements ScrollerBean

Base class for scrolling searches.

Version:
$Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
Author:
Ted Husted

Field Summary
 Integer scrollFrom
          The entry (or page) from which to scroll [1].
 
Fields inherited from class org.apache.commons.scaffold.sql.StorageBeanBase
commands, DELETE, DOT, INSERT, KEYS_INC, KEYS_NEXT, PARAM_SEP, PARAMS, RECYCLE, RESTORE, RETRIEVE, TABLE, UPDATE
 
Fields inherited from interface org.apache.commons.scaffold.util.ProcessBean
USER_PROFILE_KEY
 
Constructor Summary
ScrollerBeanBase()
           
 
Method Summary
 String commandKey()
          Returns the String to use to retrieve the appropriate query for this search.
 String countKey()
          Returns the String to use to retrieve the appropriate query to count the entries matching this search.
 int entryCount()
          The total number of entries in search list.
 boolean failsOnEmpty()
          Whether to branch to "failure" if list returns zero entries.
 Integer getScrollFrom()
          The relative position of the first entry in this set.
 boolean hasParameter()
          Returns whether this search takes a parameter (eg primary key) [false].
 boolean isLike()
          Returns whether this search uses the LIKE operator so that other methods know to wrap searchValue in a call to like [false].
 void listLegend(ResultList list)
          Setup the legend for the result list.
 Scroller newScroller(int entries)
          Return new scroller using the current starting point (getScrollFrom), the default limit (set.SCROLL_ROWS), and current count from Access (countCurrent).
 Collection result(Object target, Object parameter)
          Returns the collection representing the result of the Search [null].
 Object[] scrollerParams(String parameter)
          Return the array of parameters needed to select the entries for this set.
 ProcessResult scrollerSearch()
          Invoke business logic; return result.
 Integer scrollOffset()
          The number of entries before the first entry in the set (One less than scrollFrom) [0].
 int scrollRows()
          The number of entries to return [Scroller.SCROLL_ROWS].
 String searchLabel()
          Returns a label to the property being searched.
 String searchProperty()
          Returns the name of the property being matched with the searchValue.
 Object searchValue()
          Returns the value used in the search [null].
 void setScrollFrom(Integer scrollFrom)
           
 String tokenEmptyDispatch()
          Returns the dispatch token for an empty result [Tokens.FAILURE].
 String tokenEmptyMessage()
          Returns the message token for an empty result [Tokens.DATA_ACCESS_EMPTY].
 
Methods inherited from class org.apache.commons.scaffold.sql.StorageBeanBase
allocateKey, blank, blank, blankValue, collection, collectionResult, count, count, createKey, delete, delete, element, elementResult, executeUpdate, executeUpdateRoot, findByProperty, findCollection, findCollection, findCollection, findCollection, findElement, fixModified, getMarked, getModified, getParameters, getParamList, getPrefix, getResult, getResultCode, getStorageKey, init, isCurrent, isNew, like, lookup, lookupRoot, populate, recycle, recycle, restore, restore, retrieve, retrieve, setMarked, setModified, setParameters, setParamList, setPrefix, setResult, setResultCode, setStorageKey, store, store, update, updateResultCode
 
Methods inherited from class org.apache.commons.scaffold.util.ProcessBeanBase
execute, execute, getLocale, getParameter, getRemoteAddr, getRemoteNode, getRemoteServer, setLocale, setParameter, setRemoteAddr, setRemoteNode, setRemoteServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.scaffold.util.ProcessBean
execute, execute, getLocale, getParameter, getRemoteNode, getRemoteServer, setLocale, setParameter, setRemoteNode, setRemoteServer
 

Field Detail

scrollFrom

public Integer scrollFrom
The entry (or page) from which to scroll [1].

Constructor Detail

ScrollerBeanBase

public ScrollerBeanBase()
Method Detail

getScrollFrom

public Integer getScrollFrom()
Description copied from interface: ScrollerBean
The relative position of the first entry in this set.

Specified by:
getScrollFrom in interface ScrollerBean
Returns:
the position to start this set

setScrollFrom

public void setScrollFrom(Integer scrollFrom)
Specified by:
setScrollFrom in interface ScrollerBean

scrollOffset

public Integer scrollOffset()
Description copied from interface: ScrollerBean
The number of entries before the first entry in the set (One less than scrollFrom) [0].

Specified by:
scrollOffset in interface ScrollerBean
Returns:
Offset to next entry

scrollRows

public int scrollRows()
Description copied from interface: ScrollerBean
The number of entries to return [Scroller.SCROLL_ROWS].

Specified by:
scrollRows in interface ScrollerBean
Returns:
Entries per page.

countKey

public String countKey()
Description copied from interface: ScrollerBean
Returns the String to use to retrieve the appropriate query to count the entries matching this search. Must be overridden or provide functionality.

Specified by:
countKey in interface ScrollerBean
Returns:
Value of count key

hasParameter

public boolean hasParameter()
Description copied from interface: ScrollerBean
Returns whether this search takes a parameter (eg primary key) [false]. Override this method to return true and getParameter to return the required parameter.

Specified by:
hasParameter in interface ScrollerBean
Returns:
True if this search uses a parameter

searchValue

public Object searchValue()
Description copied from interface: ScrollerBean
Returns the value used in the search [null]. This can be the literal value used in the query or (if hasParameter==false) a description of what the search returns. Must be overridden or provide functionality.

Specified by:
searchValue in interface ScrollerBean
Returns:
Value of search parameter

isLike

public boolean isLike()
Description copied from interface: ScrollerBean
Returns whether this search uses the LIKE operator so that other methods know to wrap searchValue in a call to like [false].

Specified by:
isLike in interface ScrollerBean
Returns:
True if this search uses the LIKE operator

entryCount

public int entryCount()
               throws ResourceException
Description copied from interface: ScrollerBean
The total number of entries in search list. The default behavior returns a "like" search count of entries matching the searchKey. Override to provide functionality.

Specified by:
entryCount in interface ScrollerBean
Returns:
total entries
Throws:
ResourceException

commandKey

public String commandKey()
Description copied from interface: ScrollerBean
Returns the String to use to retrieve the appropriate query for this search. Must be overridden or provide functionality.

Specified by:
commandKey in interface ScrollerBean
Returns:
Value of command key

searchProperty

public String searchProperty()
Description copied from interface: ScrollerBean
Returns the name of the property being matched with the searchValue. Default method returns null. Must be overridden or provide functionality.

Specified by:
searchProperty in interface ScrollerBean
Returns:
The search property

searchLabel

public String searchLabel()
Description copied from interface: ScrollerBean
Returns a label to the property being searched. This can be the property name or a more descriptive legend. Default method returns searchProperty. Must be overridden or provide functionality.

Specified by:
searchLabel in interface ScrollerBean
Returns:
The label for the search property

failsOnEmpty

public boolean failsOnEmpty()
Description copied from interface: ScrollerBean
Whether to branch to "failure" if list returns zero entries.

Specified by:
failsOnEmpty in interface ScrollerBean

tokenEmptyMessage

public String tokenEmptyMessage()
Description copied from interface: ScrollerBean
Returns the message token for an empty result [Tokens.DATA_ACCESS_EMPTY]. May be used when isFailOnEmpty is true.

Specified by:
tokenEmptyMessage in interface ScrollerBean
Returns:
Message token for an empty result.

tokenEmptyDispatch

public String tokenEmptyDispatch()
Description copied from interface: ScrollerBean
Returns the dispatch token for an empty result [Tokens.FAILURE]. May be used when isFailOnEmpty is true.

Specified by:
tokenEmptyDispatch in interface ScrollerBean
Returns:
Message token for an empty result.

scrollerParams

public Object[] scrollerParams(String parameter)
Description copied from interface: ScrollerBean
Return the array of parameters needed to select the entries for this set.

Specified by:
scrollerParams in interface ScrollerBean
Parameters:
parameter - The additional parameter needed to select this set, if any.

result

public Collection result(Object target,
                         Object parameter)
                  throws ResourceException
Description copied from interface: ScrollerBean
Returns the collection representing the result of the Search [null]. The default behavior performs a "like" search for the parameter Override for an other search type. Subclasses may ignor parameter argument when isParameter is false.

Specified by:
result in interface ScrollerBean
Parameters:
target - Bean to use for entries
parameter - Value to use to match entries
Returns:
Collection with the result of the search
Throws:
ResourceException

newScroller

public Scroller newScroller(int entries)
                     throws ResourceException
Description copied from interface: ScrollerBean
Return new scroller using the current starting point (getScrollFrom), the default limit (set.SCROLL_ROWS), and current count from Access (countCurrent).

Specified by:
newScroller in interface ScrollerBean
Returns:
new Scroller using current and default settings.
Throws:
ResourceException - on data access error

listLegend

public void listLegend(ResultList list)
Description copied from interface: ScrollerBean
Setup the legend for the result list. Default behavior is to use the searchLabel and searchValue (if any).

Specified by:
listLegend in interface ScrollerBean

scrollerSearch

public ProcessResult scrollerSearch()
                             throws Exception
Description copied from interface: ScrollerBean
Invoke business logic; return result.

Specified by:
scrollerSearch in interface ScrollerBean
Throws:
Exception


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.