/**
 * $Id$
 *
 * Status: Ok
 *
 * Todo
 *   - push the appropriate stuff down into TableDecorator
 **/

package org.apache.taglibs.display;

import java.util.List;
import javax.servlet.jsp.PageContext;

/**
 * This class provides some basic functionality for all objects which serve
 * as decorators for the objects in the List being displayed.
 **/

public abstract class Decorator extends Object
{
   private PageContext ctx = null;
   private List list = null;

   private Object obj = null;
   private int viewIndex = -1;
   private int listIndex = -1;


   public Decorator() {

   }

   public void init( PageContext ctx, List list ) {
      this.ctx = ctx;
      this.list = list;
   }

   public String initRow( Object obj, int viewIndex, int listIndex ) {
      this.obj = obj;
      this.viewIndex = viewIndex;
      this.listIndex = listIndex;
      return "";
   }

   public String startRow() {
      return "";
   }

   public String finishRow() {
      return "";
   }

   public void finish() {
   
   }

   public PageContext getPageContext() { return this.ctx; }
   public List getList() { return this.list; }

   public Object getObject() { return this.obj; }
   public int getViewIndex() { return this.viewIndex; }
   public int getListIndex() { return this.listIndex; }
}

@@ -135,16 +135,45 @@
 splay;%0A%0A
+import java.util.Collection;%0A
 import j
@@ -469,25 +469,33 @@
 private 
-List list
+Object collection
  = null;
@@ -495,16 +495,20 @@
 = null;%0A
+    
 %0A   priv
@@ -663,19 +663,21 @@
 xt ctx, 
-Lis
+Objec
 t list )
@@ -712,20 +712,26 @@
    this.
-list
+collection
  = list;
@@ -1120,24 +1120,26 @@
 this.ctx; %7D%0A
+%0A 
    public Li
@@ -1156,29 +1156,450 @@
 () %7B
- return this.list; %7D%0A
+%0A%09if (this.collection instanceof List) %0A%09  return (List)this.collection;%0A%09else throw new RuntimeException (%22This function is only supported if the given collection is a java.util.List.%22);%0A    %7D%0A%0A    public Collection getCollection () %7B%0A%09if (this instanceof Collection)%0A%09    return (Collection) this.collection;%0A%09else throw new RuntimeException (%22This function is only supported if the given collection is a java.util.Collection.%22);%0A    %7D%0A    
 %0A   

patch from Zorzella to allow for Collections, Iterators and Maps