1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.scxml.model;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.commons.scxml.PathResolver;
26
27 /**
28 * The class in this SCXML object model that corresponds to the
29 * <invoke> SCXML element.
30 *
31 */
32 public class Invoke implements NamespacePrefixesHolder, PathResolverHolder,
33 Serializable {
34
35 /**
36 * Serial version UID.
37 */
38 private static final long serialVersionUID = 1L;
39
40 /**
41 * The type of target to be invoked.
42 */
43 private String type;
44
45 /**
46 * The source URL for the external service.
47 */
48 private String src;
49
50 /**
51 * The expression that evaluates to the source URL for the
52 * external service.
53 */
54 private String srcexpr;
55
56 /**
57 * The Map of the params to be sent to the invoked process.
58 *
59 * Remove with deprecated getParams() in 1.0
60 */
61 private Map params;
62
63 /**
64 * The List of the params to be sent to the invoked process.
65 */
66 private List paramsList;
67
68 /**
69 * The <finalize> child, may be null.
70 */
71 private Finalize finalize;
72
73 /**
74 * {@link PathResolver} for resolving the "src" or "srcexpr" result.
75 */
76 private PathResolver pathResolver;
77
78 /**
79 * The current XML namespaces in the SCXML document for this action node,
80 * preserved for deferred XPath evaluation.
81 */
82 private Map namespaces;
83
84 /**
85 * Default no-args constructor for Digester.
86 */
87 public Invoke() {
88 params = new HashMap();
89 paramsList = new ArrayList();
90 }
91
92 /**
93 * Get the target type for this <invoke> element.
94 *
95 * @return String Returns the targettype.
96 * @deprecated Use {@link #getType()} instead.
97 */
98 public final String getTargettype() {
99 return type;
100 }
101
102 /**
103 * Set the target type for this <invoke> element.
104 *
105 * @param targettype The targettype to set.
106 * @deprecated Use {@link #setType(String)} instead.
107 */
108 public final void setTargettype(final String targettype) {
109 this.type = targettype;
110 }
111
112 /**
113 * Get the type for this <invoke> element.
114 *
115 * @return String Returns the type.
116 */
117 public final String getType() {
118 return type;
119 }
120
121 /**
122 * Set the type for this <invoke> element.
123 *
124 * @param type The type to set.
125 */
126 public final void setType(final String type) {
127 this.type = type;
128 }
129
130 /**
131 * Get the URL for the external service.
132 *
133 * @return String The URL.
134 */
135 public final String getSrc() {
136 return src;
137 }
138
139 /**
140 * Set the URL for the external service.
141 *
142 * @param src The source URL.
143 */
144 public final void setSrc(final String src) {
145 this.src = src;
146 }
147
148 /**
149 * Get the expression that evaluates to the source URL for the
150 * external service.
151 *
152 * @return String The source expression.
153 */
154 public final String getSrcexpr() {
155 return srcexpr;
156 }
157
158 /**
159 * Set the expression that evaluates to the source URL for the
160 * external service.
161 *
162 * @param srcexpr The source expression.
163 */
164 public final void setSrcexpr(final String srcexpr) {
165 this.srcexpr = srcexpr;
166 }
167
168 /**
169 * Get the params Map.
170 *
171 * @return Map The params map.
172 * @deprecated Remove in v1.0, use params() instead
173 */
174 public final Map getParams() {
175 return params;
176 }
177
178 /**
179 * Get the list of {@link Param}s.
180 *
181 * @return List The params list.
182 */
183 public final List params() {
184 return paramsList;
185 }
186
187 /**
188 * Add this param to this invoke.
189 *
190 * @param param The invoke parameter.
191 */
192 public final void addParam(final Param param) {
193 params.put(param.getName(), param.getExpr());
194 paramsList.add(param);
195 }
196
197 /**
198 * Get the Finalize for this Invoke.
199 *
200 * @return Finalize The Finalize for this Invoke.
201 */
202 public final Finalize getFinalize() {
203 return finalize;
204 }
205
206 /**
207 * Set the Finalize for this Invoke.
208 *
209 * @param finalize The Finalize for this Invoke.
210 */
211 public final void setFinalize(final Finalize finalize) {
212 this.finalize = finalize;
213 }
214
215 /**
216 * Get the {@link PathResolver}.
217 *
218 * @return Returns the pathResolver.
219 */
220 public PathResolver getPathResolver() {
221 return pathResolver;
222 }
223
224 /**
225 * Set the {@link PathResolver}.
226 *
227 * @param pathResolver The pathResolver to set.
228 */
229 public void setPathResolver(final PathResolver pathResolver) {
230 this.pathResolver = pathResolver;
231 }
232
233 /**
234 * Get the XML namespaces at this action node in the SCXML document.
235 *
236 * @return Returns the map of namespaces.
237 */
238 public final Map getNamespaces() {
239 return namespaces;
240 }
241
242 /**
243 * Set the XML namespaces at this action node in the SCXML document.
244 *
245 * @param namespaces The document namespaces.
246 */
247 public final void setNamespaces(final Map namespaces) {
248 this.namespaces = namespaces;
249 }
250
251 }