KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > ParameterizedItemImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.action;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.alfresco.service.cmr.action.ParameterizedItem;
24
25 /**
26  * Rule item instance implementation class.
27  *
28  * @author Roy Wetherall
29  */

30 public abstract class ParameterizedItemImpl implements ParameterizedItem, Serializable JavaDoc
31 {
32     /**
33      * The id
34      */

35     private String JavaDoc id;
36     
37     /**
38      * The parameter values
39      */

40     private Map JavaDoc<String JavaDoc, Serializable JavaDoc> parameterValues = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
41
42     /**
43      * Constructor
44      *
45      * @param ruleItem the rule item
46      */

47     public ParameterizedItemImpl(String JavaDoc id)
48     {
49         this(id, null);
50     }
51     
52     /**
53      * Constructor
54      *
55      * @param ruleItem the rule item
56      * @param parameterValues the parameter values
57      */

58     public ParameterizedItemImpl(String JavaDoc id, Map JavaDoc<String JavaDoc, Serializable JavaDoc> parameterValues)
59     {
60         // Set the action id
61
this.id = id;
62         
63         if (parameterValues != null)
64         {
65             // TODO need to check that the parameter values being set correspond
66
// correctly to the parameter definions on the rule item defintion
67
this.parameterValues = parameterValues;
68         }
69     }
70     
71     /**
72      * @see org.alfresco.service.cmr.action.ParameterizedItem#getId()
73      */

74     public String JavaDoc getId()
75     {
76         return this.id;
77     }
78
79     /**
80      * @see org.alfresco.service.cmr.action.ParameterizedItem#getParameterValues()
81      */

82     public Map JavaDoc<String JavaDoc, Serializable JavaDoc> getParameterValues()
83     {
84         Map JavaDoc<String JavaDoc, Serializable JavaDoc> result = this.parameterValues;
85         if (result == null)
86         {
87             result = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>();
88         }
89         return result;
90     }
91     
92     /**
93      * @see org.alfresco.service.cmr.action.ParameterizedItem#getParameterValue(String)
94      */

95     public Serializable JavaDoc getParameterValue(String JavaDoc name)
96     {
97         return this.parameterValues.get(name);
98     }
99     
100     /**
101      * @see org.alfresco.service.cmr.action.ParameterizedItem#setParameterValues(java.util.Map)
102      */

103     public void setParameterValues(Map JavaDoc<String JavaDoc, Serializable JavaDoc> parameterValues)
104     {
105         if (parameterValues != null)
106         {
107             // TODO need to check that the parameter values being set correspond
108
// correctly to the parameter definions on the rule item defintion
109
this.parameterValues = parameterValues;
110         }
111     }
112     
113     /**
114      * @see org.alfresco.service.cmr.action.ParameterizedItem#setParameterValue(String, Serializable)
115      */

116     public void setParameterValue(String JavaDoc name, Serializable JavaDoc value)
117     {
118         this.parameterValues.put(name, value);
119     }
120     
121     /**
122      * Hash code implementation
123      */

124     @Override JavaDoc
125     public int hashCode()
126     {
127         return this.id.hashCode();
128     }
129     
130     /**
131      * Equals implementation
132      */

133     @Override JavaDoc
134     public boolean equals(Object JavaDoc obj)
135     {
136         if (this == obj)
137         {
138             return true;
139         }
140         if (obj instanceof ParameterizedItemImpl)
141         {
142             ParameterizedItemImpl that = (ParameterizedItemImpl) obj;
143             return (this.id.equals(that.id));
144         }
145         else
146         {
147             return false;
148         }
149     }
150 }
151
Popular Tags