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 /**
020 * The class in this SCXML object model that corresponds to the
021 * <history> SCXML pseudo state element.
022 *
023 */
024 public class History extends TransitionTarget {
025
026 /**
027 * Serial version UID.
028 */
029 private static final long serialVersionUID = 1L;
030
031 /**
032 * Whether this is a shallow or deep history, the default is shallow.
033 */
034 private boolean isDeep;
035
036 /**
037 * A conditionless transition representing the default history state
038 * and indicates the state to transition to if the parent state has
039 * never been entered before.
040 */
041 private Transition transition;
042
043 /**
044 * Default no-args constructor for XML Digester.
045 */
046 public History() {
047 super();
048 }
049
050 /**
051 * Get the transition.
052 *
053 * @return Returns the transition.
054 */
055 public final Transition getTransition() {
056 return transition;
057 }
058
059 /**
060 * Set the transition.
061 *
062 * @param transition The transition to set.
063 */
064 public final void setTransition(final Transition transition) {
065 this.transition = transition;
066 this.transition.setParent(this);
067 }
068
069 /**
070 * Is this history "deep" (as against "shallow").
071 *
072 * @return Returns whether this is a "deep" history
073 */
074 public final boolean isDeep() {
075 return isDeep;
076 }
077
078 /**
079 * This method is invoked by XML digester when parsing SCXML markup.
080 *
081 * @param type The history type, which can be "shallow" or
082 * "deep"
083 */
084 public final void setType(final String type) {
085 if (type.equals("deep")) {
086 isDeep = true;
087 }
088 //shallow is by default
089 }
090
091 }
092