    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     */
    017    package org.apache.commons.scxml.model;
    018
    019    import java.io.Serializable;
    020    import java.util.Map;
    021
    022    import 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     */
    029    public 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 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 name.
    077         *
    078         * @return String The name.
    079         * @deprecated Use {@link #getId()} instead.
    080         */
    081        public final String getName() {
    082            return id;
    083        }
    084
    085        /**
    086         * Set the name.
    087         *
    088         * @param name The name.
    089         * @deprecated Use {@link #setId(String)} instead.
    090         */
    091        public final void setName(final String name) {
    092            this.id = name;
    093        }
    094
    095        /**
    096         * Get the id.
    097         *
    098         * @return String An identifier.
    099         */
    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