org.kalmeo.kuix.core.model
Class DataProvider

java.lang.Object
  extended by org.kalmeo.kuix.core.model.DataProvider

public class DataProvider
extends java.lang.Object

This class represent the base object of the Kuix data model.
A DataProvider help you to organize data model to interact with widgets.
You can customize returns value by overriding the getUserDefinedValue function.
Since 1.0.1, you can create a tree of dataproviders by adding dataproviders as slave of an other. in this case, the getValue function could returns a value from the dataprovider itself if it exists of from its slaves.
dispatchUpdateEvent and dispatchItemsUpdateEvent methods invoke rescursivly each dataprovider's masters.

Author:
bbeaulant

Field Summary
static byte ADD_AFTER_MODEL_UPDATE_EVENT_TYPE
           
static byte ADD_BEFORE_MODEL_UPDATE_EVENT_TYPE
           
static byte ADD_MODEL_UPDATE_EVENT_TYPE
           
static byte CLEAR_MODEL_UPDATE_EVENT_TYPE
           
static byte FILTER_MODEL_UPDATE_EVENT_TYPE
           
static byte REMOVE_MODEL_UPDATE_EVENT_TYPE
           
static byte SORT_MODEL_UPDATE_EVENT_TYPE
           
 
Constructor Summary
DataProvider()
           
 
Method Summary
 int addItem(java.lang.String property, DataProvider item)
          Add the item to the property items list.
 int addItem(java.lang.String property, DataProvider item, DataProvider referenceItem, boolean after)
          Add the item to the property items list by placing it after or before the referenceItem according to the after parameter.
 void addSlave(DataProvider slaveDataProvider)
          Add a slave DataProvider to this DataProvider.
 void bind(Widget widget)
          Bind the widget to this DataProvider.
 int compareTo(LinkedListItem item, int flag)
           
 boolean contains(java.lang.String property, DataProvider item)
          Search a LinkedListItem in LinkedList and return true if it's in.
 int countItemValues(java.lang.String property)
          Returns the count of items assocayed with the specified property.
protected  void dispatchItemsUpdateEvent(byte type, java.lang.String property, DataProvider item, LinkedListEnumeration itemsEnumeration)
          Dispatch an items update event for a specific property to all binded widgets.
protected  void dispatchUpdateEvent(java.lang.String property)
          Dispatch an update event for a specific property to all binded widgets.
 LinkedListEnumeration enumerateItems(java.lang.String property, boolean useFilter)
          Returns the LinkedListEnumeration instance or null if no value is associated with this property.
 DataProvider getFirstItem(java.lang.String property)
          Returns the first DataProvider item of the property items list or null if the list is empty or doesn't exists.
 LinkedList getItemsValue(java.lang.String property)
          Returns the property associated items value, or null if the property has no value or value is not a LinkedList.
 DataProvider getLastItem(java.lang.String property)
          Returns the last DataProvider item of the property items list or null if the list is empty or doesn't exists.
 LinkedListItem getNext()
           
 LinkedListItem getPrevious()
           
 java.lang.String getStringValue(java.lang.String property)
          Returns the property associated string value, or null if the property has no value or value is not a string.
protected  java.lang.Object getUserDefinedValue(java.lang.String property)
          Returns the user defined value corresponding the given property.
 java.lang.Object getValue(java.lang.String property)
          Returns the value (user defined values and items values) corresponding the given property.
 void removeAllItems(java.lang.String property)
          Remove all items from the property items list.
 void removeAllSlaves()
          Remove all DataProvider slaves of this instance.
 void removeFromMaster(DataProvider masterDataProvider)
          Remove this DataProvider from a specific master.
 void removeFromMasters()
          Remove this DataProvider from its masters.
 int removeItem(java.lang.String property, DataProvider item)
          Remove the item from the property items list.
 void removeSlave(DataProvider slaveDataProvider)
          Remove the slaveDataProvider instance from this DataProvider slaves.
 void setItemsFilter(java.lang.String property, Filter filter)
          Filter property items list.
 void setNext(LinkedListItem next)
           
 void setPrevious(LinkedListItem previous)
           
 void sortItems(java.lang.String property, int flag)
          Sort property items list.
 void unbind(Widget widget)
          Unbind the widget from this DataProvider.
 void unbindAll()
          Unbind all widgets from this DataProvider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADD_MODEL_UPDATE_EVENT_TYPE

public static final byte ADD_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

ADD_BEFORE_MODEL_UPDATE_EVENT_TYPE

public static final byte ADD_BEFORE_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

ADD_AFTER_MODEL_UPDATE_EVENT_TYPE

public static final byte ADD_AFTER_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

REMOVE_MODEL_UPDATE_EVENT_TYPE

public static final byte REMOVE_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

SORT_MODEL_UPDATE_EVENT_TYPE

public static final byte SORT_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

FILTER_MODEL_UPDATE_EVENT_TYPE

public static final byte FILTER_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values

CLEAR_MODEL_UPDATE_EVENT_TYPE

public static final byte CLEAR_MODEL_UPDATE_EVENT_TYPE
See Also:
Constant Field Values
Constructor Detail

DataProvider

public DataProvider()
Method Detail

getNext

public LinkedListItem getNext()

getPrevious

public LinkedListItem getPrevious()

setNext

public void setNext(LinkedListItem next)

setPrevious

public void setPrevious(LinkedListItem previous)

addSlave

public void addSlave(DataProvider slaveDataProvider)
Add a slave DataProvider to this DataProvider.

Parameters:
slaveDataProvider -
Since:
1.0.1

removeSlave

public void removeSlave(DataProvider slaveDataProvider)
Remove the slaveDataProvider instance from this DataProvider slaves.

Parameters:
slaveDataProvider -
Since:
1.0.1

removeAllSlaves

public void removeAllSlaves()
Remove all DataProvider slaves of this instance.

Since:
1.0.1

removeFromMaster

public void removeFromMaster(DataProvider masterDataProvider)
Remove this DataProvider from a specific master.

Parameters:
masterDataProvider -
Since:
1.0.1

removeFromMasters

public void removeFromMasters()
Remove this DataProvider from its masters.

Since:
1.0.1

getValue

public final java.lang.Object getValue(java.lang.String property)
Returns the value (user defined values and items values) corresponding the given property.

Parameters:
property -
Returns:
the value associated with the given property.

getUserDefinedValue

protected java.lang.Object getUserDefinedValue(java.lang.String property)
Returns the user defined value corresponding the given property.
Override the method to returns your customs values.

Returns:
the user defined value associated with the given property.

getStringValue

public java.lang.String getStringValue(java.lang.String property)
Returns the property associated string value, or null if the property has no value or value is not a string.

Parameters:
property -
Returns:
the string value, or null if the property has no value or value is not a string.

getItemsValue

public LinkedList getItemsValue(java.lang.String property)
Returns the property associated items value, or null if the property has no value or value is not a LinkedList.
This method defer from getValue because it returns a unique LinkedList instance by property instead of a new LinkedListEnumeration each time the method is called.

Parameters:
property -
Returns:
the LinkedList value, or null if the property has no value or value is not a LinkedList.

countItemValues

public int countItemValues(java.lang.String property)
Returns the count of items assocayed with the specified property.

Parameters:
property -
Returns:
the count of items assocayed with the specified property

getFirstItem

public DataProvider getFirstItem(java.lang.String property)
Returns the first DataProvider item of the property items list or null if the list is empty or doesn't exists.

Parameters:
property -
Returns:
the first DataProvider item

getLastItem

public DataProvider getLastItem(java.lang.String property)
Returns the last DataProvider item of the property items list or null if the list is empty or doesn't exists.

Parameters:
property -
Returns:
the last DataProvider item

enumerateItems

public LinkedListEnumeration enumerateItems(java.lang.String property,
                                            boolean useFilter)
Returns the LinkedListEnumeration instance or null if no value is associated with this property. If a filter is associated with this property and useFilter is set to true, the enumeration use it.

Parameters:
property -
useFilter -
Returns:
the LinkedListEnumeration instance or null if no value is associated with this property.

addItem

public int addItem(java.lang.String property,
                   DataProvider item)
Add the item to the property items list.

Parameters:
property -
item -
Returns:
the new items linkedList size or -1 if adding is faild.

addItem

public int addItem(java.lang.String property,
                   DataProvider item,
                   DataProvider referenceItem,
                   boolean after)
Add the item to the property items list by placing it after or before the referenceItem according to the after parameter. If item is null nothing append and -1 is returned.

Parameters:
property -
item -
referenceItem -
after -
Returns:
the new items linkedList size or -1 if adding is faild.

removeItem

public int removeItem(java.lang.String property,
                      DataProvider item)
Remove the item from the property items list.

Parameters:
property -
item -
Returns:
the new items linkedList size or -1 if removing is faild.

removeAllItems

public void removeAllItems(java.lang.String property)
Remove all items from the property items list.

Parameters:
property -

contains

public boolean contains(java.lang.String property,
                        DataProvider item)
Search a LinkedListItem in LinkedList and return true if it's in. The value linked to property must be a LinkedList.

Parameters:
property - the property where item may be found
item - the LinkedListItem to search
Returns:
true if item exist in LinkedList property, false else.

sortItems

public void sortItems(java.lang.String property,
                      int flag)
Sort property items list.

Parameters:
property -
flag -

setItemsFilter

public void setItemsFilter(java.lang.String property,
                           Filter filter)
Filter property items list.

Parameters:
property -
filter - the Filter to apply to the enumeration. Set it null to retrieve all items of the enumeration

bind

public void bind(Widget widget)
Bind the widget to this DataProvider.

Parameters:
widget -

unbind

public void unbind(Widget widget)
Unbind the widget from this DataProvider.

Parameters:
widget -

unbindAll

public void unbindAll()
Unbind all widgets from this DataProvider.


dispatchUpdateEvent

protected void dispatchUpdateEvent(java.lang.String property)
Dispatch an update event for a specific property to all binded widgets.

Parameters:
property -

dispatchItemsUpdateEvent

protected void dispatchItemsUpdateEvent(byte type,
                                        java.lang.String property,
                                        DataProvider item,
                                        LinkedListEnumeration itemsEnumeration)
Dispatch an items update event for a specific property to all binded widgets.

Parameters:
type -
property -
item -
itemsEnumeration -

compareTo

public int compareTo(LinkedListItem item,
                     int flag)


Copyright © 2007-2008 Kalmeo. All Rights Reserved.