Clover coverage report - angkor - 0.4
Coverage timestamp: ti okt 15 2002 22:32:48 CEST
file stats: LOC: 94   Methods: 10
NCLOC: 59   Classes: 1
Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
JavaBeanModel.java 0% 0% 0% 0%
 1   
 /*
 2   
  * Angkor Web Framework
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at gnu.org.
 6   
  */
 7   
 package com.tirsen.angkor.beans;
 8   
 
 9   
 import com.tirsen.angkor.event.ChangeListener;
 10   
 import com.tirsen.angkor.event.ChangeSource;
 11   
 import com.tirsen.angkor.event.ChangeSourceHelper;
 12   
 import com.tirsen.angkor.widget.ValueModel;
 13   
 
 14   
 import java.io.Serializable;
 15   
 
 16   
 
 17   
 /**
 18   
  * A JavaBeanModel acts as the proxy for JavaBean instances which may or may not actually
 19   
  * exist enabling them to be lazily evaluated only when a view actually requests the value
 20   
  * of the JavaBean. Useful when creating views which should be bound to properties of JavaBeans
 21   
  * but the view is not yet visible and the JavaBean is not yet instantiated. Also has a lot of
 22   
  * utility methods for creating various models bound to the JavaBean so it may be useful even if
 23   
  * the JavaBean actually exists. For this reason the name <code>JavaBeanModel</code> may be a little bit
 24   
  * inaccurate, maybe <code>JavaBeanModel</code> may be better.
 25   
  *
 26   
  * <!-- $Id: JavaBeanModel.java,v 1.2 2002/10/09 21:37:37 tirsen Exp $ -->
 27   
  *
 28   
  * @author $Author: tirsen $
 29   
  * @version $Revision: 1.2 $
 30   
  */
 31   
 public class JavaBeanModel implements Serializable, ChangeSource
 32   
 {
 33   
     private Object valueObject;
 34   
     private ValueModel model;
 35   
     private Class objectClass;
 36   
     private ChangeSourceHelper changeSourceHelper = new ChangeSourceHelper(this);
 37   
 
 38  0
     public JavaBeanModel(Class objectClass)
 39   
     {
 40  0
         this.objectClass = objectClass;
 41   
     }
 42   
 
 43  0
     public JavaBeanModel(ValueModel model)
 44   
     {
 45  0
         this.model = model;
 46   
     }
 47   
 
 48  0
     public JavaBeanModel(Object valueObject)
 49   
     {
 50  0
         setValueObject(valueObject);
 51   
     }
 52   
 
 53  0
     public void setValueObject(Object valueObject)
 54   
     {
 55  0
         this.valueObject = valueObject;
 56  0
         changeSourceHelper.signalChangeEvent();
 57   
     }
 58   
 
 59  0
     public Object getObject()
 60   
     {
 61  0
         Object object = valueObject;
 62  0
         if (object == null && model != null) object = model.getValue();
 63  0
         return object;
 64   
     }
 65   
 
 66  0
     public Class getObjectClass()
 67   
     {
 68  0
         Class klass = objectClass;
 69  0
         if (klass == null && valueObject != null) klass = valueObject.getClass();
 70  0
         if (klass == null && model != null) klass = model.getValueClass();
 71  0
         return klass;
 72   
     }
 73   
 
 74  0
     public ValueModel getValue(String expression)
 75   
     {
 76  0
         return new PropertyValueModel(this, expression);
 77   
     }
 78   
 
 79  0
     public JavaBeanModel getJavaBean(String expression)
 80   
     {
 81  0
         return new JavaBeanModel(getValue(expression));
 82   
     }
 83   
 
 84  0
     public void addChangeListener(ChangeListener listener)
 85   
     {
 86  0
         changeSourceHelper.addChangeListener(listener);
 87   
     }
 88   
 
 89  0
     public void removeChangeListener(ChangeListener listener)
 90   
     {
 91  0
         changeSourceHelper.removeChangeListener(listener);
 92   
     }
 93   
 }
 94