Class DSJQuery

  • All Implemented Interfaces:
    java.lang.Iterable<com.xerox.docushare.DSObject>

    public class DSJQuery
    extends java.lang.Object
    implements java.lang.Iterable<com.xerox.docushare.DSObject>
    DSJQuery - DocuShare jQuery A DocuShare object query library similar to jQuery.
    Author:
    d.gowans
    See Also:
    dsJQuery on GitHub
    • Constructor Summary

      Constructors 
      Constructor Description
      DSJQuery()
      Creates a new DSJQuery object at the root of the DocuShare library.
      DSJQuery​(com.xerox.docushare.DSObject dsObject)
      Creates a new DSJQuery object from a single DSObject.
      DSJQuery​(java.lang.String findSelector)
      Creates a new DSJQuery object with DSObjects that match the given filter.
      DSJQuery​(java.util.List<com.xerox.docushare.DSObject> dsObjects)
      Creates a new DSJQuery object from a list of DSObjects.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DSJQuery addKeyword​(java.lang.String keywordToAdd)
      Adds a new keyword to the comma-separated keyword list for each DSObject.
      DSJQuery append​(DSJQuery newChildren)
      Links all child elements under the current set of collections.
      java.lang.Object attr​(java.lang.String attributeName)
      Get the value of an attribute for the first element in the current set.
      DSJQuery attr​(java.lang.String attributeName, java.lang.Object value)
      Sets an attribute across all current objects.
      DSJQuery children()
      Retrieves the immediate descendants for all selected collections.
      DSJQuery children​(java.lang.String filterSelector)
      Retrieves the immediate descendants for all selected collections which satisfy a given filter.
      DSJQuery clone()
      Creates a new DSJQuery object with the same set of matching objects.
      DSJQuery filter​(java.lang.String filterSelector)
      Reduces the set of objects to those that match the given selector.
      DSJQuery filter_byObjectClass​(java.lang.String className)
      Reduces the set of objects to those of a given object class.
      DSJQuery filter_byProperty_contains​(java.lang.String propertyName, java.lang.String propertyValue, boolean ignoreCase)
      Reduces the set of objects to those with property values containing a given value.
      DSJQuery filter_byProperty_endsWith​(java.lang.String propertyName, java.lang.String propertyValue, boolean ignoreCase)
      Reduces the set of objects to those with property values ending with a given value.
      DSJQuery filter_byProperty_equals​(java.lang.String propertyName, java.lang.String propertyValue, boolean ignoreCase)
      Reduces the set of objects to those with property values equal to a given value.
      DSJQuery filter_byProperty_startsWith​(java.lang.String propertyName, java.lang.String propertyValue, boolean ignoreCase)
      Reduces the set of objects to those with property values starting with a given value.
      DSJQuery find​(java.lang.String findSelector)
      Searches beneath all currently selected Collections for Documents and Collections that match the given selector.
      DSJQuery find_all()
      Searches beneath all currently selected Collections for all Documents and Collections.
      DSJQuery find_byHandle​(java.lang.String handle)
      Searches beneath all currently selected Collections for objects with the given handle.
      DSJQuery find_byObjectClass​(java.lang.String className)
      Searches beneath all currently selection Collections for objects with a given object class.
      DSJQuery first()
      Filters the current set of documents and collections to only include the first one.
      java.lang.String handle()
      Get the handle for the first element in the current set.
      boolean hasKeyword​(java.lang.String keyword)
      Determines whether any of the current objects have a given keyword.
      boolean hasKeyword​(java.lang.String keyword, boolean ignoreCase)
      Determines whether any of the current objects have a given keyword, with the option to ignore case.
      DSJQuery insertAndGet​(java.io.File file)
      Uploads a new Document to DocuShare under each Collection in the set.
      DSJQuery insertCollectionAndGet​(java.lang.String collectionName)
      Creates a new Collection under each Collection in the set.
      java.util.Iterator<com.xerox.docushare.DSObject> iterator()  
      int length()
      Returns the total number of DSObjects in the DSJQuery object.
      DSJQuery print()
      For debug purposes, outputs the handles and titles of objects currently the DSJQuery object.
      void remove()
      Removes all objects in the DSJQuery object.
      DSJQuery removeAttr​(java.lang.String attributeName)
      Clears an attribute across all current objects.
      DSJQuery removeKeyword​(java.lang.String keywordToRemove)
      Removes the first instance of a keyword from the keyword list if it is found.
      DSJQuery reverse()
      Reverses the order of the current set of objects.
      DSJQuery sort​(java.util.Comparator<com.xerox.docushare.DSObject> comparator)
      Sorts the current set of objects using a Comparator.
      DSJQuery sortAsc_byAttribute​(java.lang.String attributeName)
      Sorts the current set of objects in ascending order by an attribute.
      java.util.List<com.xerox.docushare.DSObject> toList()
      Similar to $().toArray(), returns the List of DSObjects.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • DSJQuery

        public DSJQuery​(java.lang.String findSelector)
                 throws com.xerox.docushare.DSException,
                        DSJQueryException,
                        java.lang.InterruptedException
        Creates a new DSJQuery object with DSObjects that match the given filter.
        Parameters:
        findSelector - - A find selector
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • DSJQuery

        public DSJQuery​(java.util.List<com.xerox.docushare.DSObject> dsObjects)
                 throws DSJQueryException
        Creates a new DSJQuery object from a list of DSObjects.
        Parameters:
        dsObjects -
        Throws:
        DSJQueryException
      • DSJQuery

        public DSJQuery​(com.xerox.docushare.DSObject dsObject)
                 throws DSJQueryException
        Creates a new DSJQuery object from a single DSObject.
        Parameters:
        dsObject -
        Throws:
        DSJQueryException
    • Method Detail

      • find_all

        public DSJQuery find_all()
                          throws com.xerox.docushare.DSException,
                                 DSJQueryException,
                                 java.lang.InterruptedException
        Searches beneath all currently selected Collections for all Documents and Collections. Equivalent to find("*")
        Returns:
        A new DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • find_byHandle

        public DSJQuery find_byHandle​(java.lang.String handle)
                               throws com.xerox.docushare.DSException,
                                      DSJQueryException,
                                      java.lang.InterruptedException
        Searches beneath all currently selected Collections for objects with the given handle.
        Parameters:
        handle - - i.e. "Document-111"
        Returns:
        A new DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • find_byObjectClass

        public DSJQuery find_byObjectClass​(java.lang.String className)
                                    throws com.xerox.docushare.DSException,
                                           DSJQueryException,
                                           java.lang.InterruptedException
        Searches beneath all currently selection Collections for objects with a given object class.
        Parameters:
        className - - i.e. "Document"
        Returns:
        A new DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • find

        public DSJQuery find​(java.lang.String findSelector)
                      throws com.xerox.docushare.DSException,
                             DSJQueryException,
                             java.lang.InterruptedException
        Searches beneath all currently selected Collections for Documents and Collections that match the given selector.
        Parameters:
        findSelector - - i.e. "*" or ".Document" or "#Document-111"
        Returns:
        A new DSJquery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
        See Also:
        find() | jQuery API
      • children

        public DSJQuery children​(java.lang.String filterSelector)
                          throws com.xerox.docushare.DSException,
                                 DSJQueryException
        Retrieves the immediate descendants for all selected collections which satisfy a given filter.
        Parameters:
        filterSelector - - i.e. ".Document", "[content_type^='image/']"
        Returns:
        A new DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        See Also:
        children() | jQuery API
      • filter_byProperty_startsWith

        public DSJQuery filter_byProperty_startsWith​(java.lang.String propertyName,
                                                     java.lang.String propertyValue,
                                                     boolean ignoreCase)
                                              throws com.xerox.docushare.DSException,
                                                     DSJQueryException
        Reduces the set of objects to those with property values starting with a given value.
        Parameters:
        propertyName -
        propertyValue -
        ignoreCase -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • filter_byProperty_endsWith

        public DSJQuery filter_byProperty_endsWith​(java.lang.String propertyName,
                                                   java.lang.String propertyValue,
                                                   boolean ignoreCase)
                                            throws com.xerox.docushare.DSException,
                                                   DSJQueryException
        Reduces the set of objects to those with property values ending with a given value.
        Parameters:
        propertyName -
        propertyValue -
        ignoreCase -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • filter_byProperty_contains

        public DSJQuery filter_byProperty_contains​(java.lang.String propertyName,
                                                   java.lang.String propertyValue,
                                                   boolean ignoreCase)
                                            throws com.xerox.docushare.DSException,
                                                   DSJQueryException
        Reduces the set of objects to those with property values containing a given value.
        Parameters:
        propertyName -
        propertyValue -
        ignoreCase -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • filter_byProperty_equals

        public DSJQuery filter_byProperty_equals​(java.lang.String propertyName,
                                                 java.lang.String propertyValue,
                                                 boolean ignoreCase)
                                          throws com.xerox.docushare.DSException,
                                                 DSJQueryException
        Reduces the set of objects to those with property values equal to a given value.
        Parameters:
        propertyName -
        propertyValue -
        ignoreCase -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • filter_byObjectClass

        public DSJQuery filter_byObjectClass​(java.lang.String className)
                                      throws com.xerox.docushare.DSException,
                                             DSJQueryException
        Reduces the set of objects to those of a given object class.
        Parameters:
        className -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • filter

        public DSJQuery filter​(java.lang.String filterSelector)
                        throws com.xerox.docushare.DSException,
                               DSJQueryException
        Reduces the set of objects to those that match the given selector.
        Parameters:
        filterSelector - - i.e. ".Document", "[content_type^='image/']"
        Returns:
        A new DSJquery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        See Also:
        filter() | jQuery API
      • sort

        public DSJQuery sort​(java.util.Comparator<com.xerox.docushare.DSObject> comparator)
                      throws DSJQueryException
        Sorts the current set of objects using a Comparator.
        Parameters:
        comparator - - The sorting function
        Returns:
        A new, sorted DSJQuery object
        Throws:
        DSJQueryException
      • sortAsc_byAttribute

        public DSJQuery sortAsc_byAttribute​(java.lang.String attributeName)
                                     throws com.xerox.docushare.DSException,
                                            DSJQueryException
        Sorts the current set of objects in ascending order by an attribute.
        Parameters:
        attributeName - - The attribute to sort by.
        Returns:
        A new, sorted DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
      • reverse

        public DSJQuery reverse()
                         throws DSJQueryException
        Reverses the order of the current set of objects. Can be used to reorder a list in descending order after calling sortAsc.
        Returns:
        A new DSJQuery object
        Throws:
        DSJQueryException
      • attr

        public java.lang.Object attr​(java.lang.String attributeName)
                              throws com.xerox.docushare.DSException
        Get the value of an attribute for the first element in the current set.
        Parameters:
        attributeName -
        Returns:
        The selected attribute value
        Throws:
        com.xerox.docushare.DSException
        See Also:
        attr() | jQuery API
      • handle

        public java.lang.String handle()
                                throws com.xerox.docushare.DSException
        Get the handle for the first element in the current set.
        Throws:
        com.xerox.docushare.DSException
        See Also:
        attr() | jQuery API
      • attr

        public DSJQuery attr​(java.lang.String attributeName,
                             java.lang.Object value)
                      throws com.xerox.docushare.DSException
        Sets an attribute across all current objects.
        Parameters:
        attributeName -
        value -
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        See Also:
        attr() | jQuery API
      • removeAttr

        public DSJQuery removeAttr​(java.lang.String attributeName)
                            throws com.xerox.docushare.DSException
        Clears an attribute across all current objects.
        Parameters:
        attributeName -
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        See Also:
        removeAttr() | jQuery API
      • hasKeyword

        public boolean hasKeyword​(java.lang.String keyword,
                                  boolean ignoreCase)
                           throws com.xerox.docushare.DSException
        Determines whether any of the current objects have a given keyword, with the option to ignore case.
        Parameters:
        keyword -
        ignoreCase - - TRUE if case should be ignored
        Returns:
        TRUE if the keyword is assigned to at least one object
        Throws:
        com.xerox.docushare.DSException
      • hasKeyword

        public boolean hasKeyword​(java.lang.String keyword)
                           throws com.xerox.docushare.DSException
        Determines whether any of the current objects have a given keyword.
        Parameters:
        keyword -
        Returns:
        Throws:
        com.xerox.docushare.DSException
        See Also:
        hasClass() | jQuery API
      • addKeyword

        public DSJQuery addKeyword​(java.lang.String keywordToAdd)
                            throws com.xerox.docushare.DSException
        Adds a new keyword to the comma-separated keyword list for each DSObject. The new keyword is only added if the keyword is not already part of the list.
        Parameters:
        keywordToAdd -
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        See Also:
        addClass() | jQuery API
      • removeKeyword

        public DSJQuery removeKeyword​(java.lang.String keywordToRemove)
                               throws com.xerox.docushare.DSException
        Removes the first instance of a keyword from the keyword list if it is found.
        Parameters:
        keywordToRemove -
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        See Also:
        removeClass() | jQuery API
      • append

        public DSJQuery append​(DSJQuery newChildren)
                        throws com.xerox.docushare.DSException
        Links all child elements under the current set of collections.
        Parameters:
        newChildren -
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
        See Also:
        append() | jQuery API
      • insertAndGet

        public DSJQuery insertAndGet​(java.io.File file)
                              throws com.xerox.docushare.DSException,
                                     DSJQueryException,
                                     java.lang.InterruptedException
        Uploads a new Document to DocuShare under each Collection in the set.
        Parameters:
        file - - The file to upload to DocuShare.
        Returns:
        A new DSJQuery object containing all of the created Documents.
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • insertCollectionAndGet

        public DSJQuery insertCollectionAndGet​(java.lang.String collectionName)
                                        throws com.xerox.docushare.DSException,
                                               DSJQueryException,
                                               java.lang.InterruptedException
        Creates a new Collection under each Collection in the set.
        Parameters:
        collectionName - - The name of the new Collection.
        Returns:
        A new DSJQuery object containing all of the created Collections.
        Throws:
        com.xerox.docushare.DSException
        DSJQueryException
        java.lang.InterruptedException
      • remove

        public void remove()
                    throws com.xerox.docushare.DSException,
                           java.lang.InterruptedException
        Removes all objects in the DSJQuery object.
        Throws:
        com.xerox.docushare.DSException
        java.lang.InterruptedException
      • length

        public int length()
        Returns the total number of DSObjects in the DSJQuery object.
        Returns:
        See Also:
        length | jQuery API
      • toList

        public java.util.List<com.xerox.docushare.DSObject> toList()
        Similar to $().toArray(), returns the List of DSObjects.
        Returns:
        See Also:
        toArray() | jQuery API
      • print

        public DSJQuery print()
                       throws com.xerox.docushare.DSException
        For debug purposes, outputs the handles and titles of objects currently the DSJQuery object.
        Returns:
        The current DSJQuery object
        Throws:
        com.xerox.docushare.DSException
      • iterator

        public java.util.Iterator<com.xerox.docushare.DSObject> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<com.xerox.docushare.DSObject>