public class ResolvableDatasource extends AbstractDatasource implements java.util.Collection
Collection
of
Resolvable
objects. The class itself
implements also the interface Collection
and serves as
wrapper for the underlying Collection of objects.
As Datasource this class supports filtering with RuleTree
s, sorting and paging.Modifier and Type | Class and Description |
---|---|
protected class |
ResolvableDatasource.Sorter
Comparator class for sorting Resolvables
TODO unify this (use the generic Comparator for resolvables)
|
Datasource.Sorting
Modifier and Type | Field and Description |
---|---|
protected org.apache.log4j.Logger |
logger
logger object
|
SORTORDER_ASC, SORTORDER_DESC, SORTORDER_NONE
Constructor and Description |
---|
ResolvableDatasource()
Create an empty instance of the ResolvableDatasource
|
ResolvableDatasource(java.util.Collection rows)
Create an instance of the ResolvableDatasource that holds the objects given in the collection
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(java.lang.Object o) |
boolean |
addAll(java.util.Collection c) |
void |
clear() |
java.lang.Object |
clone()
Clone the datasource (that means to create a copy that would
work excactly like this datasource)
|
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection c) |
DatasourceFilter |
createDatasourceFilter(Expression expression)
Create a datasource filter for the given expression.
|
protected com.gentics.lib.datasource.ResolvableDatasourceFilter |
getAsResolvableDatasourceFilter(DatasourceFilter filter)
Get the datasource filter as resolvable datasource filter
|
int |
getCount(DatasourceFilter filter,
java.util.Map specificParameters)
Get the number of objects in the datasource that match the given filter
|
int |
getCount2()
Get the number of rows matching the given rule.
|
HandlePool |
getHandlePool()
Get the handlepool used by this Datasource.
|
java.util.Collection |
getResult(DatasourceFilter filter,
java.lang.String[] prefillAttributes,
int start,
int count,
Datasource.Sorting[] sortedColumns,
java.util.Map specificParameters)
Get the resolvables from the datasource that match the given datasource filter.
|
java.util.Collection |
getResult(int start,
int count,
java.lang.String sortBy,
int sortOrder,
java.util.Map specificParameters)
Returns data fetched from the Datasource using the given RuleTree as filter.
|
boolean |
hasChanged()
Return true when data in the underlying storage layer might have changed
since the last invocation of
Datasource.getResult() (or any of it's
variants). |
boolean |
hasChanged(long timestamp)
This default implementation simply always returns true.
|
boolean |
isEmpty() |
java.util.Iterator |
iterator() |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection c) |
boolean |
retainAll(java.util.Collection c) |
void |
setAttributeNames(java.lang.String[] names)
Defines Attribute to select or store.
|
void |
setRuleTree(RuleTree ruleTree)
Set the RuleTree to be used as filter when data is retrieved from this
datasource.
|
int |
size() |
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
getCount, getCount, getId, getResult, getResult, getResult, getResult, getResult, isValidAttribute, setId
public ResolvableDatasource()
public ResolvableDatasource(java.util.Collection rows)
rows
- collection of Resolvable objectspublic void setRuleTree(RuleTree ruleTree)
Datasource
setRuleTree
in interface Datasource
ruleTree
- filter RuleTreeDatasource.getResult(DatasourceFilter, String[])
,
Datasource.createDatasourceFilter(Expression)
public void setAttributeNames(java.lang.String[] names)
Datasource
setAttributeNames
in interface Datasource
names
- array of attribute namespublic java.util.Collection getResult(int start, int count, java.lang.String sortBy, int sortOrder, java.util.Map specificParameters) throws DatasourceNotAvailableException
Datasource
getResult
in interface Datasource
start
- index of the first object to get after the filter and sorting have been
applied (counting starts with 0)count
- maximum number of objects to return, -1 for no limitsortBy
- property to sortby, null for unsorted result. May also
contain a comma separated list of attribute namessortOrder
- sort order, use one of Datasource.SORTORDER_ASC
,
Datasource.SORTORDER_DESC
Datasource.SORTORDER_NONE
specificParameters
- map of specific parameters, which will be
interpreted by some specific Datasources, may be null or empty (no
specific parameters)DatasourceNotAvailableException
- if the datasource is not availablepublic int getCount2() throws DatasourceNotAvailableException
Datasource
getCount2
in interface Datasource
DatasourceNotAvailableException
- if the datasource is not availablepublic HandlePool getHandlePool()
Datasource
getHandlePool
in interface Datasource
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Datasource
clone
in interface Datasource
clone
in class AbstractDatasource
java.lang.CloneNotSupportedException
- if cloning is not possiblepublic boolean hasChanged()
Datasource
Datasource.getResult()
(or any of it's
variants). The specific implementations can simply return true when a
change cannot be determined other than refetching the data or can do any
specific checks for modified data.hasChanged
in interface Datasource
public boolean hasChanged(long timestamp)
AbstractDatasource
hasChanged
in interface Datasource
hasChanged
in class AbstractDatasource
timestamp
- timestamp to check if data has propably changed - timestamp is a java timestamp - ie. milliseconds since 1970 like System.currentTimeMillis()
Datasource.hasChanged(long)
public int size()
size
in interface java.util.Collection
public void clear()
clear
in interface java.util.Collection
public boolean isEmpty()
isEmpty
in interface java.util.Collection
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
public boolean add(java.lang.Object o)
add
in interface java.util.Collection
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
public DatasourceFilter createDatasourceFilter(Expression expression) throws ExpressionParserException
Datasource
createDatasourceFilter
in interface Datasource
expression
- expression to transform into a datasource filterExpressionParserException
- When the DatasourceFilter can't be createdpublic java.util.Collection getResult(DatasourceFilter filter, java.lang.String[] prefillAttributes, int start, int count, Datasource.Sorting[] sortedColumns, java.util.Map specificParameters) throws DatasourceException
Datasource
getResult
in interface Datasource
filter
- datasource filterprefillAttributes
- array of attribute names to prefill (null or empty for no prefilling)start
- index of the first object to returncount
- maximum number of objects to return (-1 for all objects).sortedColumns
- possible sorting (may be null for "no sorting")specificParameters
- map of specific parameters, which will be
interpreted by some specific Datasources, may be null or empty (no
specific parameters)DatasourceException
- in case of errorsDatasource.createDatasourceFilter(Expression)
public int getCount(DatasourceFilter filter, java.util.Map specificParameters) throws DatasourceException
Datasource
getCount
in interface Datasource
filter
- datasource filterspecificParameters
- map of specific parameters, which will be
interpreted by some specific Datasources, may be null or empty (no
specific parameters)DatasourceException
- in case of errorsDatasource.createDatasourceFilter(Expression)
protected com.gentics.lib.datasource.ResolvableDatasourceFilter getAsResolvableDatasourceFilter(DatasourceFilter filter) throws DatasourceException
filter
- filterDatasourceException
- in case of errorsCopyright © 2019 Gentics Software. All Rights Reserved.