diff options
Diffstat (limited to 'src/com/itmill/toolkit/data')
29 files changed, 247 insertions, 157 deletions
diff --git a/src/com/itmill/toolkit/data/Buffered.java b/src/com/itmill/toolkit/data/Buffered.java index 4aba27376d..0550c49146 100644 --- a/src/com/itmill/toolkit/data/Buffered.java +++ b/src/com/itmill/toolkit/data/Buffered.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.data.Validator.InvalidValueException; import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; @@ -42,7 +44,7 @@ import com.itmill.toolkit.terminal.SystemError; * @VERSION@ * @since 3.0 */ -public interface Buffered { +public interface Buffered extends Serializable { /** * Updates all changes since the previous commit to the data source. The @@ -147,13 +149,9 @@ public interface Buffered { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class SourceException extends RuntimeException implements - ErrorMessage { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256720671781630518L; + ErrorMessage, Serializable { /** Source class implementing the buffered interface */ private final Buffered source; diff --git a/src/com/itmill/toolkit/data/BufferedValidatable.java b/src/com/itmill/toolkit/data/BufferedValidatable.java index 756936710a..24fd689122 100644 --- a/src/com/itmill/toolkit/data/BufferedValidatable.java +++ b/src/com/itmill/toolkit/data/BufferedValidatable.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** * <p> * This interface defines the combination of <code>Validatable</code> and @@ -16,7 +18,8 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface BufferedValidatable extends Buffered, Validatable { +public interface BufferedValidatable extends Buffered, Validatable, + Serializable { /** * Tests if the invalid data is committed to datasource. The default is diff --git a/src/com/itmill/toolkit/data/Container.java b/src/com/itmill/toolkit/data/Container.java index 5df1b34f91..7b9bb31971 100644 --- a/src/com/itmill/toolkit/data/Container.java +++ b/src/com/itmill/toolkit/data/Container.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -51,7 +52,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Container { +public interface Container extends Serializable { /** * Gets the Item with the given Item ID from the Container. If the Container @@ -70,7 +71,7 @@ public interface Container { * * @return unmodifiable collection of Property IDs */ - public Collection getContainerPropertyIds(); + public Collection<?> getContainerPropertyIds(); /** * Gets the ID's of all Items stored in the Container. The ID's are returned @@ -78,7 +79,7 @@ public interface Container { * * @return unmodifiable collection of Item IDs */ - public Collection getItemIds(); + public Collection<?> getItemIds(); /** * Gets the Property identified by the given itemId and propertyId from the @@ -100,7 +101,7 @@ public interface Container { * ID identifying the Properties * @return data type of the Properties */ - public Class getType(Object propertyId); + public Class<?> getType(Object propertyId); /** * Gets the number of Items in the Container. @@ -181,7 +182,7 @@ public interface Container { * @return <code>true</code> if the operation succeeded, <code>false</code> * if not */ - public boolean addContainerProperty(Object propertyId, Class type, + public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException; /** @@ -334,7 +335,7 @@ public interface Container { * * @return The sortable field ids. */ - Collection getSortableContainerPropertyIds(); + Collection<?> getSortableContainerPropertyIds(); } @@ -418,7 +419,7 @@ public interface Container { * containing the IDs of all other Items that are children in * the container hierarchy */ - public Collection getChildren(Object itemId); + public Collection<?> getChildren(Object itemId); /** * Gets the ID of the parent Item of the specified Item. @@ -438,7 +439,7 @@ public interface Container { * @return An unmodifiable {@link java.util.Collection collection} * containing IDs of all root elements of the container */ - public Collection rootItemIds(); + public Collection<?> rootItemIds(); /** * <p> @@ -568,7 +569,7 @@ public interface Container { * * @since 5.0 */ - public interface Filterable extends Container { + public interface Filterable extends Container, Serializable { /** * Add a filter for given property. @@ -600,7 +601,7 @@ public interface Container { * Interface implemented by viewer classes capable of using a Container as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Container that serves as the data source of the viewer. @@ -631,7 +632,7 @@ public interface Container { * internally. * </p> */ - public interface Editor extends Container.Viewer { + public interface Editor extends Container.Viewer, Serializable { } @@ -641,7 +642,7 @@ public interface Container { * An <code>Event</code> object specifying the Container whose Item set has * changed. */ - public interface ItemSetChangeEvent { + public interface ItemSetChangeEvent extends Serializable { /** * Gets the Property where the event occurred. @@ -652,7 +653,7 @@ public interface Container { } /** Container Item set change listener interface. */ - public interface ItemSetChangeListener { + public interface ItemSetChangeListener extends Serializable { /** * Lets the listener know a Containers Item set has changed. @@ -677,7 +678,7 @@ public interface Container { * be able to implement an interface. * </p> */ - public interface ItemSetChangeNotifier { + public interface ItemSetChangeNotifier extends Serializable { /** * Adds an Item set change listener for the object. @@ -702,7 +703,7 @@ public interface Container { * An <code>Event</code> object specifying the Container whose Property set * has changed. */ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Container whose contents have been modified. @@ -716,7 +717,7 @@ public interface Container { * The listener interface for receiving <code>PropertySetChangeEvent</code> * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Containers contents has changed. @@ -744,7 +745,7 @@ public interface Container { * be able to implement an interface. * </p> */ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new Property set change listener for this Container. diff --git a/src/com/itmill/toolkit/data/Item.java b/src/com/itmill/toolkit/data/Item.java index a8ffc3d7c2..1259d9cbda 100644 --- a/src/com/itmill/toolkit/data/Item.java +++ b/src/com/itmill/toolkit/data/Item.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -18,7 +19,7 @@ import java.util.Collection; * @VERSION@ * @since 3.0 */ -public interface Item { +public interface Item extends Serializable { /** * Gets the Property corresponding to the given Property ID stored in the @@ -37,7 +38,7 @@ public interface Item { * @return unmodifiable collection containing IDs of the Properties stored * the Item */ - public Collection getItemPropertyIds(); + public Collection<?> getItemPropertyIds(); /** * Tries to add a new Property into the Item. @@ -78,7 +79,7 @@ public interface Item { * Interface implemented by viewer classes capable of using an Item as a * data source. */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Item that serves as the data source of the viewer. @@ -105,7 +106,7 @@ public interface Item { * restrict the class from editing the contents of an internally. * </p> */ - public interface Editor extends Item.Viewer { + public interface Editor extends Item.Viewer, Serializable { } @@ -119,7 +120,7 @@ public interface Item { * this event. * </p> */ - public interface PropertySetChangeEvent { + public interface PropertySetChangeEvent extends Serializable { /** * Retrieves the Item whose contents has been modified. @@ -133,7 +134,7 @@ public interface Item { * The listener interface for receiving <code>PropertySetChangeEvent</code> * objects. */ - public interface PropertySetChangeListener { + public interface PropertySetChangeListener extends Serializable { /** * Notifies this listener that the Item's property set has changed. @@ -158,7 +159,7 @@ public interface Item { * be able to implement an interface. * </p> */ - public interface PropertySetChangeNotifier { + public interface PropertySetChangeNotifier extends Serializable { /** * Registers a new property set change listener for this Item. diff --git a/src/com/itmill/toolkit/data/Property.java b/src/com/itmill/toolkit/data/Property.java index 42e438025c..b3277fdde2 100644 --- a/src/com/itmill/toolkit/data/Property.java +++ b/src/com/itmill/toolkit/data/Property.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + /** * <p> * The <code>Property</code> is a simple data object that contains one typed @@ -33,7 +35,7 @@ package com.itmill.toolkit.data; * @VERSION@ * @since 3.0 */ -public interface Property { +public interface Property extends Serializable { /** * Gets the value stored in the Property. The returned object is compatible @@ -91,7 +93,7 @@ public interface Property { * * @return type of the Property */ - public Class getType(); + public Class<?> getType(); /** * Tests if the Property is in read-only mode. In read-only mode calls to @@ -124,14 +126,10 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ReadOnlyException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571702287119410L; - - /** * Constructs a new <code>ReadOnlyException</code> without a detail * message. */ @@ -160,14 +158,10 @@ public interface Property { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class ConversionException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257571706666366008L; - - /** * Constructs a new <code>ConversionException</code> without a detail * message. */ @@ -206,7 +200,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Viewer { + public interface Viewer extends Serializable { /** * Sets the Property that serves as the data source of the viewer. @@ -240,7 +234,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface Editor extends Property.Viewer { + public interface Editor extends Property.Viewer, Serializable { } @@ -255,7 +249,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeEvent { + public interface ValueChangeEvent extends Serializable { /** * Retrieves the Property that has been modified. @@ -274,7 +268,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeListener { + public interface ValueChangeListener extends Serializable { /** * Notifies this listener that the Property's value has changed. @@ -304,7 +298,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ValueChangeNotifier { + public interface ValueChangeNotifier extends Serializable { /** * Registers a new value change listener for this Property. @@ -334,7 +328,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeEvent { + public interface ReadOnlyStatusChangeEvent extends Serializable { /** * Property whose read-only state has changed. @@ -353,7 +347,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeListener { + public interface ReadOnlyStatusChangeListener extends Serializable { /** * Notifies this listener that a Property's read-only status has @@ -385,7 +379,7 @@ public interface Property { * @VERSION@ * @since 3.0 */ - public interface ReadOnlyStatusChangeNotifier { + public interface ReadOnlyStatusChangeNotifier extends Serializable { /** * Registers a new read-only status change listener for this Property. diff --git a/src/com/itmill/toolkit/data/Validatable.java b/src/com/itmill/toolkit/data/Validatable.java index c8f5afb918..e5c074726b 100644 --- a/src/com/itmill/toolkit/data/Validatable.java +++ b/src/com/itmill/toolkit/data/Validatable.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data; +import java.io.Serializable; import java.util.Collection; /** @@ -19,7 +20,7 @@ import java.util.Collection; * @since 3.0 * @see com.itmill.toolkit.data.Validator */ -public interface Validatable { +public interface Validatable extends Serializable { /** * <p> @@ -54,7 +55,7 @@ public interface Validatable { * * @return collection of validators or <code>null</code> */ - public Collection getValidators(); + public Collection<?> getValidators(); /** * <p> diff --git a/src/com/itmill/toolkit/data/Validator.java b/src/com/itmill/toolkit/data/Validator.java index d0094914ed..55626fb040 100644 --- a/src/com/itmill/toolkit/data/Validator.java +++ b/src/com/itmill/toolkit/data/Validator.java @@ -4,6 +4,8 @@ package com.itmill.toolkit.data; +import java.io.Serializable; + import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; @@ -25,7 +27,7 @@ import com.itmill.toolkit.terminal.PaintTarget; * @VERSION@ * @since 3.0 */ -public interface Validator { +public interface Validator extends Serializable { /** * Checks the given value against this validator. If the value is valid this @@ -57,14 +59,10 @@ public interface Validator { * @VERSION@ * @since 3.0 */ + @SuppressWarnings("serial") public class InvalidValueException extends RuntimeException implements ErrorMessage { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3689073941163422257L; - /** Array of validation errors that are causing the problem. */ private InvalidValueException[] causes = null; @@ -171,11 +169,8 @@ public interface Validator { } + @SuppressWarnings("serial") public class EmptyValueException extends Validator.InvalidValueException { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = -4488988853486652602L; public EmptyValueException(String message) { super(message); diff --git a/src/com/itmill/toolkit/data/util/BeanItem.java b/src/com/itmill/toolkit/data/util/BeanItem.java index 65bc57a1b3..0df0ea39e8 100644 --- a/src/com/itmill/toolkit/data/util/BeanItem.java +++ b/src/com/itmill/toolkit/data/util/BeanItem.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class BeanItem extends PropertysetItem { /** @@ -97,7 +98,7 @@ public class BeanItem extends PropertysetItem { * @param propertyIds * id of the property. */ - public BeanItem(Object bean, Collection propertyIds) { + public BeanItem(Object bean, Collection<?> propertyIds) { this.bean = bean; diff --git a/src/com/itmill/toolkit/data/util/BeanItemContainer.java b/src/com/itmill/toolkit/data/util/BeanItemContainer.java index 5ba44568ad..99e42e7e76 100644 --- a/src/com/itmill/toolkit/data/util/BeanItemContainer.java +++ b/src/com/itmill/toolkit/data/util/BeanItemContainer.java @@ -1,6 +1,7 @@ package com.itmill.toolkit.data.util; import java.beans.PropertyDescriptor; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -15,7 +16,6 @@ import java.util.Map; import java.util.Set; import com.itmill.toolkit.data.Container; -import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.Property; import com.itmill.toolkit.data.Container.Filterable; import com.itmill.toolkit.data.Container.Indexed; @@ -36,6 +36,7 @@ import com.itmill.toolkit.data.Property.ValueChangeNotifier; * * @since 5.4 */ +@SuppressWarnings("serial") public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, ItemSetChangeNotifier, ValueChangeListener { // filtered and unfiltered item IDs @@ -45,42 +46,77 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, // internal data model to obtain property IDs etc. private final Class<BT> type; - private final LinkedHashMap<String, PropertyDescriptor> model; + private transient LinkedHashMap<String, PropertyDescriptor> model; private List<ItemSetChangeListener> itemSetChangeListeners; private Set<Filter> filters = new HashSet<Filter>(); - public BeanItemContainer(Class<BT> type) throws InstantiationException, - IllegalAccessException { + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + model = BeanItem.getPropertyDescriptors(type); + } + + /** + * Constructs BeanItemContainer for beans of a given type. + * + * @param type + * the class of beans to be used with this containers. + * @throws IllegalArgumentException + * If the type is null + */ + public BeanItemContainer(Class<BT> type) { + if (type == null) { + throw new IllegalArgumentException( + "The type passed to BeanItemContainer must not be null"); + } this.type = type; model = BeanItem.getPropertyDescriptors(type); } /** - * Constructs BeanItemContainer with given collection of beans in it. + * Constructs BeanItemContainer with given collection of beans in it. The + * collection must not be empty or an IllegalArgument is thrown. * - * @param list + * @param collection * non empty {@link Collection} of beans. - * @throws IllegalAccessException - * @throws InstantiationException + * @throws IllegalArgumentException + * If the collection is null or empty. */ - @SuppressWarnings("unchecked") - public BeanItemContainer(Collection<BT> list) - throws InstantiationException, IllegalAccessException { - type = (Class<BT>) list.iterator().next().getClass(); + public BeanItemContainer(Collection<BT> collection) + throws IllegalArgumentException { + if (collection == null || collection.isEmpty()) { + throw new IllegalArgumentException( + "The collection passed to BeanItemContainer must not be null or empty"); + } + + type = (Class<BT>) collection.iterator().next().getClass(); model = BeanItem.getPropertyDescriptors(type); int i = 0; - for (BT bt : list) { + for (BT bt : collection) { addItemAt(i++, bt); } } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int) + */ public Object addItemAt(int index) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItemAt(int index, Object newItemId) + /** + * Adds new item at given index. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Indexed#addItemAt(int, Object) + */ + public BeanItem addItemAt(int index, Object newItemId) throws UnsupportedOperationException { if (index < 0 || index > size()) { return null; @@ -106,8 +142,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * Id of the new item to be added. * @return Returns new item or null if the operation fails. */ - @SuppressWarnings("unchecked") - private Item addItemAtInternalIndex(int index, Object newItemId) { + private BeanItem addItemAtInternalIndex(int index, Object newItemId) { // Make sure that the Item has not been created yet if (allItems.contains(newItemId)) { return null; @@ -132,7 +167,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object getIdByIndex(int index) { + public BT getIdByIndex(int index) { return list.get(index); } @@ -140,12 +175,25 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return list.indexOf(itemId); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object) + */ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItemAfter(Object previousItemId, Object newItemId) + /** + * Adds new item after the given item. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container.Ordered#addItemAfter(Object, + * Object) + */ + public BeanItem addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // only add if the previous item is visible if (list.contains(previousItemId)) { @@ -156,7 +204,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object firstItemId() { + public BT firstItemId() { if (list.size() > 0) { return list.get(0); } else { @@ -172,7 +220,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return lastItemId() == itemId; } - public Object lastItemId() { + public BT lastItemId() { if (list.size() > 0) { return list.get(list.size() - 1); } else { @@ -180,7 +228,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object nextItemId(Object itemId) { + public BT nextItemId(Object itemId) { int index = list.indexOf(itemId); if (index >= 0 && index < list.size() - 1) { return list.get(index + 1); @@ -190,7 +238,7 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - public Object prevItemId(Object itemId) { + public BT prevItemId(Object itemId) { int index = list.indexOf(itemId); if (index > 0) { return list.get(index - 1); @@ -206,11 +254,34 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, throw new UnsupportedOperationException(); } + /** + * Unsupported operation. + * + * @see com.itmill.toolkit.data.Container#addItem() + */ public Object addItem() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public Item addItem(Object itemId) throws UnsupportedOperationException { + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ + public BeanItem addBean(BT bean) { + return addItem(bean); + } + + /** + * Creates a new Item with the bean into the Container. + * + * The bean is used both as the item contents and as the item identifier. + * + * @see com.itmill.toolkit.data.Container#addItem(Object) + */ + public BeanItem addItem(Object itemId) throws UnsupportedOperationException { if (list.size() > 0) { // add immediately after last visible item int lastIndex = allItems.indexOf(lastItemId()); @@ -229,18 +300,16 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, return beanToItem.get(itemId).getItemProperty(propertyId); } - @SuppressWarnings("unchecked") - public Collection getContainerPropertyIds() { + public Collection<String> getContainerPropertyIds() { return model.keySet(); } - public Item getItem(Object itemId) { + public BeanItem getItem(Object itemId) { return beanToItem.get(itemId); } - @SuppressWarnings("unchecked") - public Collection getItemIds() { - return (Collection) list.clone(); + public Collection<BT> getItemIds() { + return (Collection<BT>) list.clone(); } public Class<?> getType(Object propertyId) { @@ -364,7 +433,6 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, } } - @SuppressWarnings("unchecked") public void addContainerFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix) { if (filters.isEmpty()) { @@ -386,7 +454,6 @@ public class BeanItemContainer<BT> implements Indexed, Sortable, Filterable, * items, and send a notification if the set of visible items changed in any * way. */ - @SuppressWarnings("unchecked") protected void filterAll() { // avoid notification if the filtering had no effect List<BT> originalItems = list; diff --git a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java index 91dd00fc46..2c88c2ab61 100644 --- a/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerHierarchicalWrapper.java @@ -34,6 +34,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerHierarchicalWrapper implements Container.Hierarchical, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java index c9e5736b9a..a57fbb1719 100644 --- a/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java +++ b/src/com/itmill/toolkit/data/util/ContainerOrderedWrapper.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ContainerOrderedWrapper implements Container.Ordered, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier { diff --git a/src/com/itmill/toolkit/data/util/FilesystemContainer.java b/src/com/itmill/toolkit/data/util/FilesystemContainer.java index f1d5273003..03451ad411 100644 --- a/src/com/itmill/toolkit/data/util/FilesystemContainer.java +++ b/src/com/itmill/toolkit/data/util/FilesystemContainer.java @@ -7,6 +7,7 @@ package com.itmill.toolkit.data.util; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +36,7 @@ import com.itmill.toolkit.terminal.Resource; * @author mattitahvonen * */ +@SuppressWarnings("serial") public class FilesystemContainer implements Container.Hierarchical { /** @@ -62,13 +64,13 @@ public class FilesystemContainer implements Container.Hierarchical { */ public static Collection FILE_PROPERTIES; - private static Method FILEITEM_LASTMODIFIED; + private final static Method FILEITEM_LASTMODIFIED; - private static Method FILEITEM_NAME; + private final static Method FILEITEM_NAME; - private static Method FILEITEM_ICON; + private final static Method FILEITEM_ICON; - private static Method FILEITEM_SIZE; + private final static Method FILEITEM_SIZE; static { @@ -741,7 +743,7 @@ public class FilesystemContainer implements Container.Hierarchical { * @VERSION@ * @since 3.0 */ - public class FileExtensionFilter implements FilenameFilter { + public class FileExtensionFilter implements FilenameFilter, Serializable { private final String filter; diff --git a/src/com/itmill/toolkit/data/util/Filter.java b/src/com/itmill/toolkit/data/util/Filter.java index cbb1efae0d..cd31a57b9d 100644 --- a/src/com/itmill/toolkit/data/util/Filter.java +++ b/src/com/itmill/toolkit/data/util/Filter.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.data.util;
+import java.io.Serializable;
+
import com.itmill.toolkit.data.Item;
import com.itmill.toolkit.data.Property;
@@ -9,7 +11,8 @@ import com.itmill.toolkit.data.Property; *
* @since 5.4
*/
-public class Filter {
+@SuppressWarnings("serial")
+public class Filter implements Serializable {
final Object propertyId;
final String filterString;
final boolean ignoreCase;
diff --git a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java index ce46da362a..75ade41e26 100644 --- a/src/com/itmill/toolkit/data/util/HierarchicalContainer.java +++ b/src/com/itmill/toolkit/data/util/HierarchicalContainer.java @@ -22,6 +22,7 @@ import com.itmill.toolkit.data.Item; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class HierarchicalContainer extends IndexedContainer implements Container.Hierarchical { diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java index 0dbe44fc46..e649cace8e 100644 --- a/src/com/itmill/toolkit/data/util/IndexedContainer.java +++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.Serializable; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; @@ -45,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 3.0 */ +@SuppressWarnings("serial") public class IndexedContainer implements Container.Indexed, Container.ItemSetChangeNotifier, Container.PropertySetChangeNotifier, Property.ValueChangeNotifier, Container.Sortable, Comparator, @@ -726,12 +728,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertySetChangeEvent extends EventObject implements - Container.PropertySetChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257002172528079926L; + Container.PropertySetChangeEvent, Serializable { private PropertySetChangeEvent(IndexedContainer source) { super(source); @@ -759,12 +756,8 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ public class ItemSetChangeEvent extends EventObject implements - Container.ItemSetChangeEvent { + Container.ItemSetChangeEvent, Serializable { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3832616279386372147L; private final int addedItemIndex; private ItemSetChangeEvent(IndexedContainer source, int addedItemIndex) { @@ -804,12 +797,7 @@ public class IndexedContainer implements Container.Indexed, * @since 3.0 */ private class PropertyValueChangeEvent extends EventObject implements - Property.ValueChangeEvent { - - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3833749884498359857L; + Property.ValueChangeEvent, Serializable { private PropertyValueChangeEvent(Property source) { super(source); diff --git a/src/com/itmill/toolkit/data/util/MethodProperty.java b/src/com/itmill/toolkit/data/util/MethodProperty.java index 165d54c902..e8f220be79 100644 --- a/src/com/itmill/toolkit/data/util/MethodProperty.java +++ b/src/com/itmill/toolkit/data/util/MethodProperty.java @@ -4,6 +4,7 @@ package com.itmill.toolkit.data.util; +import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -43,18 +44,19 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class MethodProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { /** * The object that includes the property the MethodProperty is bound to. */ - private final Object instance; + private transient Object instance; /** * Argument arrays for the getter and setter methods. */ - private Object[] setArgs, getArgs; + private transient Object[] setArgs, getArgs; /** * Is the MethodProperty read-only? @@ -64,7 +66,7 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, /** * The getter and setter methods. */ - private Method setMethod, getMethod; + private transient Method setMethod, getMethod; /** * Index of the new value in the argument list for the setter method. If the @@ -90,6 +92,59 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, */ private LinkedList valueChangeListeners = null; + /* Special serialization to handle method references */ + private void writeObject(java.io.ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(instance); + out.writeObject(setArgs); + out.writeObject(getArgs); + if (setMethod != null) { + out.writeObject(setMethod.getName()); + out.writeObject(setMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } + if (getMethod != null) { + out.writeObject(getMethod.getName()); + out.writeObject(getMethod.getParameterTypes()); + } else { + out.writeObject(""); + out.writeObject(""); + } + }; + + /* Special serialization to handle method references */ + private void readObject(java.io.ObjectInputStream in) throws IOException, + ClassNotFoundException { + in.defaultReadObject(); + try { + instance = in.readObject(); + setArgs = (Object[]) in.readObject(); + getArgs = (Object[]) in.readObject(); + String name = (String) in.readObject(); + Class<?>[] paramTypes = (Class<?>[]) in.readObject(); + if (name != null && !name.equals("")) { + setMethod = instance.getClass().getMethod(name, paramTypes); + } else { + setMethod = null; + } + name = (String) in.readObject(); + paramTypes = (Class<?>[]) in.readObject(); + if (name != null && !name.equals("")) { + getMethod = instance.getClass().getMethod(name, paramTypes); + } else { + getMethod = null; + } + } catch (SecurityException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } catch (NoSuchMethodException e) { + System.err.println("Internal deserialization error"); + e.printStackTrace(); + } + }; + /** * <p> * Creates a new instance of <code>MethodProperty</code> from a named bean @@ -702,11 +757,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, public class MethodException extends RuntimeException { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3690473623827855153L; - - /** * Cause of the method exception */ private Throwable cause; @@ -763,11 +813,6 @@ public class MethodProperty implements Property, Property.ValueChangeNotifier, implements Property.ReadOnlyStatusChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3258129163305955896L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/ObjectProperty.java b/src/com/itmill/toolkit/data/util/ObjectProperty.java index 1821a815ed..dd31c89606 100644 --- a/src/com/itmill/toolkit/data/util/ObjectProperty.java +++ b/src/com/itmill/toolkit/data/util/ObjectProperty.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class ObjectProperty implements Property, Property.ValueChangeNotifier, Property.ReadOnlyStatusChangeNotifier { @@ -216,11 +217,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, Property.ValueChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3256718468479725873L; - - /** * Constructs a new value change event for this object. * * @param source @@ -253,11 +249,6 @@ public class ObjectProperty implements Property, Property.ValueChangeNotifier, implements Property.ReadOnlyStatusChangeEvent { /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3907208273529616696L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/PropertyFormatter.java b/src/com/itmill/toolkit/data/util/PropertyFormatter.java index c6454a7f47..0b407bdd52 100644 --- a/src/com/itmill/toolkit/data/util/PropertyFormatter.java +++ b/src/com/itmill/toolkit/data/util/PropertyFormatter.java @@ -31,6 +31,7 @@ import com.itmill.toolkit.data.Property; * @author IT Mill Ltd. * @since 5.3.0 */ +@SuppressWarnings("serial") public abstract class PropertyFormatter implements Property, Property.ValueChangeNotifier, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener, @@ -229,11 +230,6 @@ public abstract class PropertyFormatter implements Property, Property.ValueChangeEvent { /** - * - */ - private static final long serialVersionUID = -489631310964258710L; - - /** * Constructs a new value change event for this object. * * @param source @@ -264,11 +260,6 @@ public abstract class PropertyFormatter implements Property, implements Property.ReadOnlyStatusChangeEvent { /** - * - */ - private static final long serialVersionUID = 8329395774911454548L; - - /** * Constructs a new read-only status change event for this object. * * @param source diff --git a/src/com/itmill/toolkit/data/util/PropertysetItem.java b/src/com/itmill/toolkit/data/util/PropertysetItem.java index c6c01743e2..d2d2946d4e 100644 --- a/src/com/itmill/toolkit/data/util/PropertysetItem.java +++ b/src/com/itmill/toolkit/data/util/PropertysetItem.java @@ -25,6 +25,7 @@ import com.itmill.toolkit.data.Property; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, Cloneable { @@ -165,11 +166,6 @@ public class PropertysetItem implements Item, Item.PropertySetChangeNotifier, private class PropertySetChangeEvent extends EventObject implements Item.PropertySetChangeEvent { - /** - * Serial generated by eclipse. - */ - private static final long serialVersionUID = 3257562910590055991L; - private PropertySetChangeEvent(Item source) { super(source); } diff --git a/src/com/itmill/toolkit/data/util/QueryContainer.java b/src/com/itmill/toolkit/data/util/QueryContainer.java index 2c76e58702..2139318e0c 100644 --- a/src/com/itmill/toolkit/data/util/QueryContainer.java +++ b/src/com/itmill/toolkit/data/util/QueryContainer.java @@ -46,6 +46,7 @@ import com.itmill.toolkit.data.Property; * @since 4.0 */ +@SuppressWarnings("serial") public class QueryContainer implements Container, Container.Ordered, Container.Indexed { diff --git a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java index 7f26a87861..cecc63a637 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractStringValidator.java @@ -15,6 +15,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public abstract class AbstractStringValidator extends AbstractValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/AbstractValidator.java b/src/com/itmill/toolkit/data/validator/AbstractValidator.java index 93d6ae41fa..c12ea0d848 100644 --- a/src/com/itmill/toolkit/data/validator/AbstractValidator.java +++ b/src/com/itmill/toolkit/data/validator/AbstractValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public abstract class AbstractValidator implements Validator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/CompositeValidator.java b/src/com/itmill/toolkit/data/validator/CompositeValidator.java index 6aa9d07b99..13266d4ca8 100644 --- a/src/com/itmill/toolkit/data/validator/CompositeValidator.java +++ b/src/com/itmill/toolkit/data/validator/CompositeValidator.java @@ -23,6 +23,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class CompositeValidator extends AbstractValidator { /** diff --git a/src/com/itmill/toolkit/data/validator/DoubleValidator.java b/src/com/itmill/toolkit/data/validator/DoubleValidator.java index 56f537f5e4..9ee4fec65e 100644 --- a/src/com/itmill/toolkit/data/validator/DoubleValidator.java +++ b/src/com/itmill/toolkit/data/validator/DoubleValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class DoubleValidator extends AbstractStringValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/EmailValidator.java b/src/com/itmill/toolkit/data/validator/EmailValidator.java index b5abb4d712..f833d5ca77 100644 --- a/src/com/itmill/toolkit/data/validator/EmailValidator.java +++ b/src/com/itmill/toolkit/data/validator/EmailValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class EmailValidator extends RegexpValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/IntegerValidator.java b/src/com/itmill/toolkit/data/validator/IntegerValidator.java index f48e85943e..48afacf8c8 100644 --- a/src/com/itmill/toolkit/data/validator/IntegerValidator.java +++ b/src/com/itmill/toolkit/data/validator/IntegerValidator.java @@ -10,6 +10,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class IntegerValidator extends AbstractStringValidator {
/**
diff --git a/src/com/itmill/toolkit/data/validator/NullValidator.java b/src/com/itmill/toolkit/data/validator/NullValidator.java index e2038d9017..be2b041bb2 100644 --- a/src/com/itmill/toolkit/data/validator/NullValidator.java +++ b/src/com/itmill/toolkit/data/validator/NullValidator.java @@ -15,6 +15,7 @@ import com.itmill.toolkit.data.Validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class NullValidator implements Validator { private boolean onlyNullAllowed; diff --git a/src/com/itmill/toolkit/data/validator/RegexpValidator.java b/src/com/itmill/toolkit/data/validator/RegexpValidator.java index 56316bea84..eb42a2668a 100644 --- a/src/com/itmill/toolkit/data/validator/RegexpValidator.java +++ b/src/com/itmill/toolkit/data/validator/RegexpValidator.java @@ -21,6 +21,7 @@ import java.util.regex.Pattern; * @VERSION@
* @since 5.4
*/
+@SuppressWarnings("serial")
public class RegexpValidator extends AbstractStringValidator {
private Pattern pattern;
diff --git a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java index e4c28041a7..6105b0e746 100644 --- a/src/com/itmill/toolkit/data/validator/StringLengthValidator.java +++ b/src/com/itmill/toolkit/data/validator/StringLengthValidator.java @@ -13,6 +13,7 @@ package com.itmill.toolkit.data.validator; * @VERSION@ * @since 3.0 */ +@SuppressWarnings("serial") public class StringLengthValidator extends AbstractValidator { private int minLength = -1; |