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

Quick Search    Search Deep

ulu.view
Class ViewImpl  view ViewImpl download ViewImpl.java

java.lang.Object
  extended byulu.view.ItemImpl
      extended byulu.view.ViewImpl
All Implemented Interfaces:
ContentSource, Handler, Invokable, Item, java.util.Observer, ulu.view.ui.Pager, Propertied, Referrer, Searchable, java.io.Serializable, Sortable, Typed, UContained, UContainer, View

public class ViewImpl
extends ItemImpl
implements View, ulu.view.ui.Pager

generic implementation of ulu.view.View interface

refactored April 2002


Field Summary
protected  boolean cached
          flag used to denote whether a lazy, caching view has populated itself
protected  boolean caching
          denotes whether a lazy component can cache its results.
 boolean CaseSensitiveNames
          if false, hash all items by lower-case names for search purposes, but will preserve case of the name property (e.g.
(package private)  ItemFilter filt
          filter operating on this view
(package private)  boolean filtered
          flag denoting whether current filter has been applied (and visItems cache is therefore up to date)
(package private)  java.util.Vector items
          stored items in this view, held as a Vector rather than a Hashtable because the latter won't guarantee a correct ordering of items that can be used for returning enumerations of a paged subsection.
protected  boolean lazy
          denotes whether container ought to be populated at creation, or only as needed
(package private)  java.util.Vector listeners
          list of listeners to this item
(package private)  java.lang.Object pagemarker
          page marker object used to denote top of current page.
 ulu.view.ui.Pager pager
          pager to delegate to
 boolean passive
          By default, a View won't generate events, but assumes the back-end is passively-recieving requests to update from the UI client.
(package private)  java.util.Vector visItems
          cache of items currently visible through filter, changed only when the filter changes.
 
Fields inherited from class ulu.view.ItemImpl
changes, defmeth, methods, PROP_REFSTRING, props, reference, sealed, types, useScrap
 
Fields inherited from interface ulu.view.Item
METHOD_ADD_TO_SCRAPBOOK
 
Fields inherited from interface ulu.view.UContained
PROP_PARENT
 
Fields inherited from interface ulu.view.Propertied
PROP_DISPLAY_LOD, PROP_NAME
 
Fields inherited from interface ulu.view.Typed
PROP_TYPE
 
Fields inherited from interface ulu.view.ContentSource
PROP_CONTENT_URL
 
Fields inherited from interface ulu.view.UContainer
METHOD_OPEN, METHOD_REFRESH, PROP_COUNT, PROP_DEFAULT_ITEM_PROPS
 
Fields inherited from interface ulu.view.ui.Pager
DEFAULT_PAGE_LENGTH, METHOD_NAME_BACK, METHOD_NAME_GOTO, METHOD_NAME_NEXT
 
Constructor Summary
ViewImpl()
          no-arg constructor required for ItemFactory
ViewImpl(java.lang.String name)
          constructor will add an 'open' method as well as the name property.
ViewImpl(java.lang.String name, boolean lazy)
           The constructor will add an 'open' and a 'refresh' method as well as the name property.
 
Method Summary
 boolean addChild(UContained uc, boolean update)
          generic wrapper to conform to UContainer interface
 void addDefaultMethods()
          add default methods for opening and refreshing container.
 boolean addItem(Item it, boolean update)
          (attempt to) add an item to view - success status returned.
 void addListener(UEventListener listener)
          add a listener
 boolean addObject(java.lang.String name, java.lang.Object obj)
          add an arbitrary object to this view, using the ItemFactory system to wrap it up as an Item.
 boolean addObject(java.lang.String name, java.lang.Object obj, boolean update)
          add an arbitrary object to this view, using the ItemFactory system to wrap it up as an Item
 boolean back()
          visit the previous page - returns true if possible (should check isReversible() before offering the user a hook to this method - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method
 boolean clear()
          remove all items from the view
 ulu.view.ui.Pager createPager()
          factory method for creating a pager - override if custom type required
 void filter()
          filter all items in the view using current filters
(package private)  java.lang.Object findPageMarker()
          find object marking top of page
 void fireEvent(UEvent ev)
          generic wrapper for firing any ViewEvent
 void fireRedirectEvent(View v)
          fire a redirect update event, pointing listeners towards a different view
static void fireRedirectEvent(View from, View to)
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
 void fireUpdateEvent()
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
 void fireUpdateEvent(int type)
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
 void fireUpdateEvent(int type, Item[] its)
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
 void fireUpdateEvent(int type, Item[] its, java.lang.String[] props)
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
static void fireUpdateEvent(View v)
          more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.
 UContained getChild(java.lang.String name)
          wrapper to satify the more generic Container interface
 int getCount()
          count number of visible items in the current view
 ItemFilter getFilter()
          get a filter for this view
 Item getItem(java.lang.String name)
          retrieve a contained item by name
 int getPageLength()
          get the current page length by delegating - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() metho
 int getPageNo()
          get the current page number - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method
 ulu.view.ui.Pager getPager()
          get the pager for this view
 java.lang.Class getSearchClass()
          get a Search implementation that operates on this type of object
 java.lang.Class getSortClass()
          get a Sorter implementation that operates on this type of object
 UContainer getSource()
          get the Viewable being paged
 int getTotalLength()
          get the total length of the list being paged; in some cases this will be known in advance, in others not.
 java.lang.Object invoke(UMethod u)
          implementation of Handler - this is the callback point for an invoked method.
 java.lang.Object invokeSpecials(UMethod u)
          invoke any implementation-specific methods here
 boolean isAutoFill()
          specifies whether the view will populate its contents automatically on startup.
static boolean isPagerMethod(UMethod u)
          convenience method for identifying whether to delegate method calls to the Pager - can be overridden if using bespoke pagers with extra functionality, although a Pager-defined flag that can be set in the method would be preferable really
 boolean isReversible()
          say whether the list can be navigated in both directions, or is simply a one-way traversal system (e.g.
 java.util.Enumeration items()
          list contents of this viewable object
 java.util.Enumeration list(java.util.Vector allitems)
          list all items from the given Vector that are on the current page
 boolean next()
          visit the next page - returns true if possible - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method
 java.lang.String pageDescrip()
          get a short message describing the page number - will give a total if available
 void populate()
          override this method to talk to the real back-end - the filesystem, jini network, database, whatever...
 boolean removeChild(UContained uc, boolean update)
          generic wrapper to conform to UContainer interface
 boolean removeItem(Item it, boolean update)
          (attempt to) remove an item from view - success status returned.
 void removeListener(UEventListener listener)
          remove a listener
 boolean removeObject(java.lang.Object obj, boolean update)
          attempt to remove any item from the view that has a reference object matching the one passed here
 void setDefProps(java.lang.String[] defprops)
          convenience method for setting default properties
 void setFilter(ItemFilter f)
          set a Filter for this view
 void setPageLength(int i)
          set the current page length - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() metho
 void setPageNo(int i)
          set the current page number - only allowed if isReversible() returns true - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method
 void setSource(UContainer uc)
          set the Viewable being paged - always itself, so a null implementation given here
 java.util.Vector visibleItems()
          apply the current filters if needs be and return a list of filtered items
 
Methods inherited from class ulu.view.ItemImpl
addJAFMethods, addMethod, addProp, addProp, addPropertyChangeListener, clearMethods, clearProps, getContent, getDefaultMethod, getMethod, getName, getParent, getParentView, getProp, getReference, getScrapbook, getType, inferTypeByClass, methods, properties, removeMethod, removeProp, removePropertyChangeListener, seal, setDefaultMethod, setName, setParent, setParentView, setReference, setRefImpl, setRefString, setType, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ulu.view.Item
getParentView, setParentView
 
Methods inherited from interface ulu.view.UContained
getParent, setParent
 
Methods inherited from interface ulu.view.Propertied
addProp, clearProps, getName, getProp, properties, removeProp, setName
 
Methods inherited from interface ulu.view.Invokable
addMethod, clearMethods, getDefaultMethod, getMethod, methods, removeMethod, setDefaultMethod
 
Methods inherited from interface ulu.view.Referrer
getReference, setReference
 
Methods inherited from interface ulu.view.Typed
getType, setType
 
Methods inherited from interface ulu.view.ContentSource
getContent
 

Field Detail

lazy

protected boolean lazy
denotes whether container ought to be populated at creation, or only as needed


caching

protected boolean caching
denotes whether a lazy component can cache its results. (i.e. retain the same items after items() has been called the first time), or whether it needs to call populate() each time items is called. If the view is not lazy, then caching makes no difference


cached

protected boolean cached
flag used to denote whether a lazy, caching view has populated itself


items

java.util.Vector items
stored items in this view, held as a Vector rather than a Hashtable because the latter won't guarantee a correct ordering of items that can be used for returning enumerations of a paged subsection. The downside of this (and the advantage of hashtables) is that lookup by name is slow in a Vector. This default implementation is not designed for high performance; where that's required, use a native implementation for that container instead


CaseSensitiveNames

public boolean CaseSensitiveNames
if false, hash all items by lower-case names for search purposes, but will preserve case of the name property (e.g. for display)


passive

public boolean passive
By default, a View won't generate events, but assumes the back-end is passively-recieving requests to update from the UI client. In some cases, we will want to actively push updates and other events from middle|back-end to client (e.g. a mail-watcher or instant messenger), so provide the mechanisms to do so here


listeners

java.util.Vector listeners
list of listeners to this item


pager

public ulu.view.ui.Pager pager
pager to delegate to


filt

ItemFilter filt
filter operating on this view


visItems

java.util.Vector visItems
cache of items currently visible through filter, changed only when the filter changes. This cached set is fed to the pager when altering its settings


filtered

boolean filtered
flag denoting whether current filter has been applied (and visItems cache is therefore up to date)


pagemarker

java.lang.Object pagemarker
page marker object used to denote top of current page. A numerical top of page index as used by the standard Pager doesn't work because filtering may change the position of the same item. This way if we refilter and the current top-pof-page is not filtered out, that item will stay at top of page, but page number may alter.

Constructor Detail

ViewImpl

public ViewImpl()
no-arg constructor required for ItemFactory


ViewImpl

public ViewImpl(java.lang.String name)
constructor will add an 'open' method as well as the name property. If no lazy option is given, will default to true


ViewImpl

public ViewImpl(java.lang.String name,
                boolean lazy)

The constructor will add an 'open' and a 'refresh' method as well as the name property.

Method Detail

addDefaultMethods

public void addDefaultMethods()
add default methods for opening and refreshing container. These will always be restored after a call to clearMethods(), so may be useful to override this method in some cases

Overrides:
addDefaultMethods in class ItemImpl

setDefProps

public void setDefProps(java.lang.String[] defprops)
convenience method for setting default properties


populate

public void populate()
override this method to talk to the real back-end - the filesystem, jini network, database, whatever...


invoke

public java.lang.Object invoke(UMethod u)
                        throws java.lang.Exception

implementation of Handler - this is the callback point for an invoked method. The default implementation here handles the ubiquitous open() and refresh() methods of the View, so subclasses adding their own handler code should call the super.invoke() at some point in order to preserve this important functionality

Specified by:
invoke in interface Handler
Overrides:
invoke in class ItemImpl

isPagerMethod

public static boolean isPagerMethod(UMethod u)

convenience method for identifying whether to delegate method calls to the Pager - can be overridden if using bespoke pagers with extra functionality, although a Pager-defined flag that can be set in the method would be preferable really


invokeSpecials

public java.lang.Object invokeSpecials(UMethod u)
                                throws java.lang.Exception
invoke any implementation-specific methods here


getCount

public int getCount()
count number of visible items in the current view

Specified by:
getCount in interface UContainer

items

public java.util.Enumeration items()
list contents of this viewable object

Specified by:
items in interface UContainer

getChild

public UContained getChild(java.lang.String name)
wrapper to satify the more generic Container interface

Specified by:
getChild in interface UContainer

getItem

public Item getItem(java.lang.String name)
retrieve a contained item by name

Specified by:
getItem in interface View

addChild

public boolean addChild(UContained uc,
                        boolean update)
generic wrapper to conform to UContainer interface

Specified by:
addChild in interface UContainer

addItem

public boolean addItem(Item it,
                       boolean update)
(attempt to) add an item to view - success status returned. The update flag indicates whether to inform the client UI of the change (may be more efficient not to when deleting or adding many items sequentially)

Specified by:
addItem in interface View

addObject

public boolean addObject(java.lang.String name,
                         java.lang.Object obj)
add an arbitrary object to this view, using the ItemFactory system to wrap it up as an Item. Viewers of the container are notified immediately of the change


addObject

public boolean addObject(java.lang.String name,
                         java.lang.Object obj,
                         boolean update)
add an arbitrary object to this view, using the ItemFactory system to wrap it up as an Item


removeChild

public boolean removeChild(UContained uc,
                           boolean update)
generic wrapper to conform to UContainer interface

Specified by:
removeChild in interface UContainer

removeItem

public boolean removeItem(Item it,
                          boolean update)
(attempt to) remove an item from view - success status returned. The update flag indicates whether to inform the client UI of the change (may be more efficient not to when deleting or adding many items sequentially)

Specified by:
removeItem in interface View

removeObject

public boolean removeObject(java.lang.Object obj,
                            boolean update)
attempt to remove any item from the view that has a reference object matching the one passed here


clear

public boolean clear()
remove all items from the view

Specified by:
clear in interface UContainer

addListener

public void addListener(UEventListener listener)
add a listener

Specified by:
addListener in interface View

removeListener

public void removeListener(UEventListener listener)
remove a listener

Specified by:
removeListener in interface View

fireEvent

public void fireEvent(UEvent ev)
generic wrapper for firing any ViewEvent

Specified by:
fireEvent in interface View

fireUpdateEvent

public void fireUpdateEvent()
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.


fireUpdateEvent

public void fireUpdateEvent(int type)
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.


fireUpdateEvent

public void fireUpdateEvent(int type,
                            Item[] its)
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.


fireUpdateEvent

public void fireUpdateEvent(int type,
                            Item[] its,
                            java.lang.String[] props)
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc.


fireRedirectEvent

public void fireRedirectEvent(View v)
fire a redirect update event, pointing listeners towards a different view


fireUpdateEvent

public static void fireUpdateEvent(View v)
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc. Note that this is statically declared, hence will work with all Views, not just those descended from ViewImpl


fireRedirectEvent

public static void fireRedirectEvent(View from,
                                     View to)
more specific wrapper for firing update events, specifying the type of update and the item(s) affected, etc. Note that this is statically declared, hence will work with all Views, not just those descended from ViewImpl


isAutoFill

public boolean isAutoFill()
specifies whether the view will populate its contents automatically on startup. This is true of most views. This information is required by the persistence mechanism, which will only write child items to a persistence store if the view cannot automatically populate itself at startup


getPager

public ulu.view.ui.Pager getPager()
get the pager for this view


createPager

public ulu.view.ui.Pager createPager()
factory method for creating a pager - override if custom type required


getSource

public UContainer getSource()
get the Viewable being paged

Specified by:
getSource in interface ulu.view.ui.Pager

setSource

public void setSource(UContainer uc)
set the Viewable being paged - always itself, so a null implementation given here

Specified by:
setSource in interface ulu.view.ui.Pager

getPageLength

public int getPageLength()
get the current page length by delegating - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() metho

Specified by:
getPageLength in interface ulu.view.ui.Pager

setPageLength

public void setPageLength(int i)
set the current page length - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() metho

Specified by:
setPageLength in interface ulu.view.ui.Pager

getPageNo

public int getPageNo()
get the current page number - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
getPageNo in interface ulu.view.ui.Pager

setPageNo

public void setPageNo(int i)
set the current page number - only allowed if isReversible() returns true - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
setPageNo in interface ulu.view.ui.Pager

getTotalLength

public int getTotalLength()
get the total length of the list being paged; in some cases this will be known in advance, in others not. (If it is known, it could be useful in building up a google-style navigation strip in addition to a next/back control). Will return -1 if the list length can't be determined. - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
getTotalLength in interface ulu.view.ui.Pager

isReversible

public boolean isReversible()
say whether the list can be navigated in both directions, or is simply a one-way traversal system (e.g. a database resultset with a non-scrollable cursor) - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
isReversible in interface ulu.view.ui.Pager

next

public boolean next()
visit the next page - returns true if possible - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
next in interface ulu.view.ui.Pager

back

public boolean back()
visit the previous page - returns true if possible (should check isReversible() before offering the user a hook to this method - shouldn't need to override this, but override a subclass of PagerImpl returned by the createPager() method

Specified by:
back in interface ulu.view.ui.Pager

list

public java.util.Enumeration list(java.util.Vector allitems)
list all items from the given Vector that are on the current page

Specified by:
list in interface ulu.view.ui.Pager

pageDescrip

public java.lang.String pageDescrip()
get a short message describing the page number - will give a total if available

Specified by:
pageDescrip in interface ulu.view.ui.Pager

getFilter

public ItemFilter getFilter()
get a filter for this view

Specified by:
getFilter in interface View

setFilter

public void setFilter(ItemFilter f)
set a Filter for this view

Specified by:
setFilter in interface View

findPageMarker

java.lang.Object findPageMarker()
find object marking top of page


visibleItems

public java.util.Vector visibleItems()
apply the current filters if needs be and return a list of filtered items


filter

public void filter()
filter all items in the view using current filters


getSearchClass

public java.lang.Class getSearchClass()
get a Search implementation that operates on this type of object

Specified by:
getSearchClass in interface Searchable

getSortClass

public java.lang.Class getSortClass()
get a Sorter implementation that operates on this type of object

Specified by:
getSortClass in interface Sortable