Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.progeeks.meta
Class DefaultMetaTable  view DefaultMetaTable download DefaultMetaTable.java

java.lang.Object
  extended byorg.progeeks.util.beans.BeanChangeSupport
      extended byorg.progeeks.meta.DefaultMetaTable
All Implemented Interfaces:
MetaTable, org.progeeks.util.beans.StandardBean

public class DefaultMetaTable
extends org.progeeks.util.beans.BeanChangeSupport
implements MetaTable

A default implementation of the MetaTable interface. This meta-table implementation contains an internal list of objects. If these objects are meta-objects then they are access directly. Otherwise, they are wrapped in meta-objects using the meta-kit provided. Optionally a list of property names can be provided or the table will pull the property names from the specified meta-class.

Version:
$Revision: 1.6 $

Nested Class Summary
private  class DefaultMetaTable.MetaObjectListener
          This is the listener that is added to all meta-objects so that any changes are forwarded along to table listeners.
 
Field Summary
private  MetaKit kit
          A reference to the meta-kit we'll use to create new meta-objects when we need to.
private  MetaClass metaClass
          The meta-class that this table is constrained by.
private  DefaultMetaTable.MetaObjectListener objectListener
          The listener that is added to all meta-objects created internally.
private  org.progeeks.util.ObservableList objects
          The original object list.
private  java.lang.String[] properties
          An array of the supported properties.
private  java.util.List wrapperObjects
          Keeps cached version of the meta-objects as they are created.
 
Fields inherited from class org.progeeks.util.beans.BeanChangeSupport
 
Constructor Summary
DefaultMetaTable(java.util.List objects, java.util.List properties, MetaClass metaClass, MetaKit kit)
          Creates a default meta-table that contains the specified list of objects.
DefaultMetaTable(java.util.List objects, java.util.List properties, MetaClass metaClass, MetaKit kit, boolean autoWrap)
          Creates a default meta-table that contains the specified list of objects.
 
Method Summary
 void addObject(java.lang.Object obj)
          Adds the specified object to the list.
 void addPropertyChangeListener(int column, java.beans.PropertyChangeListener l)
          Adds a property change listener that will be notified whenever the specified property changes in any row.
 int getColumnCount()
          Returns the number of columns in the table.
 int getColumnIndex(java.lang.String propertyName)
          Returns the column index of the specified property.
 MetaClass getMetaClass()
          Returns the meta-class associated with this object.
 MetaKit getMetaKit()
          Returns the meta-kit for this meta-object's implementation layer.
 MetaObject getMetaObject(int row)
          Returns the specified row as a meta-object.
 java.lang.Object getProperty(int row, int column)
          Returns the value of the specified property.
 PropertyInfo getPropertyInfo(int column)
          Returns the property info for a given column.
 PropertyMutator getPropertyMutator(int row, int column)
          Returns a mutator for the specified property.
 int getRowCount()
          Returns the number of rows in the table.
 int getRowIndex(MetaObject obj)
          Returns the row index for the specified meta-object.
 boolean hasListeners(int column)
          Returns true if the specified property name has listeners registered.
 void removePropertyChangeListener(int column, java.beans.PropertyChangeListener l)
          Removes the property change listener from a specific property.
protected  void setObjects(java.util.List objects, boolean autoWrap)
           
protected  void setProperties(java.util.List names)
           
 void setProperty(int row, int column, java.lang.Object value)
          Sets the value of the specified property.
 
Methods inherited from class org.progeeks.util.beans.BeanChangeSupport
addPropertyChangeListener, addPropertyChangeListener, clearAllListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, hasListeners, removePropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.progeeks.meta.MetaTable
addPropertyChangeListener, clearAllListeners, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

wrapperObjects

private java.util.List wrapperObjects
Keeps cached version of the meta-objects as they are created. If the original object list contains meta-objects, then this field will be null.


objects

private org.progeeks.util.ObservableList objects
The original object list. This will be the same size as the metaList, or null if the objects are all meta-objects.


properties

private java.lang.String[] properties
An array of the supported properties. Easy to map column to property name this way.


metaClass

private MetaClass metaClass
The meta-class that this table is constrained by.


kit

private MetaKit kit
A reference to the meta-kit we'll use to create new meta-objects when we need to.


objectListener

private DefaultMetaTable.MetaObjectListener objectListener
The listener that is added to all meta-objects created internally. This passes on the change events to table listeners.

Constructor Detail

DefaultMetaTable

public DefaultMetaTable(java.util.List objects,
                        java.util.List properties,
                        MetaClass metaClass,
                        MetaKit kit)
Creates a default meta-table that contains the specified list of objects.


DefaultMetaTable

public DefaultMetaTable(java.util.List objects,
                        java.util.List properties,
                        MetaClass metaClass,
                        MetaKit kit,
                        boolean autoWrap)
Creates a default meta-table that contains the specified list of objects.

Method Detail

setObjects

protected void setObjects(java.util.List objects,
                          boolean autoWrap)

setProperties

protected void setProperties(java.util.List names)

addObject

public void addObject(java.lang.Object obj)
Adds the specified object to the list. If an object is a meta-object then it will be directly added to the meta-object list. Otherwise, a meta-object will be created.


getMetaObject

public MetaObject getMetaObject(int row)
Returns the specified row as a meta-object.

Specified by:
getMetaObject in interface MetaTable

getRowIndex

public int getRowIndex(MetaObject obj)
Returns the row index for the specified meta-object. This is an optional operation and may throw an UnsupportedOpreationException.

Specified by:
getRowIndex in interface MetaTable

getPropertyInfo

public PropertyInfo getPropertyInfo(int column)
Returns the property info for a given column.

Specified by:
getPropertyInfo in interface MetaTable

getColumnIndex

public int getColumnIndex(java.lang.String propertyName)
Returns the column index of the specified property.

Specified by:
getColumnIndex in interface MetaTable

getRowCount

public int getRowCount()
Returns the number of rows in the table.

Specified by:
getRowCount in interface MetaTable

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.

Specified by:
getColumnCount in interface MetaTable

setProperty

public void setProperty(int row,
                        int column,
                        java.lang.Object value)
Sets the value of the specified property.

Specified by:
setProperty in interface MetaTable

getProperty

public java.lang.Object getProperty(int row,
                                    int column)
Returns the value of the specified property.

Specified by:
getProperty in interface MetaTable

getPropertyMutator

public PropertyMutator getPropertyMutator(int row,
                                          int column)
Returns a mutator for the specified property.

Specified by:
getPropertyMutator in interface MetaTable

getMetaClass

public MetaClass getMetaClass()
Returns the meta-class associated with this object.

Specified by:
getMetaClass in interface MetaTable

getMetaKit

public MetaKit getMetaKit()
Returns the meta-kit for this meta-object's implementation layer.

Specified by:
getMetaKit in interface MetaTable

addPropertyChangeListener

public void addPropertyChangeListener(int column,
                                      java.beans.PropertyChangeListener l)
Adds a property change listener that will be notified whenever the specified property changes in any row.

Specified by:
addPropertyChangeListener in interface MetaTable

hasListeners

public boolean hasListeners(int column)
Returns true if the specified property name has listeners registered.

Specified by:
hasListeners in interface MetaTable

removePropertyChangeListener

public void removePropertyChangeListener(int column,
                                         java.beans.PropertyChangeListener l)
Removes the property change listener from a specific property.

Specified by:
removePropertyChangeListener in interface MetaTable