public final class DataContainer extends Object
DataProvider
. A DataProvider
must call one of the following
methods in order to provide some Data
:
setItem(Object)
- in case of a single objectsetItems(Collection)
- in case of a (non-sortable and non-pageable) collection of itemssetPage(Page)
- in case of a (potentially sorted/paginated) Page
setPage(Collection, Pageable)
/ setPage(Collection, Pageable, boolean)
- in case where paging
and sorting should be applied to a collection of itemsResultset
(in case isSingleResult()
returns false
) or a Result
is being added to
the Data
returned by getWrappedData()
using a ResultService
.Constructor and Description |
---|
DataContainer(FieldProcessor fieldProcessor)
Creates a new
DataContainer using the given FieldProcessor . |
Modifier and Type | Method and Description |
---|---|
FieldProcessor |
getFieldProcessor()
Returns the
FieldProcessor this DataContainer was created with |
Object |
getItem()
Returns the single item
|
Collection<?> |
getItems()
Returns the items previously set via one of the
setItems(...) -methods |
org.springframework.data.domain.Page<?> |
getPage()
Returns the
Page (may be null ) for this DataContainer |
org.springframework.data.domain.Pageable |
getPageable()
Returns the
Pageable (may be null ) for this DataContainer |
List<SelectionGroup> |
getSelectionGroups()
Convenience method to access the
SelectionGroup s of the wrapped Data . |
List<Selection> |
getSelections()
|
Data |
getWrappedData()
Returns the
Data wrapped within this DataContainer |
boolean |
isSingleResult()
Returns whether this
DataContainer contains only a single item |
void |
setItem(Object item)
Sets the single item
|
void |
setItems(Collection<?> items)
Sets the
Collection of items for this DataContainer . |
void |
setPage(Collection<?> items,
org.springframework.data.domain.Pageable pageable)
Sets the
Page for this DataContainer , which is being extracted from the given Collection
of items, based on the given Pageable . |
void |
setPage(Collection<?> items,
org.springframework.data.domain.Pageable pageable,
boolean skipSort)
Sets the
Page for this DataContainer , which is being extracted from the given Collection
of items, based on the given Pageable .For example, if there are 15 items in the collection, and the Pageable requests (the 0-based) page 1 with
a pagesize of 10, the resulting page will contain the (1-based) elements 11 to 15.If the Pageable has a Sort property set, the items will be sorted before extracting the page. |
void |
setPage(org.springframework.data.domain.Page<?> page)
Sets the
Page for this DataContainer |
public DataContainer(FieldProcessor fieldProcessor)
DataContainer
using the given FieldProcessor
.fieldProcessor
- the FieldProcessor
containing all readable FieldDef
initionspublic Object getItem()
public void setItem(Object item)
item
- the itempublic boolean isSingleResult()
DataContainer
contains only a single itemtrue
if this DataContainer
only contains a single result which has been set via
setItem(Object)
public Collection<?> getItems()
setItems(...)
-methodspublic void setItems(Collection<?> items)
Collection
of items for this DataContainer
. Note that paging and sorting is not
supported when using this method.items
- a Collection
of itemspublic void setPage(Collection<?> items, org.springframework.data.domain.Pageable pageable)
Page
for this DataContainer
, which is being extracted from the given Collection
of items, based on the given Pageable
. See setPage(Collection, Pageable, boolean)
for details.items
- the Collection
of items the extract the Page
frompageable
- the Pageable
for the Page
to extractsetPage(Collection, Pageable, boolean)
public void setPage(Collection<?> items, org.springframework.data.domain.Pageable pageable, boolean skipSort)
Page
for this DataContainer
, which is being extracted from the given Collection
of items, based on the given Pageable
.Pageable
requests (the 0-based) page 1 with
a pagesize of 10, the resulting page will contain the (1-based) elements 11 to 15.Pageable
has a Sort
property set, the items will be sorted before extracting the page.
Note that sorting the items is done by using Java Reflection-API, thus for performance reasons it is not
recommended to apply sorting to very large collections. Such collections should be pre-sorted before in a
non-reflective way (then skipSort
should be set to true
).
items
- the Collection
of items the extract the Page
frompageable
- the Pageable
for the Page
to extractskipSort
- if the items should not get sorted, even if the pageable
has a Sort
property setpublic org.springframework.data.domain.Pageable getPageable()
Pageable
(may be null
) for this DataContainer
Pageable
, if anysetPage(Page)
,
setPage(Collection, Pageable)
public org.springframework.data.domain.Page<?> getPage()
Page
(may be null
) for this DataContainer
Page
, if anysetPage(Page)
,
setPage(Collection, Pageable)
public void setPage(org.springframework.data.domain.Page<?> page)
Page
for this DataContainer
page
- the Page
to setpublic List<Selection> getSelections()
Selection
sgetWrappedData()
public List<SelectionGroup> getSelectionGroups()
SelectionGroup
s of the wrapped Data
.SelectionGroup
sgetWrappedData()
public Data getWrappedData()
Data
wrapped within this DataContainer
Data
public FieldProcessor getFieldProcessor()
FieldProcessor
this DataContainer
was created withFieldProcessor
Copyright © 2011–2017 aiticon GmbH. All rights reserved.