|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gentics.api.lib.datasource.AbstractDatasource
com.gentics.api.lib.datasource.ResolvableDatasource
public class ResolvableDatasource
Simple Implementation of a Datasource that is based on a given
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.
Nested Class Summary | |
---|---|
protected class |
ResolvableDatasource.Sorter
Comparator class for sorting Resolvables TODO unify this (use the generic Comparator for resolvables) |
Nested classes/interfaces inherited from interface com.gentics.api.lib.datasource.Datasource |
---|
Datasource.Sorting |
Field Summary | |
---|---|
protected org.apache.log4j.Logger |
logger
logger object |
Fields inherited from interface com.gentics.api.lib.datasource.Datasource |
---|
SORTORDER_ASC, SORTORDER_DESC, SORTORDER_NONE |
Constructor Summary | |
---|---|
ResolvableDatasource()
Create an empty instance of the ResolvableDatasource |
|
ResolvableDatasource(Collection rows)
Create an instance of the ResolvableDatasource that holds the objects given in the collection |
Method Summary | |
---|---|
boolean |
add(Object o)
|
boolean |
addAll(Collection c)
|
void |
clear()
|
Object |
clone()
Clone the datasource (that means to create a copy that would work excactly like this datasource) |
boolean |
contains(Object o)
|
boolean |
containsAll(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,
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. |
Collection |
getResult(DatasourceFilter filter,
String[] prefillAttributes,
int start,
int count,
Datasource.Sorting[] sortedColumns,
Map specificParameters)
Get the resolvables from the datasource that match the given datasource filter. |
Collection |
getResult(int start,
int count,
String sortBy,
int sortOrder,
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()
|
Iterator |
iterator()
|
boolean |
remove(Object o)
|
boolean |
removeAll(Collection c)
|
boolean |
retainAll(Collection c)
|
void |
setAttributeNames(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()
|
Object[] |
toArray()
|
Object[] |
toArray(Object[] a)
|
Methods inherited from class com.gentics.api.lib.datasource.AbstractDatasource |
---|
getCount, getCount, getId, getResult, getResult, getResult, getResult, getResult, isValidAttribute, setId |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
protected org.apache.log4j.Logger logger
Constructor Detail |
---|
public ResolvableDatasource()
public ResolvableDatasource(Collection rows)
rows
- collection of Resolvable objectsMethod Detail |
---|
public void setRuleTree(RuleTree ruleTree)
Datasource
setRuleTree
in interface Datasource
ruleTree
- filter RuleTreeDatasource.getResult(DatasourceFilter, String[])
,
Datasource.createDatasourceFilter(Expression)
public void setAttributeNames(String[] names)
Datasource
setAttributeNames
in interface Datasource
names
- array of attribute namespublic Collection getResult(int start, int count, String sortBy, int sortOrder, 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
public int getCount2() throws DatasourceNotAvailableException
Datasource
getCount2
in interface Datasource
DatasourceNotAvailableException
public HandlePool getHandlePool()
Datasource
getHandlePool
in interface Datasource
public Object clone() throws CloneNotSupportedException
Datasource
clone
in interface Datasource
clone
in class AbstractDatasource
CloneNotSupportedException
public 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 Collection
public void clear()
clear
in interface Collection
public boolean isEmpty()
isEmpty
in interface Collection
public Object[] toArray()
toArray
in interface Collection
public boolean add(Object o)
add
in interface Collection
public boolean contains(Object o)
contains
in interface Collection
public boolean remove(Object o)
remove
in interface Collection
public boolean addAll(Collection c)
addAll
in interface Collection
public boolean containsAll(Collection c)
containsAll
in interface Collection
public boolean removeAll(Collection c)
removeAll
in interface Collection
public boolean retainAll(Collection c)
retainAll
in interface Collection
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
public Object[] toArray(Object[] a)
toArray
in interface Collection
public DatasourceFilter createDatasourceFilter(Expression expression) throws ExpressionParserException
Datasource
createDatasourceFilter
in interface Datasource
expression
- expression to transform into a datasource filter
ExpressionParserException
- When the DatasourceFilter can't be createdpublic Collection getResult(DatasourceFilter filter, String[] prefillAttributes, int start, int count, Datasource.Sorting[] sortedColumns, 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
Datasource.createDatasourceFilter(Expression)
public int getCount(DatasourceFilter filter, 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
Datasource.createDatasourceFilter(Expression)
protected com.gentics.lib.datasource.ResolvableDatasourceFilter getAsResolvableDatasourceFilter(DatasourceFilter filter) throws DatasourceException
filter
- filter
DatasourceException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |