Update of /cvsroot/displaytag/display09/src/org/displaytag/decorator
In directory sc8-pr-cvs1:/tmp/cvs-serv14366/src/org/displaytag/decorator

Modified Files:
        ColumnDecorator.java Decorator.java TableDecorator.java 
Log Message:
added utility methods to decorator, moved something to tabledecorator

Index: ColumnDecorator.java
===================================================================
RCS file: 
/cvsroot/displaytag/display09/src/org/displaytag/decorator/ColumnDecorator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ColumnDecorator.java        21 Jun 2003 12:34:49 -0000      1.1
--- ColumnDecorator.java        15 Jul 2003 21:49:24 -0000      1.2
***************
*** 1,4 ****
--- 1,6 ----
  package org.displaytag.decorator;
  
+ import org.displaytag.exception.DecoratorException;
+ 
  /**
   * <p>A simple "decorator" for column values</p>
***************
*** 8,24 ****
  public abstract class ColumnDecorator
  {
-       /**
-        * empty costructor for ColumnDecorator
-        */
-       public ColumnDecorator()
-       {
-               super();
-       }
  
        /**
!        * Method decorate
!        * @param pColumnValue Object
!        * @return String
         */
!       public abstract String decorate(Object pColumnValue);
  }
--- 10,21 ----
  public abstract class ColumnDecorator
  {
  
        /**
!        * Method called to decorate the underlining object
!        * @param pColumnValue Object to decorate
!        * @return String decorated object
!        * @throws DecoratorException for exceptions
         */
!       public abstract String decorate(Object pColumnValue) throws DecoratorException;
! 
  }

Index: Decorator.java
===================================================================
RCS file: /cvsroot/displaytag/display09/src/org/displaytag/decorator/Decorator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Decorator.java      22 Jun 2003 16:16:25 -0000      1.2
--- Decorator.java      15 Jul 2003 21:49:24 -0000      1.3
***************
*** 1,10 ****
  package org.displaytag.decorator;
  
  import javax.servlet.jsp.PageContext;
  
  /**
   * <p>This class provides some basic functionality for all objects which serve
   * as decorators for the objects in the List being displayed.<p>
!  * <p>Decorator should never be subclasse directly. Use TableDecorator instead</p>
   * @author mraible
   * @version $Revision$ ($Author$)
--- 1,15 ----
  package org.displaytag.decorator;
  
+ import java.beans.PropertyDescriptor;
+ import java.util.HashMap;
+ 
  import javax.servlet.jsp.PageContext;
  
+ import org.apache.commons.beanutils.PropertyUtils;
+ 
  /**
   * <p>This class provides some basic functionality for all objects which serve
   * as decorators for the objects in the List being displayed.<p>
!  * <p>Decorator should never be subclassed directly. Use TableDecorator instead</p>
   * @author mraible
   * @version $Revision$ ($Author$)
***************
*** 14,107 ****
  
        /**
!        * Field mPageContext
!        */
!       private PageContext mPageContext= null;
!       
!       /**
!        * Field mCollection
         */
!       private Object mCollection= null;
  
        /**
!        * Field mObject
!        */
!       private Object mObject= null;
!       /**
!        * Field mViewIndex
!        */
!       private int mViewIndex= -1;
!       /**
!        * Field mListIndex
         */
!       private int mListIndex= -1;
  
        /**
!        * Method getObject
!        * @return Object
         */
!       public Object getObject()
!       {
!               return mObject;
!       }
  
        /**
!        * Method getViewIndex
!        * @return int
         */
!       public int getViewIndex()
        {
!               return mViewIndex;
        }
  
        /**
!        * Method getListIndex
!        * @return int
         */
!       public int getListIndex()
        {
!               return mListIndex;
        }
  
        /**
!        * Method getPageContext
!        * @return PageContext
         */
!       public PageContext getPageContext()
        {
!               return mPageContext;
        }
  
        /**
!        * Method init
!        * @param pPageContext PageContext
!        * @param pList Object
         */
!       public void init(PageContext pPageContext, Object pList)
        {
!               mPageContext= pPageContext;
!               mCollection= pList;
        }
  
        /**
!        * Method initRow
!        * @param pObject Object
!        * @param pViewIndex int
!        * @param pListIndex int
         */
!       public void initRow(Object pObject, int pViewIndex, int pListIndex)
        {
!               mObject= pObject;
!               mViewIndex= pViewIndex;
!               mListIndex= pListIndex;
        }
  
        /**
!        * Method finish
         */
!       public void finish()
        {
!               mPageContext= null;
!               mCollection= null;
!               mObject= null;
        }
  
--- 19,118 ----
  
        /**
!        * page context
         */
!       private PageContext mPageContext;
  
        /**
!        * property info cache
         */
!       private static HashMap lPropertyMap = new HashMap();
  
        /**
!        * decorated object. Usually a List
         */
!       private Object mDecoratedObject;
  
        /**
!        * Method init
!        * @param pPageContext PageContext
!        * @param pDecoratedObject decorated object (usually a list)
         */
!       public void init(PageContext pPageContext, Object pDecoratedObject)
        {
!               mPageContext = pPageContext;
!               mDecoratedObject = pDecoratedObject;
        }
  
        /**
!        * returns the page context
!        * @return PageContext
         */
!       public PageContext getPageContext()
        {
!               return mPageContext;
        }
  
        /**
!        * returns the decorated object
!        * @return Object
         */
!       public Object getDecoratedObject()
        {
!               return mDecoratedObject;
        }
  
        /**
!        * Method called at the end of evaluation
         */
!       public void finish()
        {
!               mPageContext = null;
!               mDecoratedObject = null;
        }
  
        /**
!        * look for a getter for the given property using introspection
!        * @param pPropertyName name of the property to check
!        * @return boolean true if the decorator has a getter for the given property
         */
!       public boolean searchGetterFor(String pPropertyName)
        {
!               PropertyDescriptor[] lDescriptors = 
PropertyUtils.getPropertyDescriptors(getClass());
! 
!               // iterate on property descriptors
!               for (int lCount = 0; lCount < lDescriptors.length; lCount++)
!               {
!                       if (pPropertyName.equals(lDescriptors[lCount].getName()))
!                       {
!                               return true;
!                       }
!               }
! 
!               return false;
        }
  
        /**
!        * Check if a getter exists for a given property. Uses cached info if property 
has already been requested
!        * @param pPropertyName name of the property to check
!        * @return boolean true if the decorator has a getter for the given property
         */
!       public boolean hasGetterFor(String pPropertyName)
        {
!               Boolean lCachedResult;
! 
!               if ((lCachedResult = (Boolean) lPropertyMap.get(pPropertyName)) != 
null)
!               {
!                       return lCachedResult.booleanValue();
!               }
! 
!               // not already cached... check
!               boolean lHasGetter = searchGetterFor(pPropertyName);
! 
!               // save in cache
!               lPropertyMap.put(pPropertyName, new Boolean(lHasGetter));
! 
!               // and return
!               return lHasGetter;
! 
        }
  

Index: TableDecorator.java
===================================================================
RCS file: 
/cvsroot/displaytag/display09/src/org/displaytag/decorator/TableDecorator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TableDecorator.java 22 Jun 2003 16:16:25 -0000      1.2
--- TableDecorator.java 15 Jul 2003 21:49:24 -0000      1.3
***************
*** 7,10 ****
--- 7,55 ----
  public abstract class TableDecorator extends Decorator
  {
+       /**
+        * Field mObject
+        */
+       private Object mCurrentRowObject;
+ 
+       /**
+        * Field mViewIndex
+        */
+       private int mViewIndex = -1;
+ 
+       /**
+        * Field mListIndex
+        */
+       private int mListIndex = -1;
+ 
+       /**
+        * Method getViewIndex
+        * @return int
+        */
+       public int getViewIndex()
+       {
+               return mViewIndex;
+       }
+ 
+       /**
+        * Method getListIndex
+        * @return int
+        */
+       public int getListIndex()
+       {
+               return mListIndex;
+       }
+ 
+       /**
+        * Method initRow
+        * @param pObject Object
+        * @param pViewIndex int
+        * @param pListIndex int
+        */
+       public void initRow(Object pObject, int pViewIndex, int pListIndex)
+       {
+               mCurrentRowObject = pObject;
+               mViewIndex = pViewIndex;
+               mListIndex = pListIndex;
+       }
  
        /**
***************
*** 24,27 ****
--- 69,90 ----
        {
                return "";
+       }
+ 
+       /**
+        * Method called at the end of evaluation
+        */
+       public void finish()
+       {
+               mCurrentRowObject = null;
+               super.finish();
+       }
+ 
+       /**
+        * Returns the currentRowObject.
+        * @return Object
+        */
+       public Object getCurrentRowObject()
+       {
+               return mCurrentRowObject;
        }
  




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
displaytag-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to