Class DBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>

  • All Implemented Interfaces:
    com.netscape.certsrv.dbs.IDBVirtualList<E>

    public class DBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
    extends java.lang.Object
    implements com.netscape.certsrv.dbs.IDBVirtualList<E>
    A class represents a virtual list of search results. Note that this class must be used with DS4.0.
    Version:
    $Revision$, $Date$
    Author:
    thomask, mzhao
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger logger  
    • Constructor Summary

      Constructors 
      Constructor Description
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs)
      Constructs a virtual list.
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs, java.lang.String sortKey)
      Constructs a virtual list.
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs, java.lang.String[] sortKey)
      Constructs a virtual list.
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs, java.lang.String[] sortKey, int pageSize)
      Constructs a virtual list.
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs, java.lang.String sortKey, int pageSize)
      Constructs a virtual list.
      DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry, netscape.ldap.LDAPConnection c, java.lang.String base, java.lang.String filter, java.lang.String[] attrs, java.lang.String startFrom, java.lang.String sortKey, int pageSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCurrentIndex()  
      E getElementAt​(int index)
      fetch data of a single list item Recommend to call getSize() before getElementAt() or getElements() since you'd better check if the index is out of bound first.
      int getFirstIndex()
      get the top of the buffer
      E getJumpToElementAt​(int i)
      Retrieves and jumps to element in the given position.
      boolean getPage​(int first)
      Get a page starting at "first" (although we may also fetch some preceding entries) Recommend to call getSize() before getElementAt() or getElements() since you'd better check if the index is out of bound first.
      boolean getPage​(java.lang.String text)
      Called by application to scroll the list with initial letters.
      int getSelectedIndex()
      get the virutal selected index
      int getSize()
      Retrieves the size of this virtual list.
      int getSizeAfterJumpTo()  
      int getSizeBeforeJumpTo()
      Returns current index.
      void processElements​(int startidx, int endidx, com.netscape.certsrv.dbs.IElementProcessor ep)
      This function processes elements as soon as it arrives.
      void setPageSize​(int size)
      Set the paging size of this virtual list.
      void setSortKey​(java.lang.String sortKey)
      set the sort key
      void setSortKey​(java.lang.String[] sortKeys)
      set the sort key
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        public static org.slf4j.Logger logger
    • Constructor Detail

      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs)
                      throws EBaseException
        Constructs a virtual list. Be sure to setPageSize() later if your pageSize is not the default 10 Be sure to setSortKey() before fetchs param registry the registry of attribute mappers param c the ldap connection. It has to be version 3 and upper param base the base distinguished name to search from param filter search filter specifying the search criteria param attrs list of attributes that you want returned in the search results
        Throws:
        EBaseException
      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs,
                             java.lang.String[] sortKey)
                      throws EBaseException
        Constructs a virtual list. Be sure to setPageSize() later if your pageSize is not the default 10 param registry the registry of attribute mappers param c the ldap connection. It has to be version 3 and upper param base the base distinguished name to search from param filter search filter specifying the search criteria param attrs list of attributes that you want returned in the search results param sortKey the attributes to sort by
        Throws:
        EBaseException
      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs,
                             java.lang.String sortKey)
                      throws EBaseException
        Constructs a virtual list. Be sure to setPageSize() later if your pageSize is not the default 10 param registry the registry of attribute mappers param c the ldap connection. It has to be version 3 and upper param base the base distinguished name to search from param filter search filter specifying the search criteria param attrs list of attributes that you want returned in the search results param sortKey the attribute to sort by
        Throws:
        EBaseException
      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs,
                             java.lang.String[] sortKey,
                             int pageSize)
                      throws EBaseException
        Constructs a virtual list. param registry the registry of attribute mappers param c the ldap connection. It has to be version 3 and upper param base the base distinguished name to search from param filter search filter specifying the search criteria param attrs list of attributes that you want returned in the search results param sortKey the attributes to sort by param pageSize the size of a page. There is a 3*pageSize buffer maintained so pageUp and pageDown won't invoke fetch from ldap server
        Throws:
        EBaseException
      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs,
                             java.lang.String sortKey,
                             int pageSize)
                      throws EBaseException
        Constructs a virtual list. param registry the registry of attribute mappers param c the ldap connection. It has to be version 3 and upper param base the base distinguished name to search from param filter search filter specifying the search criteria param attrs list of attributes that you want returned in the search results param sortKey the attribute to sort by param pageSize the size of a page. There is a 3*pageSize buffer maintained so pageUp and pageDown won't invoke fetch from ldap server
        Throws:
        EBaseException
      • DBVirtualList

        public DBVirtualList​(com.netscape.certsrv.dbs.IDBRegistry registry,
                             netscape.ldap.LDAPConnection c,
                             java.lang.String base,
                             java.lang.String filter,
                             java.lang.String[] attrs,
                             java.lang.String startFrom,
                             java.lang.String sortKey,
                             int pageSize)
                      throws EBaseException
        Throws:
        EBaseException
    • Method Detail

      • setPageSize

        public void setPageSize​(int size)
        Set the paging size of this virtual list. The page size here is just a buffer size. A buffer is kept around that is three times as large as the number of visible entries. That way, you can scroll up/down several items(up to a page-full) without refetching entries from the directory.
        Specified by:
        setPageSize in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        size - the page size
      • setSortKey

        public void setSortKey​(java.lang.String sortKey)
                        throws EBaseException
        set the sort key
        Specified by:
        setSortKey in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        sortKey - the attribute to sort by
        Throws:
        EBaseException - failed to set
      • setSortKey

        public void setSortKey​(java.lang.String[] sortKeys)
                        throws EBaseException
        set the sort key
        Specified by:
        setSortKey in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        sortKey - the attributes to sort by
        Throws:
        EBaseException - failed to set
      • getSize

        public int getSize()
        Retrieves the size of this virtual list. Recommend to call getSize() before getElementAt() or getElements() since you'd better check if the index is out of bound first.
        Specified by:
        getSize in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Returns:
        current size in list
      • getSizeBeforeJumpTo

        public int getSizeBeforeJumpTo()
        Description copied from interface: com.netscape.certsrv.dbs.IDBVirtualList
        Returns current index.
        Specified by:
        getSizeBeforeJumpTo in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Returns:
        current index
      • getSizeAfterJumpTo

        public int getSizeAfterJumpTo()
        Specified by:
        getSizeAfterJumpTo in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
      • getCurrentIndex

        public int getCurrentIndex()
        Specified by:
        getCurrentIndex in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
      • getPage

        public boolean getPage​(int first)
        Get a page starting at "first" (although we may also fetch some preceding entries) Recommend to call getSize() before getElementAt() or getElements() since you'd better check if the index is out of bound first.
        Specified by:
        getPage in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        first - the index of the first entry of the page you want to fetch
      • getPage

        public boolean getPage​(java.lang.String text)
        Called by application to scroll the list with initial letters. Consider text to be an initial substring of the attribute of the primary sorting key(the first one specified in the sort key array) of an entry. If no entries match, the one just before(or after, if none before) will be returned as mSelectedIndex
        Specified by:
        getPage in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        text - the prefix of the first entry of the page you want to fetch
      • getElementAt

        public E getElementAt​(int index)
        fetch data of a single list item Recommend to call getSize() before getElementAt() or getElements() since you'd better check if the index is out of bound first. If the index is out of range of the virtual list, an exception will be thrown and return null
        Specified by:
        getElementAt in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        index - the index of the element to fetch
      • getJumpToElementAt

        public E getJumpToElementAt​(int i)
        Description copied from interface: com.netscape.certsrv.dbs.IDBVirtualList
        Retrieves and jumps to element in the given position.
        Specified by:
        getJumpToElementAt in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        i - position
        Returns:
        object
      • processElements

        public void processElements​(int startidx,
                                    int endidx,
                                    com.netscape.certsrv.dbs.IElementProcessor ep)
                             throws EBaseException
        This function processes elements as soon as it arrives. It is more memory-efficient.
        Specified by:
        processElements in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Parameters:
        startidx - starting index
        endidx - ending index
        ep - object to call
        Throws:
        EBaseException - failed to process elements
      • getSelectedIndex

        public int getSelectedIndex()
        get the virutal selected index
        Specified by:
        getSelectedIndex in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Returns:
        selected index
      • getFirstIndex

        public int getFirstIndex()
        get the top of the buffer
        Specified by:
        getFirstIndex in interface com.netscape.certsrv.dbs.IDBVirtualList<E extends com.netscape.certsrv.dbs.IDBObj>
        Returns:
        first index