KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > form > core > ApplicationResourceForm


1 package com.blandware.atleap.webapp.form.core;
2
3 import com.blandware.atleap.webapp.form.BaseForm;
4 import org.apache.struts.action.ActionMapping;
5
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7 import java.io.Serializable JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.util.Map JavaDoc;
10
11 /**
12  * <p>Form bean that serves to update application resource.
13  * Used to collect values for all locales associated with single key</p>
14  *
15  * @author Sergey Zubtcovskii <a HREF="mailto:sergey.zubtcovskii@blandware.com">&lt;sergey.zubtcovskii@blandware.com&gt;</a>
16  * @version $Revision: 1.2 $ $Date: 2005/08/04 17:25:15 $
17  * @struts.form name="applicationResourceForm"
18  */

19 public class ApplicationResourceForm extends BaseForm implements Serializable JavaDoc {
20
21     /**
22      * Key of application resource
23      */

24     protected String JavaDoc key;
25
26     /**
27      * Map of values associated with key
28      */

29     protected Map JavaDoc valueMap = new HashMap JavaDoc();
30
31     /**
32      * Map of versions to enable for optimistic locking feature
33      */

34     protected Map JavaDoc versionMap = new HashMap JavaDoc();
35
36
37     /**
38      * Returns key of application resource
39      *
40      * @return Key of application resource
41      */

42     public String JavaDoc getKey() {
43         return key;
44     }
45
46     /**
47      * Sets key of application resource
48      *
49      * @param key Key of application resource
50      */

51     public void setKey(String JavaDoc key) {
52         this.key = key;
53     }
54
55     /**
56      * Returns map of values associated with key
57      *
58      * @return Map of values associated with key
59      */

60     public Map JavaDoc getValueMap() {
61         return this.valueMap;
62     }
63
64     /**
65      * Sets map of values associated with key
66      *
67      * @param valueMap Map of values associated with key
68      */

69     public void setValueMap(Map JavaDoc valueMap) {
70         this.valueMap = valueMap;
71     }
72
73     /**
74      * Returns value associated with specified locale identifier
75      *
76      * @param localeIdentifier Identifier of locale to return value associated with
77      * @return Value associated with locale with specified identifier
78      */

79     public Object JavaDoc getValue(String JavaDoc localeIdentifier) {
80         return valueMap.get(localeIdentifier);
81     }
82
83     /**
84      * Sets value for specified locale identifier
85      *
86      * @param localeIdentifier Locale identifier to associate value with
87      * @param value Value to associate with given locale identifier
88      */

89     public void setValue(String JavaDoc localeIdentifier, Object JavaDoc value) {
90         valueMap.put(localeIdentifier, value);
91     }
92
93     /**
94      * Returns map of versions
95      *
96      * @return Map of versions
97      */

98     public Map JavaDoc getVersionMap() {
99         return this.versionMap;
100     }
101
102     /**
103      * Sets map of versions
104      *
105      * @param versionMap Map of versions to set
106      */

107     public void setVersionMap(Map JavaDoc versionMap) {
108         this.versionMap = versionMap;
109     }
110
111     /**
112      * Returns version associated with given locale identifier
113      *
114      * @param localeIdentifier Locale identifier to get version associated with
115      * @return Version associated with given locale identifier
116      */

117     public Object JavaDoc getVersion(String JavaDoc localeIdentifier) {
118         return versionMap.get(localeIdentifier);
119     }
120
121     /**
122      * Associates version with locale identifier
123      *
124      * @param localeIdentifier Locale identifier to associate version with
125      * @param version Version to associate with given locale identifier
126      */

127     public void setVersion(String JavaDoc localeIdentifier, Object JavaDoc version) {
128         versionMap.put(localeIdentifier, version);
129     }
130
131     /**
132      * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
133      */

134     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
135
136         // reset all mapped properties to default values
137
this.valueMap = new HashMap JavaDoc();
138         this.versionMap = new HashMap JavaDoc();
139
140     }
141 }
142
Popular Tags