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.Map;
21
22 import org.w3c.dom.Node;
23
24 /**
25 * The class in this SCXML object model that corresponds to the SCXML
26 * <data> child element of the <datamodel> element.
27 *
28 */
29 public class Data implements NamespacePrefixesHolder, Serializable {
30
31 /**
32 * Serial version UID.
33 */
34 private static final long serialVersionUID = 1L;
35
36 /**
37 * The identifier of this data instance.
38 * For backwards compatibility this is also the name.
39 */
40 private String id;
41
42 /**
43 * The URL to get the XML data tree from.
44 */
45 private String src;
46
47 /**
48 * The expression that evaluates to the value of this data instance.
49 */
50 private String expr;
51
52 /**
53 * The child XML data tree, parsed as a Node, cloned per execution
54 * instance.
55 */
56 private Node node;
57
58 /**
59 * The current XML namespaces in the SCXML document for this action node,
60 * preserved for deferred XPath evaluation. Easier than to scrape node
61 * above, given the Builtin API.
62 */
63 private Map namespaces;
64
65 /**
66 * Constructor.
67 */
68 public Data() {
69 this.id = null;
70 this.src = null;
71 this.expr = null;
72 this.node = null;
73 }
74
75 /**
76 * Get the name.
77 *
78 * @return String The name.
79 * @deprecated Use {@link #getId()} instead.
80 */
81 public final String getName() {
82 return id;
83 }
84
85 /**
86 * Set the name.
87 *
88 * @param name The name.
89 * @deprecated Use {@link #setId(String)} instead.
90 */
91 public final void setName(final String name) {
92 this.id = name;
93 }
94
95 /**
96 * Get the id.
97 *
98 * @return String An identifier.
99 */
100 public final String getId() {
101 return id;
102 }
103
104 /**
105 * Set the id.
106 *
107 * @param id The identifier.
108 */
109 public final void setId(final String id) {
110 this.id = id;
111 }
112
113 /**
114 * Get the URL where the XML data tree resides.
115 *
116 * @return String The URL.
117 */
118 public final String getSrc() {
119 return src;
120 }
121
122 /**
123 * Set the URL where the XML data tree resides.
124 *
125 * @param src The source URL.
126 */
127 public final void setSrc(final String src) {
128 this.src = src;
129 }
130
131 /**
132 * Get the expression that evaluates to the value of this data instance.
133 *
134 * @return String The expression.
135 */
136 public final String getExpr() {
137 return expr;
138 }
139
140 /**
141 * Set the expression that evaluates to the value of this data instance.
142 *
143 * @param expr The expression.
144 */
145 public final void setExpr(final String expr) {
146 this.expr = expr;
147 }
148
149 /**
150 * Get the XML data tree.
151 *
152 * @return Node The XML data tree, parsed as a <code>Node</code>.
153 */
154 public final Node getNode() {
155 return node;
156 }
157
158 /**
159 * Set the XML data tree.
160 *
161 * @param node The XML data tree, parsed as a <code>Node</code>.
162 */
163 public final void setNode(final Node node) {
164 this.node = node;
165 }
166
167 /**
168 * Get the XML namespaces at this action node in the SCXML document.
169 *
170 * @return Returns the map of namespaces.
171 */
172 public final Map getNamespaces() {
173 return namespaces;
174 }
175
176 /**
177 * Set the XML namespaces at this action node in the SCXML document.
178 *
179 * @param namespaces The document namespaces.
180 */
181 public final void setNamespaces(final Map namespaces) {
182 this.namespaces = namespaces;
183 }
184
185 }
186