I - the item ID typeT - the type of the Java objects that back each Item in the containerpublic abstract class AbstractSimpleContainer<I,T> extends AbstractInMemoryContainer<I,String,BackedItem<T>> implements PropertyExtractor<T>, Container.Filterable, Container.SimpleFilterable, Container.Sortable, Connectable
Container implementations where each
Item in the container is backed by a Java object.
This Container's Propertys are defined via PropertyDefs, and a PropertyExtractor
is used to actually extract the property values from each underlying object (alternately, subclasses can override
getPropertyValue()). However, the easist way to configure the container Propertys
is to pass a @ProvidesProperty-annotated Java class to the AbstractSimpleContainer(Class)
constructor.
Use load() to load or reload the container.
SimpleItem,
Serialized FormAbstractInMemoryContainer.BaseItemAddEvent, AbstractInMemoryContainer.BaseItemRemoveEventAbstractContainer.BaseItemSetChangeEvent, AbstractContainer.BasePropertySetChangeEventContainer.Editor, Container.Filter, Container.Filterable, Container.Hierarchical, Container.Indexed, Container.ItemSetChangeEvent, Container.ItemSetChangeListener, Container.ItemSetChangeNotifier, Container.Ordered, Container.PropertySetChangeEvent, Container.PropertySetChangeListener, Container.PropertySetChangeNotifier, Container.SimpleFilterable, Container.Sortable, Container.ViewerContainer.Indexed.ItemAddEvent, Container.Indexed.ItemRemoveEvent| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSimpleContainer()
Constructor.
|
protected |
AbstractSimpleContainer(Class<? super T> type)
Constructor.
|
protected |
AbstractSimpleContainer(Collection<? extends PropertyDef<?>> propertyDefs)
Constructor.
|
protected |
AbstractSimpleContainer(PropertyExtractor<? super T> propertyExtractor)
Constructor.
|
protected |
AbstractSimpleContainer(PropertyExtractor<? super T> propertyExtractor,
Collection<? extends PropertyDef<?>> propertyDefs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContainerFilter(Container.Filter filter) |
void |
addContainerFilter(Object propertyId,
String filterString,
boolean ignoreCase,
boolean onlyMatchPrefix) |
protected void |
afterReload()
Subclass hook invoked after each reload but prior to invoking
AbstractContainer.fireItemSetChange(). |
void |
connect()
Connect this instance to non-Vaadin resources.
|
protected BackedItem<T> |
createBackedItem(T object,
Collection<PropertyDef<?>> propertyDefs,
PropertyExtractor<? super T> propertyExtractor)
Create a
BackedItem for the given backing Java object. |
void |
disconnect()
Disconnect this instance from non-Vaadin resources.
|
protected abstract I |
generateItemId(T obj)
Create a new, unique item ID for the given object.
|
Collection<Container.Filter> |
getContainerFilters() |
Property<?> |
getContainerProperty(Object itemId,
Object propertyId) |
Set<String> |
getContainerPropertyIds() |
I |
getItemIdFor(T obj)
Get the container item ID corresponding to the given underlying Java object which is wrapped by this container.
|
I |
getItemIdForSame(T obj)
Get the container item ID corresponding to the given underlying Java object which is wrapped by this container.
|
List<I> |
getItemIds() |
abstract T |
getJavaObject(Object itemId)
Get the underlying Java object corresponding to the given item ID.
|
PropertyExtractor<? super T> |
getPropertyExtractor()
Get the configured
PropertyExtractor for this container. |
<V> V |
getPropertyValue(T obj,
PropertyDef<V> propertyDef)
Read the value of the property defined by
propertyDef from the given object. |
Collection<?> |
getSortableContainerPropertyIds() |
Class<?> |
getType(Object propertyId) |
BackedItem<T> |
getUnfilteredItem(Object itemId) |
protected void |
internalRemoveAllItems() |
void |
load(Iterable<? extends T> contents)
Change this container's contents.
|
void |
load(Iterator<? extends T> contents)
Change this container's contents.
|
void |
removeAllContainerFilters() |
void |
removeContainerFilter(Container.Filter filter) |
void |
removeContainerFilters(Object propertyId) |
protected abstract void |
resetItemIds()
Subclass hook invoked prior to each reload.
|
void |
setProperties(Collection<? extends PropertyDef<?>> propertyDefs)
Change the configured properties of this container.
|
void |
setProperty(PropertyDef<?> propertyDef)
Add or replace a configured property of this container.
|
void |
setPropertyExtractor(PropertyExtractor<? super T> propertyExtractor)
Change the configured
PropertyExtractor for this container. |
void |
sort(Object[] propertyId,
boolean[] ascending) |
addContainerProperty, addFilter, addItem, addItem, addItemAfter, addItemAfter, addItemAt, addItemAt, addItemSetChangeListener, addListener, containsId, doFilterContainer, doSort, filterAll, fireItemAdded, fireItemRemoved, fireItemsAdded, fireItemsRemoved, firstItemId, getAllItemIds, getFilteredItemIds, getFilters, getFirstVisibleItem, getIdByIndex, getItem, getItemIds, getItemSorter, getSortablePropertyIds, getVisibleItemIds, hasContainerFilters, indexOfId, internalAddItemAfter, internalAddItemAt, internalAddItemAtEnd, internalRemoveItem, isFiltered, isFirstId, isLastId, isPropertyFiltered, lastItemId, nextItemId, passesFilters, prevItemId, registerNewItem, removeAllFilters, removeAllItems, removeContainerProperty, removeFilter, removeFilters, removeItem, removeItemSetChangeListener, removeListener, setAllItemIds, setFilteredItemIds, setFilters, setItemSorter, size, sortContaineraddListener, addPropertySetChangeListener, fireContainerPropertySetChange, fireContainerPropertySetChange, fireItemSetChange, fireItemSetChange, getItemSetChangeListeners, getListeners, getPropertySetChangeListeners, removeListener, removePropertySetChangeListener, setItemSetChangeListeners, setPropertySetChangeListenersclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddItemAfter, addItemAfter, firstItemId, isFirstId, isLastId, lastItemId, nextItemId, prevItemIdaddContainerProperty, addItem, addItem, containsId, getItem, removeAllItems, removeContainerProperty, removeItem, sizeprotected AbstractSimpleContainer()
After using this constructor, subsequent invocations of setPropertyExtractor()
and setProperties() are required to define the properties of this container
and how to extract them.
protected AbstractSimpleContainer(PropertyExtractor<? super T> propertyExtractor)
After using this constructor, a subsequent invocation of setProperties() is required
to define the properties of this container.
propertyExtractor - used to extract properties from the underlying Java objects;
may be null but then container is not usable until one is configured via
setPropertyExtractor()protected AbstractSimpleContainer(Collection<? extends PropertyDef<?>> propertyDefs)
After using this constructor, a subsequent invocation of setPropertyExtractor() is required
to define how to extract the properties of this container; alternately, subclasses can override
getPropertyValue().
propertyDefs - container property definitions; null is treated like the empty setprotected AbstractSimpleContainer(PropertyExtractor<? super T> propertyExtractor, Collection<? extends PropertyDef<?>> propertyDefs)
propertyExtractor - used to extract properties from the underlying Java objects;
may be null but then container is not usable until one is configured via
setPropertyExtractor()propertyDefs - container property definitions; null is treated like the empty setprotected AbstractSimpleContainer(Class<? super T> type)
Properties will be determined by the @ProvidesProperty and
@ProvidesPropertySort annotated methods in the given class.
type - class to introspect for annotated methodsIllegalArgumentException - if type is nullIllegalArgumentException - if type has two @ProvidesProperty
or @ProvidesPropertySort annotated methods for the same propertyIllegalArgumentException - if a @ProvidesProperty-annotated method with no
property name specified has a name which cannot be interpreted as a bean
property "getter" methodProvidesProperty,
ProvidesPropertySort,
ProvidesPropertyScannerpublic PropertyExtractor<? super T> getPropertyExtractor()
PropertyExtractor for this container.PropertyExtractorpublic void setPropertyExtractor(PropertyExtractor<? super T> propertyExtractor)
PropertyExtractor for this container.
Invoking this method does not result in any container notifications.propertyExtractor - used to extract properties from the underlying Java objects;
may be null but the container is not usable without onepublic <V> V getPropertyValue(T obj, PropertyDef<V> propertyDef)
propertyDef from the given object.
The implementation in AbstractSimpleContainer just delegates to the configured
PropertyExtractor; subclasses may override to customize property extraction.
getPropertyValue in interface PropertyExtractor<T>V - value typeobj - Java objectpropertyDef - definition of which property to readNullPointerException - if either parameter is nullIllegalStateException - if no PropertyExtractor is configured for this containerpublic void setProperties(Collection<? extends PropertyDef<?>> propertyDefs)
propertyDefs - container property definitions; null is treated like the empty setIllegalArgumentException - if propertyDefs contains a property with a duplicate namepublic void setProperty(PropertyDef<?> propertyDef)
propertyDef - new container property definitionsIllegalArgumentException - if propertyDef is nullpublic void load(Iterable<? extends T> contents)
contents - new container contentsIllegalArgumentException - if contents or any item in contents is nullpublic void load(Iterator<? extends T> contents)
contents - new container contentsIllegalArgumentException - if contents or any item in contents is nullprotected void internalRemoveAllItems()
internalRemoveAllItems in class AbstractInMemoryContainer<I,String,BackedItem<T>>public I getItemIdFor(T obj)
Object.equals().
The implementation in AbstractSimpleContainer requires a linear search of the container.
Some subclasses may provide a more efficient implementation.
This method is not used by this class but is defined as a convenience for subclasses.
Note: items that are filtered out will not be found.
obj - underlying container objectobject, or null if object is not found in this containerIllegalArgumentException - if object is nullgetItemIdForSame(T)public I getItemIdForSame(T obj)
Object.equals().
The implementation in AbstractSimpleContainer requires a linear search of the container.
Some subclasses may provide a more efficient implementation.
This method is not used by this class but is defined as a convenience for subclasses.
Note: items that are filtered out will not be found.
obj - underlying container objectobject, or null if object is not found in this containerIllegalArgumentException - if object is nullgetItemIdFor(T)public void connect()
The implementation in AbstractSimpleContainer does nothing.
connect in interface ConnectableIllegalStateException - if there is no VaadinSession associated with the current threadpublic void disconnect()
The implementation in AbstractSimpleContainer does nothing.
disconnect in interface ConnectableIllegalStateException - if there is no VaadinSession associated with the current threadpublic List<I> getItemIds()
getItemIds in interface ContainergetItemIds in class AbstractInMemoryContainer<I,String,BackedItem<T>>public Set<String> getContainerPropertyIds()
getContainerPropertyIds in interface Containerpublic Property<?> getContainerProperty(Object itemId, Object propertyId)
getContainerProperty in interface Containerpublic BackedItem<T> getUnfilteredItem(Object itemId)
getUnfilteredItem in class AbstractInMemoryContainer<I,String,BackedItem<T>>public abstract T getJavaObject(Object itemId)
itemId - item IDprotected abstract void resetItemIds()
protected abstract I generateItemId(T obj)
The returned item ID must be unique, i.e., not returned by this method since the most recent invocation of
resetItemIds().
obj - underlying container object, never nullprotected void afterReload()
AbstractContainer.fireItemSetChange().
The implementation in AbstractSimpleContainer does nothing.
protected BackedItem<T> createBackedItem(T object, Collection<PropertyDef<?>> propertyDefs, PropertyExtractor<? super T> propertyExtractor)
BackedItem for the given backing Java object.
The implementation in AbstractSimpleContainer returns
new SimpleItem<T>(object, propertyDefs, propertyExtractor).
object - underlying Java objectpropertyDefs - property definitionspropertyExtractor - extracts the property value from objectBackedItemIllegalArgumentException - if any parameter is nullpublic void sort(Object[] propertyId, boolean[] ascending)
sort in interface Container.Sortablepublic void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix)
addContainerFilter in interface Container.SimpleFilterablepublic Collection<Container.Filter> getContainerFilters()
getContainerFilters in interface Container.FilterablegetContainerFilters in class AbstractInMemoryContainer<I,String,BackedItem<T>>public void removeAllContainerFilters()
removeAllContainerFilters in interface Container.FilterableremoveAllContainerFilters in interface Container.SimpleFilterablepublic void removeContainerFilters(Object propertyId)
removeContainerFilters in interface Container.SimpleFilterablepublic void addContainerFilter(Container.Filter filter)
addContainerFilter in interface Container.Filterablepublic void removeContainerFilter(Container.Filter filter)
removeContainerFilter in interface Container.Filterablepublic Collection<?> getSortableContainerPropertyIds()
getSortableContainerPropertyIds in interface Container.SortableCopyright © 2017. All rights reserved.