dsto.dfc.databeans
Class DataObjectView

java.lang.Object
  extended by dsto.dfc.databeans.AbstractDataObject
      extended by dsto.dfc.databeans.DataObjectView
All Implemented Interfaces:
IDataObject, IDataObjectChildListener, PropertyListener, Disposable, Cloneable, Iterable, EventListener

public class DataObjectView
extends AbstractDataObject
implements Disposable, PropertyListener, Iterable

Creates a dynamically sortable, filterable list view of a data object. The list view is itself a data object: The properties of this object are integer indexes. The source object is usually a collection type object such as a registry but can be any IDataObject.

Author:
Matthew Phillips
See Also:
DataObjectFilter

Field Summary
 
Fields inherited from class dsto.dfc.databeans.AbstractDataObject
listeners
 
Fields inherited from interface dsto.dfc.databeans.IDataObject
OVERRIDE, PERSISTENT, PERSISTENT_OVERRIDE, TRANSIENT, TRANSIENT_OVERRIDE
 
Constructor Summary
DataObjectView(IDataObject source)
           
DataObjectView(IDataObject source, IFilter filter)
           
DataObjectView(IDataObject source, IFilter filter, ISorter sorter)
          Create a new instance.
DataObjectView(IDataObject source, IFilterSorter filterSorter)
          Shortcut to create a new instance with a combined filter/sorter.
DataObjectView(IDataObject source, ISorter sorter)
           
 
Method Summary
 void childPropertyChanged(Object notUsed, PropertyEvent e)
          Invoked when a child property value has changed.
static
<T> ISorter<T>
defaultSorter()
          Create a default sorter.
 void dispose()
          Dispose of the object (unregister listeners, close open resources etc).
 IFilter getFilter()
           
 TypeInfo getTypeInfo()
          Get the optional type information for this object.
 Object getValue(int index)
           
 Object getValue(Object name)
          Get the value of a given property.
 int indexOf(Object value)
          The sorted index of value in the view (-1 if value is not shown in the view).
 boolean isTransient(Object name)
          Test a property is transient (ie will not be preserved if the object is saved).
 Iterator iterator()
           
 Iterator propertyIterator()
          Get an iterator that scans over all currently defined properties.
 void propertyValueChanged(PropertyEvent e)
           
 void refilter()
          Force the view to refilter its contents.
 void setFilter(IFilter newFilter)
          Set the view filter.
 void setValue(Object name, Object value, int mode)
          Set the value of a given property.
 int size()
           
 
Methods inherited from class dsto.dfc.databeans.AbstractDataObject
addFirstPropertyListener, addPropertyListener, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, firePropertyChangedEvent, getBeanValue, getBooleanValue, getBooleanValue, getCharValue, getCharValue, getDoubleValue, getDoubleValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getObjectValue, getPropertyListeners, getShortValue, getStringValue, registerValue, removePropertyListener, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, shallowClone, toString, unregisterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataObjectView

public DataObjectView(IDataObject source)

DataObjectView

public DataObjectView(IDataObject source,
                      IFilterSorter filterSorter)
Shortcut to create a new instance with a combined filter/sorter.

Parameters:
source - The source object to read from.
filterSorter - Combined filter sorter.

DataObjectView

public DataObjectView(IDataObject source,
                      IFilter filter)

DataObjectView

public DataObjectView(IDataObject source,
                      ISorter sorter)

DataObjectView

public DataObjectView(IDataObject source,
                      IFilter filter,
                      ISorter sorter)
Create a new instance.

Parameters:
source - The source object to read from.
filter - Any values of source that are included by the fliter appear in this view. May be null for no filtering.
sorter - Values in the view are kept sorted using this. May be null for default sorting.
Method Detail

defaultSorter

public static final <T> ISorter<T> defaultSorter()
Create a default sorter.

See Also:
ISorter.DEFAULT_SORTER

dispose

public void dispose()
Description copied from interface: Disposable
Dispose of the object (unregister listeners, close open resources etc). It should be safe to call this method more than once. Note for beans that support client event listeners: if there are listeners registered when this is called, this method should do nothing.

Specified by:
dispose in interface Disposable

setFilter

public void setFilter(IFilter newFilter)
Set the view filter.


getFilter

public IFilter getFilter()

refilter

public void refilter()
Force the view to refilter its contents.


propertyValueChanged

public void propertyValueChanged(PropertyEvent e)
Specified by:
propertyValueChanged in interface PropertyListener

childPropertyChanged

public void childPropertyChanged(Object notUsed,
                                 PropertyEvent e)
Description copied from class: AbstractDataObject
Invoked when a child property value has changed.

Specified by:
childPropertyChanged in interface IDataObjectChildListener
Overrides:
childPropertyChanged in class AbstractDataObject
Parameters:
notUsed - The property name on this object that the child is accessible by.
e - The change event from the child.
See Also:
AbstractDataObject.registerValue(Object, Object)

getTypeInfo

public TypeInfo getTypeInfo()
Description copied from interface: IDataObject
Get the optional type information for this object. If the object has none, this will be null.

Specified by:
getTypeInfo in interface IDataObject
Specified by:
getTypeInfo in class AbstractDataObject
See Also:
TypeRegistry

setValue

public void setValue(Object name,
                     Object value,
                     int mode)
Description copied from interface: IDataObject
Set the value of a given property. If the object supports it, a property change event should be emitted.

Specified by:
setValue in interface IDataObject
Specified by:
setValue in class AbstractDataObject
Parameters:
name - A property name.
value - The new value. On most objects using null removes the property.
mode - The mode for the value. This is a bitwise OR of TRANSIENT and/or OVERRIDE. Using TRANSIENT specifies the value is to be marked transient (ie isTransient (name) will return true). Not all data object implementations support dynamic transience. OVERRIDE must be set if an existing value is to be overwritten: if not set and a value is already defined, then nothing is changed. The IDataObject.setValue (name, value) call corresponds to IDataBean.setValue (name, value, OVERRIDE).
See Also:
IDataObject.setValue(Object, Object)

getValue

public Object getValue(Object name)
Description copied from interface: IDataObject
Get the value of a given property.

Specified by:
getValue in interface IDataObject
Parameters:
name - The property "name" (may be any object).
Returns:
the value of a given property or null if the property is not defined.
See Also:
IDataObject.setValue(Object, Object), IDataObject.propertyIterator()

getValue

public Object getValue(int index)

isTransient

public boolean isTransient(Object name)
Description copied from interface: IDataObject
Test a property is transient (ie will not be preserved if the object is saved).

Specified by:
isTransient in interface IDataObject
Parameters:
name - The property name.
Returns:
boolean True if the property is transient.

propertyIterator

public Iterator propertyIterator()
Description copied from interface: IDataObject
Get an iterator that scans over all currently defined properties.

Specified by:
propertyIterator in interface IDataObject
Returns:
An iterator that yields all defined property values (ie that would get a non-null result from IDataObject.getValue(Object)).
See Also:
IDataObject.getValue(Object), PropertyValueIterator

size

public int size()

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable

indexOf

public int indexOf(Object value)
The sorted index of value in the view (-1 if value is not shown in the view).



Copyright © 2008 Commonwealth of Australia