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.scxml2.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<String, String> 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 id. 77 * 78 * @return String An identifier. 79 */ 80 public final String getId() { 81 return id; 82 } 83 84 /** 85 * Set the id. 86 * 87 * @param id The identifier. 88 */ 89 public final void setId(final String id) { 90 this.id = id; 91 } 92 93 /** 94 * Get the URL where the XML data tree resides. 95 * 96 * @return String The URL. 97 */ 98 public final String getSrc() { 99 return src; 100 } 101 102 /** 103 * Set the URL where the XML data tree resides. 104 * 105 * @param src The source URL. 106 */ 107 public final void setSrc(final String src) { 108 this.src = src; 109 } 110 111 /** 112 * Get the expression that evaluates to the value of this data instance. 113 * 114 * @return String The expression. 115 */ 116 public final String getExpr() { 117 return expr; 118 } 119 120 /** 121 * Set the expression that evaluates to the value of this data instance. 122 * 123 * @param expr The expression. 124 */ 125 public final void setExpr(final String expr) { 126 this.expr = expr; 127 } 128 129 /** 130 * Get the XML data tree. 131 * 132 * @return Node The XML data tree, parsed as a <code>Node</code>. 133 */ 134 public final Node getNode() { 135 return node; 136 } 137 138 /** 139 * Set the XML data tree. 140 * 141 * @param node The XML data tree, parsed as a <code>Node</code>. 142 */ 143 public final void setNode(final Node node) { 144 this.node = node; 145 } 146 147 /** 148 * Get the XML namespaces at this action node in the SCXML document. 149 * 150 * @return Returns the map of namespaces. 151 */ 152 public final Map<String, String> getNamespaces() { 153 return namespaces; 154 } 155 156 /** 157 * Set the XML namespaces at this action node in the SCXML document. 158 * 159 * @param namespaces The document namespaces. 160 */ 161 public final void setNamespaces(final Map<String, String> namespaces) { 162 this.namespaces = namespaces; 163 } 164 165 } 166