KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > xml > nuts > PropertiesNut


1 package jfun.yan.xml.nuts;
2
3 import java.util.List JavaDoc;
4 import java.util.Properties JavaDoc;
5
6 import jfun.yan.Component;
7 import jfun.yan.Components;
8 import jfun.yan.SimpleComponent;
9
10 /**
11  * The <props> tag that creates Properties object.
12  * <p>
13  * @author Ben Yu
14  * Nov 17, 2005 1:03:30 AM
15  */

16 public class PropertiesNut extends EntriesNut {
17   public PropertiesNut(){
18     super.setKey_type(String JavaDoc.class);
19     super.setOf(String JavaDoc.class);
20   }
21   
22   /**
23    * Disable "key-type" by throwing exception.
24    */

25   public void setKey_type(Class JavaDoc key_type) {
26     throw raise("attribute \"key-type\" not supported.");
27   }
28
29   /**
30    * Disable "of" by throwing exception.
31    */

32   public void setOf(Class JavaDoc of) {
33     throw raise("attribute \"of\" not supported.");
34   }
35
36   public Component eval(){
37     final List JavaDoc keys = getKeys();
38     final Component[] vals = getEntryComponents();
39     final Component step1 = new SimpleComponent(Properties JavaDoc.class){
40       public Object JavaDoc create(){
41         return new Properties JavaDoc();
42       }
43     };
44     return Components.storeMap(step1, keys.toArray(), vals);
45   }
46 }
47
Popular Tags