001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.scxml2.model; 018 019import java.io.Serializable; 020import java.util.Map; 021 022import org.w3c.dom.Node; 023 024/** 025 * The class in this SCXML object model that corresponds to the SCXML 026 * <data> child element of the <datamodel> element. 027 * 028 */ 029public class Data implements NamespacePrefixesHolder, Serializable { 030 031 /** 032 * Serial version UID. 033 */ 034 private static final long serialVersionUID = 1L; 035 036 /** 037 * The identifier of this data instance. 038 * For backwards compatibility this is also the name. 039 */ 040 private String id; 041 042 /** 043 * The URL to get the XML data tree from. 044 */ 045 private String src; 046 047 /** 048 * The expression that evaluates to the value of this data instance. 049 */ 050 private String expr; 051 052 /** 053 * The child XML data tree, parsed as a Node, cloned per execution 054 * instance. 055 */ 056 private Node node; 057 058 /** 059 * The current XML namespaces in the SCXML document for this action node, 060 * preserved for deferred XPath evaluation. Easier than to scrape node 061 * above, given the Builtin API. 062 */ 063 private Map<String, String> namespaces; 064 065 /** 066 * Constructor. 067 */ 068 public Data() { 069 this.id = null; 070 this.src = null; 071 this.expr = null; 072 this.node = null; 073 } 074 075 /** 076 * Get the id. 077 * 078 * @return String An identifier. 079 */ 080 public final String getId() { 081 return id; 082 } 083 084 /** 085 * Set the id. 086 * 087 * @param id The identifier. 088 */ 089 public final void setId(final String id) { 090 this.id = id; 091 } 092 093 /** 094 * Get the URL where the XML data tree resides. 095 * 096 * @return String The URL. 097 */ 098 public final String getSrc() { 099 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