    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.env.jexl;
    018
    019    import java.util.Map;
    020
    021    import org.apache.commons.scxml.Builtin;
    022    import org.apache.commons.scxml.Context;
    023    import org.apache.commons.scxml.env.SimpleContext;
    024
    025    /**
    026     * JEXL Context implementation for Commons SCXML.
    027     *
    028     */
    029    public class JexlContext extends SimpleContext
    030        implements org.apache.commons.jexl.JexlContext {
    031
    032        /** Serial version UID. */
    033        private static final long serialVersionUID = 1L;
    034
    035        /**
    036         * Constructor.
    037         */
    038        public JexlContext() {
    039            super();
    040            getVars().put("_builtin", new Builtin());
    041        }
    042
    043        /**
    044         * Constructor with initial vars.
    045         *
    046         * @param initialVars The initial set of variables.
    047         */
    048        public JexlContext(final Map initialVars) {
    049            super(initialVars);
    050            getVars().put("_builtin", new Builtin());
    051        }
    052
    053        /**
    054         * Constructor with parent context.
    055         *
    056         * @param parent The parent context.
    057         */
    058        public JexlContext(final Context parent) {
    059            super(parent);
    060            getVars().put("_builtin", new Builtin());
    061        }
    062
    063        /**
    064         * Set the variables map.
    065         *
    066         * @param vars The new variables map.
    067         *
    068         * @see org.apache.commons.jexl.JexlContext#setVars(Map)
    069         * @see org.apache.commons.scxml.env.SimpleContext#setVars(Map)
    070         */
    071        public void setVars(final Map vars) {
    072            super.setVars(vars);
    073            getVars().put("_builtin", new Builtin());
    074        }
    075
    076        /**
    077         * Get the variables map.
    078         *
    079         * @return Map The variables map.
    080         *
    081         * @see org.apache.commons.jexl.JexlContext#getVars()
    082         * @see org.apache.commons.scxml.env.SimpleContext#getVars()
    083         */
    084        public Map getVars() {
    085            return super.getVars();
    086        }
    087
    088        /**
    089         * Clear this Context.
    090         *
    091         * @see org.apache.commons.scxml.Context#reset()
    092         */
    093        public void reset() {
    094            super.reset();
    095            getVars().put("_builtin", new Builtin());
    096        }
    097
    098    }
    099