KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > util > service > ProfileRule


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.util.service;
8
9 import java.util.Map JavaDoc;
10
11 import org.ejtools.util.state.DefaultRule;
12 import org.xml.sax.Attributes JavaDoc;
13
14 /**
15  * @author Laurent Etiemble
16  * @version $Revision: 1.2 $
17  */

18 public class ProfileRule extends DefaultRule
19 {
20    /**
21     * Description of the Method
22     *
23     * @param context Description of the Parameter
24     */

25    public void loadEnter(Map JavaDoc context)
26    {
27       ProfileHolder holder = (ProfileHolder) context.get("HOLDER");
28       Profile profile = new Profile();
29       holder.setProfile(profile);
30       context.put("PROFILE", profile);
31    }
32
33
34    /**
35     * Description of the Class
36     *
37     * @author letiembl
38     * @version $Revision: 1.2 $
39     */

40    public static class ProfilePropertyRule extends DefaultRule
41    {
42       /** Description of the Field */
43       private String JavaDoc key;
44
45
46       /**
47        * Description of the Method
48        *
49        * @param context Description of the Parameter
50        */

51       public void loadBody(Map JavaDoc context)
52       {
53          Profile profile = (Profile) context.get("PROFILE");
54          String JavaDoc text = (String JavaDoc) context.get("TEXT");
55          profile.put(this.key, text);
56       }
57
58
59       /**
60        * Description of the Method
61        *
62        * @param context Description of the Parameter
63        */

64       public void loadEnter(Map JavaDoc context)
65       {
66          Attributes JavaDoc attrs = (Attributes JavaDoc) context.get("ATTRIBUTES");
67          this.key = attrs.getValue("key");
68       }
69
70
71       /**
72        * Description of the Method
73        *
74        * @param context Description of the Parameter
75        */

76       public void loadExit(Map JavaDoc context)
77       {
78          Profile profile = (Profile) context.get("PROFILE");
79          String JavaDoc text = profile.getProperty(this.key);
80          if (text == null)
81          {
82             profile.setProperty(this.key, "");
83          }
84       }
85    }
86 }
87
Popular Tags