/*
 This file is part of the software framework JStatCom, 
 a library for building applications for data based analysis.

 Copyright (C) 2000-2005  Markus Kraetzig

 This library 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 2.1 of the
 License, or (at your option) any later version.

 This library 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
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 USA
 */

package com.jstatcom.project;

import java.util.HashMap;
import java.util.Map;

/**
 * This enumeration contains all existing ProjectData types. If
 * new data types are to be added, this class needs to be extended.
 * 
 * @author Markus Kraetzig 
 */
public final class ProjectDataTypes {

    public final String NAME;

    /**
     * Map with all data types.
     */
    private static Map typeMap = new HashMap();

    private final String DES_NAME;

    /**
     * Data type that is used to represent time series data.
     */
    public static final ProjectDataTypes TS_DATA = new ProjectDataTypes(
            "TS_DATA", "Time Series Data");

    /**
     * Creates a data type instance with a name. A type with a certain name can
     * only be created once.
     * 
     * @param name
     *            identifier of this project data type
     * @param description
     *            a description for this data type
     * @throws IllegalStateException
     *             if a type with the same name has already been created before
     * @throws IllegalArgumentException
     *             if (name == null)
     */
    public ProjectDataTypes(String name, String description) {
        if (name == null)
            throw new IllegalArgumentException("Argument was null.");
        NAME = name.toUpperCase();
        DES_NAME = description;
        if (typeMap.containsKey(NAME))
            throw new IllegalStateException(
                    "An instance of ProjectDataTypes with the name \""
                            + NAME
                            + "\" has already been created.\nChoose a different name.");
        typeMap.put(NAME, this);
    }

    /**
     * Gets string representation of this object.
     * 
     * @return a string
     */
    public String toString() {
        return DES_NAME;
    }

}
 

Ads help maintain this website.