Package ca.saultstemarie.dsjquery
Class DSJQuery
- java.lang.Object
-
- ca.saultstemarie.dsjquery.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 DSJQueryaddKeyword(java.lang.String keywordToAdd)Adds a new keyword to the comma-separated keyword list for each DSObject.DSJQueryappend(DSJQuery newChildren)Links all child elements under the current set of collections.java.lang.Objectattr(java.lang.String attributeName)Get the value of an attribute for the first element in the current set.DSJQueryattr(java.lang.String attributeName, java.lang.Object value)Sets an attribute across all current objects.DSJQuerychildren()Retrieves the immediate descendants for all selected collections.DSJQuerychildren(java.lang.String filterSelector)Retrieves the immediate descendants for all selected collections which satisfy a given filter.DSJQueryclone()Creates a new DSJQuery object with the same set of matching objects.DSJQueryfilter(java.lang.String filterSelector)Reduces the set of objects to those that match the given selector.DSJQueryfilter_byObjectClass(java.lang.String className)Reduces the set of objects to those of a given object class.DSJQueryfilter_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.DSJQueryfilter_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.DSJQueryfilter_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.DSJQueryfilter_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.DSJQueryfind(java.lang.String findSelector)Searches beneath all currently selected Collections for Documents and Collections that match the given selector.DSJQueryfind_all()Searches beneath all currently selected Collections for all Documents and Collections.DSJQueryfind_byHandle(java.lang.String handle)Searches beneath all currently selected Collections for objects with the given handle.DSJQueryfind_byObjectClass(java.lang.String className)Searches beneath all currently selection Collections for objects with a given object class.DSJQueryfirst()Filters the current set of documents and collections to only include the first one.java.lang.Stringhandle()Get the handle for the first element in the current set.booleanhasKeyword(java.lang.String keyword)Determines whether any of the current objects have a given keyword.booleanhasKeyword(java.lang.String keyword, boolean ignoreCase)Determines whether any of the current objects have a given keyword, with the option to ignore case.DSJQueryinsertAndGet(java.io.File file)Uploads a new Document to DocuShare under each Collection in the set.DSJQueryinsertCollectionAndGet(java.lang.String collectionName)Creates a new Collection under each Collection in the set.java.util.Iterator<com.xerox.docushare.DSObject>iterator()intlength()Returns the total number of DSObjects in the DSJQuery object.DSJQueryprint()For debug purposes, outputs the handles and titles of objects currently the DSJQuery object.voidremove()Removes all objects in the DSJQuery object.DSJQueryremoveAttr(java.lang.String attributeName)Clears an attribute across all current objects.DSJQueryremoveKeyword(java.lang.String keywordToRemove)Removes the first instance of a keyword from the keyword list if it is found.DSJQueryreverse()Reverses the order of the current set of objects.DSJQuerysort(java.util.Comparator<com.xerox.docushare.DSObject> comparator)Sorts the current set of objects using a Comparator.DSJQuerysortAsc_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.
-
-
-
Constructor Detail
-
DSJQuery
public DSJQuery() throws DSJQueryExceptionCreates a new DSJQuery object at the root of the DocuShare library. It contains no DSObjects, but in it's state, any DSObject in the library can be selected.- Throws:
DSJQueryException- See Also:
- jQuery() | jQuery API
-
DSJQuery
public DSJQuery(java.lang.String findSelector) throws com.xerox.docushare.DSException, DSJQueryException, java.lang.InterruptedExceptionCreates a new DSJQuery object with DSObjects that match the given filter.- Parameters:
findSelector- - A find selector- Throws:
com.xerox.docushare.DSExceptionDSJQueryExceptionjava.lang.InterruptedException
-
DSJQuery
public DSJQuery(java.util.List<com.xerox.docushare.DSObject> dsObjects) throws DSJQueryExceptionCreates a new DSJQuery object from a list of DSObjects.- Parameters:
dsObjects-- Throws:
DSJQueryException
-
DSJQuery
public DSJQuery(com.xerox.docushare.DSObject dsObject) throws DSJQueryExceptionCreates 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 tofind("*")- Returns:
- A new DSJQuery object
- Throws:
com.xerox.docushare.DSExceptionDSJQueryExceptionjava.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.DSExceptionDSJQueryExceptionjava.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.DSExceptionDSJQueryExceptionjava.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.DSExceptionDSJQueryExceptionjava.lang.InterruptedException- See Also:
- find() | jQuery API
-
children
public DSJQuery children() throws com.xerox.docushare.DSException, DSJQueryException
Retrieves the immediate descendants for all selected collections.- Returns:
- A new DSJQuery object
- Throws:
com.xerox.docushare.DSExceptionDSJQueryException- See Also:
- children() | 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.DSExceptionDSJQueryException- 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.DSExceptionDSJQueryException
-
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.DSExceptionDSJQueryException
-
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.DSExceptionDSJQueryException
-
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.DSExceptionDSJQueryException
-
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.DSExceptionDSJQueryException
-
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.DSExceptionDSJQueryException- See Also:
- filter() | jQuery API
-
first
public DSJQuery first() throws DSJQueryException
Filters the current set of documents and collections to only include the first one.- Returns:
- A new DSJquery object
- Throws:
DSJQueryException- See Also:
- first() | 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.DSExceptionDSJQueryException
-
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.DSExceptionGet 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.DSExceptionGet 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.DSExceptionDetermines 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.DSExceptionDetermines 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
-
clone
public DSJQuery clone()
Creates a new DSJQuery object with the same set of matching objects.- See Also:
- clone() | 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.DSExceptionDSJQueryExceptionjava.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.DSExceptionDSJQueryExceptionjava.lang.InterruptedException
-
remove
public void remove() throws com.xerox.docushare.DSException, java.lang.InterruptedExceptionRemoves all objects in the DSJQuery object.- Throws:
com.xerox.docushare.DSExceptionjava.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:
iteratorin interfacejava.lang.Iterable<com.xerox.docushare.DSObject>
-
-