KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > nuts > optional > RefNut


1 package jfun.yan.xml.nuts.optional;
2
3 import jfun.yan.Component;
4 import jfun.yan.Components;
5 import jfun.yan.xml.nut.ComponentNut;
6
7 /**
8  * Use this tag to reference any component in the current container.
9  * The reference is not checked by the compilation and is not affected by namespace.
10  *
11  * <p>
12  * @author Ben Yu
13  * Dec 21, 2005 1:43:34 PM
14  */

15 public class RefNut extends ComponentNut {
16   private Object JavaDoc to;
17   private Class JavaDoc type;
18   
19   public Class JavaDoc getType() {
20     return type;
21   }
22
23   public void setType(Class JavaDoc type) {
24     this.type = type;
25   }
26
27   public Object JavaDoc getTo() {
28     return to;
29   }
30
31   public void setTo(Object JavaDoc ref) {
32     this.to = ref;
33   }
34
35   public Component eval(){
36     if(to!=null)
37       return Components.useKey(to);
38     else{
39       if(type==null){
40         raise("either 'to' or 'type' has to be specified");
41       }
42       return Components.useType(type);
43     }
44   }
45
46 }
47
Popular Tags