All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.eugene.models.state.xml.StateModelImpl Maven / Gradle / Ivy

/*
 * #%L
 * EUGene :: EUGene
 * 
 * $Id: StateModelImpl.java 1012 2010-11-28 11:24:27Z tchemit $
 * $HeadURL: http://svn.nuiton.org/svn/eugene/tags/eugene-2.3.3/eugene/src/main/java/org/nuiton/eugene/models/state/xml/StateModelImpl.java $
 * %%
 * Copyright (C) 2004 - 2010 CodeLutin
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */

package org.nuiton.eugene.models.state.xml;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.nuiton.eugene.models.state.StateModel;
import org.nuiton.eugene.models.state.StateModelStateChart;

/**
 * Implementation of the {@link StateModel}.
 * 
 * @author chatellier
 * @version $Revision: 1012 $
 *
 * Last update : $Date: 2010-11-28 12:24:27 +0100 (dim, 28 nov 2010) $
 * 
 * @plexus.component role="org.nuiton.eugene.models.Model" role-hint="statemodel"
 */
public class StateModelImpl implements StateModel {

    /**
     * List of charts composing this model
     */
    protected List listStateCharts;

    /**
     * Name of this model
     */
    protected String name;

    /**
     * Version of this model
     */
    protected String version;
    
    /**
     * Model tagged values
     */
    protected Map modelTagValues;

    /**
     * Construteur
     */
    public StateModelImpl() {
        listStateCharts = new ArrayList();
        modelTagValues = new HashMap();
    }

    @Override
    public String getName() {
        return name;
    }

    /**
     * Set model name.
     * 
     * @param name model name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Add chart.
     * 
     * @param chart chart
     */
    public void addStateChart(StateModelStateChart chart) {

        // appele apres construction du StateModelStateChartImpl
        // corrige les liens entre les nom d'etat, et les instances d'etat
        ((StateModelStateChartImpl) chart)
                .correctTransitionNameToInstance(null);

        listStateCharts.add(chart);
    }

    @Override
    public List getStateCharts() {
        return listStateCharts;
    }

    /**
     * Add a list of stateCharts into current model
     * @param charts list
     */
    public void addAllStateCharts(Collection charts) {
        listStateCharts.addAll(charts);
    }

    @Override
    public Map getTagValues() {
        return modelTagValues;
    }

    /**
     * Adds the given {@code value} associated to the {@code key}.
     *
     * Note: If a previous tag value was definied, then it will be replaced.
     *
     * @param key the name of the tag value
     * @param value the value to associate
     */
    public void addTagValue(String key, String value) {
        modelTagValues.put(key, value);
    }

    @Override
    public String getTagValue(String key) {
        return key == null ? null : modelTagValues.get(key);
    }

    /**
     * Set model version.
     *
     * @param version model version
     */
    public void setVersion(String version) {
        this.version = version;
    }

    @Override
    public String getVersion() {
        return version;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy