Package at.tuwien.minimee.model

Source Code of at.tuwien.minimee.model.ExperienceBase

/*******************************************************************************
* Copyright (c) 2006-2010 Vienna University of Technology,
* Department of Software Technology and Interactive Systems
*
* All rights reserved. This program and the accompanying
* materials are made available under the terms of the
* Apache License, Version 2.0 which accompanies
* this distribution, and is available at
* http://www.apache.org/licenses/LICENSE-2.0
*******************************************************************************/
package at.tuwien.minimee.model;

import java.util.HashMap;

import eu.planets_project.pp.plato.model.ToolExperience;
import eu.planets_project.pp.plato.model.measurement.MeasurableProperty;
import eu.planets_project.pp.plato.model.measurement.Measurement;

/**
* This class provides a very simple experience database for measured properties
* {@link ToolExperience}
*/
public class ExperienceBase {
    private HashMap<String,ToolExperience> toolExperience = new HashMap<String,ToolExperience>();
   
    /**
     * @param tool identifier of the {@link ToolExperience}
     * @return the {@link ToolExperience} corresponding to the identifier.
     * If there was no ToolExperience defined yet for this ID, a new one will
     * be created and put into the map!
     */
    public ToolExperience getToolExperience(String tool) {
        ToolExperience b = toolExperience.get(tool);
        if (b == null) {
            b = new ToolExperience();
            toolExperience.put(tool, b);
        }
        return b;
    }   
   
    /**
     * adds a new {@link Measurement} to the {@link ToolExperience}
     * identified by the provided id
     * @param tool identifies the {@link ToolExperience} to which to add the measurement
     * @param m
     */
    public void addExperience(String tool,Measurement m) {
        ToolExperience b = getToolExperience(tool);
        b.addMeasurement(m);
    }   
   
    /**
     * @param tool identifies the {@link ToolExperience}
     * @param m identifies the {@link Measurement} which points to a {@link MeasurableProperty}
     * for which we want to get the average
     * @return average of the measurements for this property
     *  {@link ToolExperience#getAverage(String)}
     */
    public Measurement getAverage(String tool, Measurement m) {
        return getToolExperience(tool).getAverage(m.getProperty().getName());
    }
}
TOP

Related Classes of at.tuwien.minimee.model.ExperienceBase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.