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

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

/* *##% 
 * EUGene :: EUGene
 * Copyright (C) 2004 - 2009 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
 * .
 * ##%*/

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: 758 $
 *
 * Last update : $Date: 2009-12-16 19:01:51 +0100 (mer., 16 déc. 2009) $
 * By : $Author: tchemit $
 *
 * @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 = null;

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

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

    @Override
    public String getName() {
        return this.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;
    }

    /**
     * Add a tag value
     * 
     * @param key key
     * @param value value
     */
    public void addTagValue(String key, String value) {
        modelTagValues.put(key, value);
    }

    /**
     * Get a tag value
     * 
     * @return the value of the found tagValue, or null if the element has no
     *         associated tagValue for this name.
     */
    @Override
    public String getTagValue(String key) {
        return (key == null ? null : (String) modelTagValues.get(key));
    }

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

    /**
     * Get model version.
     *
     * @return model version
     */
    @Override
    public String getVersion() {
        return this.version;
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy