    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.util.Collection;
    020
    021    import org.apache.commons.logging.Log;
    022    import org.apache.commons.scxml.ErrorReporter;
    023    import org.apache.commons.scxml.EventDispatcher;
    024    import org.apache.commons.scxml.SCInstance;
    025    import org.apache.commons.scxml.SCXMLExpressionException;
    026    import org.apache.commons.scxml.TriggerEvent;
    027
    028    /**
    029     * The class in this SCXML object model that corresponds to the
    030     * <event> SCXML element.
    031     *
    032     * @since 0.7
    033     */
    034    public class Event extends Action {
    035
    036        /**
    037         * Serial version UID.
    038         */
    039        private static final long serialVersionUID = 1L;
    040
    041        /**
    042         * The name of the derived event to be generated.
    043         */
    044        private String name;
    045
    046        /**
    047         * Constructor.
    048         */
    049        public Event() {
    050            super();
    051        }
    052
    053        /**
    054         * Get the event name.
    055         *
    056         * @return Returns the name.
    057         */
    058        public final String getName() {
    059            return name;
    060        }
    061
    062        /**
    063         * Set the event name.
    064         *
    065         * @param name The event name to set.
    066         */
    067        public final void setName(final String name) {
    068            this.name = name;
    069        }
    070
    071        /**
    072         * {@inheritDoc}
    073         */
    074        public void execute(final EventDispatcher evtDispatcher,
    075                final ErrorReporter errRep, final SCInstance scInstance,
    076                final Log appLog, final Collection derivedEvents)
    077        throws ModelException, SCXMLExpressionException {
    078
    079            if (appLog.isDebugEnabled()) {
    080                appLog.debug("<event>: Adding event named '" + name
    081                    + "' to list of derived events.");
    082            }
    083            TriggerEvent ev = new TriggerEvent(name, TriggerEvent.SIGNAL_EVENT);
    084            derivedEvents.add(ev);
    085
    086        }
    087
    088    }
    089