⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 largeselect.java

📁 torque服务器源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    }    /**     * Provide access to indicator that the total values for the number of     * records and pages are now accurate as opposed to known upper limits.     *     * @return <code>true</code> when the totals are known to have been fully     * computed.     */    public boolean getTotalsFinalized()    {        return totalsFinalized;    }    /**     * Provide a way of changing the more pages/records indicator.     *     * @param moreIndicator the indicator to use in place of the default     * ("&gt;").     */    public static void setMoreIndicator(String moreIndicator)    {        LargeSelect.moreIndicator = moreIndicator;    }    /**     * Retrieve the more pages/records indicator.     */    public static String getMoreIndicator()    {        return LargeSelect.moreIndicator;    }    /**     * Sets the multiplier that will be used to compute the memory limit when a     * constructor with no memory page limit is used - the memory limit will be     * this number multiplied by the page size.     *     * @param memoryPageLimit the maximum number of pages to be in memory     * at one time.     */    public static void setMemoryPageLimit(int memoryPageLimit)    {        LargeSelect.memoryPageLimit = memoryPageLimit;    }    /**     * Retrieves the multiplier that will be used to compute the memory limit     * when a constructor with no memory page limit is used - the memory limit     * will be this number multiplied by the page size.     */    public static int getMemoryPageLimit()    {        return LargeSelect.memoryPageLimit;    }    /**     * A convenience method that provides text showing progress through the     * selected rows on a page basis.     *     * @return progress text in the form of "1 of &gt; 5" where "&gt;" can be     * configured using <code>setMoreIndicator()</code>.     */    public String getPageProgressText()    {        StringBuffer result = new StringBuffer();        result.append(getCurrentPageNumber());        result.append(" of ");        if (!totalsFinalized)        {            result.append(moreIndicator);            result.append(" ");        }        result.append(getTotalPages());        return result.toString();    }    /**     * Provides a count of the number of rows to be displayed on the current     * page - for the last page this may be less than the configured page size.     *     * @return the number of records that are included on the current page of     * results.     */    public int getCurrentPageSize()    {        if (null == lastResults)        {            return 0;        }        return lastResults.size();    }    /**     * Provide the record number of the first row included on the current page.     *     * @return The record number of the first row of the current page.     */    public int getFirstRecordNoForPage()    {        if (getCurrentPageNumber() < 1)        {            return 0;        }        return getCurrentPageNumber() * getPageSize() - getPageSize() + 1;    }    /**     * Provide the record number of the last row included on the current page.     *     * @return the record number of the last row of the current page.     */    public int getLastRecordNoForPage()    {        if (0 == currentPageNumber)        {            return 0;        }        return (getCurrentPageNumber() - 1) * getPageSize()                + getCurrentPageSize();    }    /**     * A convenience method that provides text showing progress through the     * selected rows on a record basis.     *     * @return progress text in the form of "26 - 50 of &gt; 250" where "&gt;"     * can be configured using <code>setMoreIndicator()</code>.     */    public String getRecordProgressText()    {        StringBuffer result = new StringBuffer();        result.append(getFirstRecordNoForPage());        result.append(" - ");        result.append(getLastRecordNoForPage());        result.append(" of ");        if (!totalsFinalized)        {            result.append(moreIndicator);            result.append(" ");        }        result.append(getTotalRecords());        return result.toString();    }    /**     * Indicates if further result pages are available.     *     * @return <code>true</code> when further results are available.     */    public boolean getNextResultsAvailable()    {        if (!totalsFinalized || getCurrentPageNumber() < getTotalPages())        {            return true;        }        return false;    }    /**     * Indicates if previous results pages are available.     *     * @return <code>true</code> when previous results are available.     */    public boolean getPreviousResultsAvailable()    {        if (getCurrentPageNumber() <= 1)        {            return false;        }        return true;    }    /**     * Indicates if any results are available.     *     * @return <code>true</code> of any results are available.     */    public boolean hasResultsAvailable()    {        return getTotalRecords() > 0;    }    /**     * Clear the query result so that the query is reexecuted when the next page     * is retrieved.  You may want to invoke this method if you are returning to     * a page after performing an operation on an item in the result set.     *     * @throws TorqueException if a sleep is interrupted.     */    public synchronized void invalidateResult() throws TorqueException    {        stopQuery();        blockBegin = 0;        blockEnd = 0;        currentlyFilledTo = -1;        qds = null;        results = null;        position = 0;        totalPages = -1;        totalRecords = 0;        // todo Perhaps store the oldPageNumber and immediately restart the        // query.         // oldPageNumber = currentPageNumber;        currentPageNumber = 0;        queryCompleted = false;        totalsFinalized = false;        lastResults = null;    }    /**     * Retrieve a search parameter.  This acts as a convenient place to store     * parameters that relate to the LargeSelect to make it easy to get at them     * in order to repopulate search parameters on a form when the next page of     * results is retrieved - they in no way effect the operation of     * LargeSelect.     *     * @param name the search parameter key to retrieve.     * @return the value of the search parameter.     */    public String getSearchParam(String name)    {        return getSearchParam(name, null);    }    /**     * Retrieve a search parameter.  This acts as a convenient place to store     * parameters that relate to the LargeSelect to make it easy to get at them     * in order to repopulate search parameters on a form when the next page of     * results is retrieved - they in no way effect the operation of     * LargeSelect.     *     * @param name the search parameter key to retrieve.     * @param defaultValue the default value to return if the key is not found.     * @return the value of the search parameter.     */    public String getSearchParam(String name, String defaultValue)    {        if (null == params)        {            return defaultValue;        }        String value = (String) params.get(name);        return null == value ? defaultValue : value;    }    /**     * Set a search parameter.  If the value is <code>null</code> then the      * key will be removed from the parameters.     *     * @param name the search parameter key to set.     * @param value the value of the search parameter to store.     */    public void setSearchParam(String name, String value)    {        if (null == value)        {            removeSearchParam(name);        }        else        {            if (null != name)            {                if (null == params)                {                    params = new Hashtable();                }                params.put(name, value);            }        }    }    /**     * Remove a value from the search parameters.     *     * @param name the search parameter key to remove.     */    public void removeSearchParam(String name)    {        if (null != params)        {            params.remove(name);        }    }    /**     * Provide something useful for debugging purposes.     *      * @return some basic information about this instance of LargeSelect.     */    public String toString()    {        StringBuffer result = new StringBuffer();        result.append("LargeSelect - TotalRecords: ");        result.append(getTotalRecords());        result.append(" TotalsFinalised: ");        result.append(getTotalsFinalized());        result.append("\nParameters:");        if (null == params || params.size() == 0)        {            result.append(" No parameters have been set.");        }        else        {            Set keys = params.keySet();            for (Iterator iter = keys.iterator(); iter.hasNext();)            {                String key = (String) iter.next();                String val = (String) params.get(key);                result.append("\n ").append(key).append(": ").append(val);            }        }        return result.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -