KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > tags > support > Arg


1 package org.sapia.gumby.tags.support;
2
3 import org.sapia.gumby.RenderContext;
4 import org.sapia.gumby.factory.ContextAware;
5 import org.sapia.gumby.tags.types.TypeUtil;
6 import org.sapia.util.xml.confix.ConfigurationException;
7 import org.sapia.util.xml.confix.ObjectHandlerIF;
8
9 /**
10  * @author Yanick Duchesne
11  *
12  * <dl>
13  * <dt><b>Copyright: </b>
14  * <dd>Copyright &#169; 2002-2005 <a HREF="http://www.sapia-oss.org">Sapia Open
15  * Source Software </a>. All Rights Reserved.</dd>
16  * </dt>
17  * <dt><b>License: </b>
18  * <dd>Read the license.txt file of the jar or visit the <a
19  * HREF="http://www.sapia-oss.org/license.html">license page </a> at the Sapia
20  * OSS web site</dd>
21  * </dt>
22  * </dl>
23  */

24 public class Arg implements ObjectHandlerIF, ContextAware {
25
26   private Class JavaDoc _type;
27   private Object JavaDoc _value;
28   private RenderContext _context;
29
30   public void setType(String JavaDoc type) throws Exception JavaDoc {
31     _type = TypeUtil.getTypeFor(type);
32     if(_type == null) {
33       _type = _context.getSettings().resolveClass(type);
34     }
35   }
36
37   public Class JavaDoc getType() {
38     if(_type == null) {
39       if(_value == null) {
40         throw new IllegalStateException JavaDoc(
41             "Could not determine type; arg value is null");
42       }
43       return _value.getClass();
44     }
45     return _type;
46   }
47
48   public void setValue(Object JavaDoc value) {
49     _value = value;
50   }
51
52   public Object JavaDoc getValue() {
53     return _value;
54   }
55
56   /**
57    * @see org.sapia.gumby.factory.ContextAware#handleContext(org.sapia.gumby.RenderContext)
58    */

59   public void handleContext(RenderContext context) {
60     _context = context;
61   }
62
63   /**
64    * @see org.sapia.util.xml.confix.ObjectHandlerIF#handleObject(java.lang.String,
65    * java.lang.Object)
66    */

67   public void handleObject(String JavaDoc arg0, Object JavaDoc arg1)
68       throws ConfigurationException {
69     setValue(arg1);
70   }
71
72 }
73
Popular Tags