Version: 1.1.1

org.biomoby.service.dashboard.renderers
Class CollectionRenderer

java.lang.Object
  extended by org.biomoby.service.dashboard.renderers.AbstractRenderer
      extended by org.biomoby.service.dashboard.renderers.CollectionRenderer
All Implemented Interfaces:
Renderer
Direct Known Subclasses:
BoxCollectionRenderer, TabCollectionRenderer

public abstract class CollectionRenderer
extends AbstractRenderer

This is not a normal renderer that is loaded and used through SPI. It is explicitly called if a service result is a collection but no renderer is here to process it as a collection, but there is one or more renderer(s) that can process individual elements of such collection.

Various subclasses of this class gets such renderer and a whole collection, and iterates over it - putting resulting components in various layouts (vertically below each other, in a tabbed pane, etc.).

Its method save2File(org.biomoby.service.dashboard.data.DataContainer, java.io.File) invents new file name for each element in a collection and calls a specific renderer to save the element in a file.

Version:
$Id: CollectionRenderer.java,v 1.4 2006/02/20 05:51:11 senger Exp $
Author:
Martin Senger

Field Summary
 
Fields inherited from interface org.biomoby.service.dashboard.renderers.Renderer
CLASS, CLASS_NAME, DATA, DATA_CONTAINER, MIME_TYPE, MOBY_TYPE
 
Method Summary
 boolean canHandle(String criterion, Object value)
          Never used...
abstract  JComponent getComponent(DataContainer data)
          Return a JComponent displaying (rendering) given data.
 boolean save2File(DataContainer data, File file)
          It creates a separate file for each element of the collection in 'data' (it does nothing if 'data' is null, or if it does not contain a collection - an array).
 
Methods inherited from class org.biomoby.service.dashboard.renderers.AbstractRenderer
getIcon, getName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

canHandle

public boolean canHandle(String criterion,
                         Object value)
Never used...

Specified by:
canHandle in interface Renderer
Specified by:
canHandle in class AbstractRenderer
Parameters:
criterion - is a category of the value, e.g. "MIME-TYPE"
value - is a value from the category criterion, e.g. "text/xml"

getComponent

public abstract JComponent getComponent(DataContainer data)
                                 throws MobyException
Description copied from interface: Renderer
Return a JComponent displaying (rendering) given data.

If it gets an array of data, it can always delegate their accumulation to the CollectionRenderer by saying:

   if (data.getData().getClass().isArray())
      return new BoxCollectionRenderer (this).getComponent (data);

Specified by:
getComponent in interface Renderer
Specified by:
getComponent in class AbstractRenderer
Parameters:
data - to be rendered
Returns:
a component for displaying data, or null if there is a problem with data
Throws:
MobyException - if called with wrong type of data

save2File

public boolean save2File(DataContainer data,
                         File file)
                  throws MobyException
It creates a separate file for each element of the collection in 'data' (it does nothing if 'data' is null, or if it does not contain a collection - an array). It adds a sequential number to the 'file' name: before its extension if the filename has one, or at the end.

Note that the real saving is done by a delegate renderer, nit by this class.

Specified by:
save2File in interface Renderer
Overrides:
save2File in class AbstractRenderer
Returns:
true on success, return false if you even did nt try to save data (probably because it does not make sense to store such data)
Throws:
MobyException - if saving was tried but failed

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010