001: /**
002: * <copyright>
003: *
004: * Copyright 2002-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */package org.cougaar.tools.csmart.recipe;
026:
027: /**
028: * Simple Class used by the UI to obtain all the Recipe Names and classes.
029: * Whenever a new recipe is added, its name and class must be added here
030: * or it will not appear in the UI.
031: *
032: * Created: Wed Mar 27 10:37:01 2002
033: *
034: */
035: public class RecipeList {
036:
037: // Add any new recipes to this array.
038: private static final NameClassPair[] recipes = {
039: new NameClassPair("Basic Metric", BasicMetric.class),
040: new NameClassPair("Specific Insertion",
041: SpecificInsertionRecipe.class),
042: new NameClassPair("Parameter Insertion",
043: ParameterInsertionRecipe.class),
044: new NameClassPair("Servlet Group Insertion",
045: ServletGroupInsertionRecipe.class),
046: new NameClassPair("Adaptivity Support",
047: AdaptivitySupportRecipe.class),
048: new NameClassPair("Complete Agent",
049: CompleteAgentRecipe.class),
050: new NameClassPair("Component Collection",
051: ComponentCollectionRecipe.class),
052: // new NameClassPair("Switch Plugin", SwitchPluginRecipe.class),
053: };
054:
055: public static final String[] getRecipeNames() {
056: String[] names = new String[recipes.length];
057:
058: for (int i = 0; i < recipes.length; i++) {
059: names[i] = recipes[i].name;
060: }
061:
062: return names;
063: }
064:
065: public static final Class[] getRecipeClasses() {
066: Class[] classes = new Class[recipes.length];
067:
068: for (int i = 0; i < recipes.length; i++) {
069: classes[i] = recipes[i].cls;
070: }
071:
072: return classes;
073: }
074:
075: public static final int getRecipeCount() {
076: return recipes.length;
077: }
078:
079: public static final String getRecipeName(int i)
080: throws ArrayIndexOutOfBoundsException {
081: if (i < 0 || i > recipes.length) {
082: throw new ArrayIndexOutOfBoundsException(i);
083: }
084: return recipes[i].name;
085: }
086:
087: public static final Class getRecipeClass(int i)
088: throws ArrayIndexOutOfBoundsException {
089: if (i < 0 || i > recipes.length) {
090: throw new ArrayIndexOutOfBoundsException(i);
091: }
092: return recipes[i].cls;
093: }
094:
095: private static final class NameClassPair {
096: public String name;
097: public Class cls;
098:
099: public NameClassPair(String name, Class cls) {
100: this .cls = cls;
101: this .name = name;
102: }
103:
104: public String toString() {
105: return name;
106: }
107: }
108:
109: }// RecipeList
|