diff options
author | rbrooks | 2008-11-13 17:30:57 +0000 |
---|---|---|
committer | rbrooks | 2008-11-13 17:30:57 +0000 |
commit | 7dd7a5317bd043d65e38925e7e6990fe65ecb662 (patch) | |
tree | e8717d7b811a861661d198c0512417c9b930e185 /org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam | |
parent | dab100a3c288cbb16d5a8eb3c8d8fa635e8537a5 (diff) | |
download | org.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.tar.gz org.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.tar.xz org.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.zip |
"Team Workflow" - J9HHT - "Improve rendering design to make it more extensible"
Diffstat (limited to 'org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam')
-rw-r--r-- | org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java index 69af685aa31..b83c60dcc2a 100644 --- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java +++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java @@ -1,111 +1,111 @@ -/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.ui.skynet.blam;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.osee.framework.db.connection.exception.OseeArgumentException;
-import org.eclipse.osee.framework.skynet.core.User;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactType;
-import org.eclipse.osee.framework.skynet.core.artifact.Branch;
-import org.eclipse.osee.framework.skynet.core.attribute.AttributeType;
-
-/**
- * @author Ryan D. Brooks
- */
-public class VariableMap {
- private final HashMap<String, Object> variableMap = new HashMap<String, Object>();
-
- public VariableMap() {
- }
-
- /**
- * @throws OseeArgumentException
- */
- public VariableMap(Object... optionArgs) throws OseeArgumentException {
- for (int i = 0; i < optionArgs.length; i += 2) {
- if (optionArgs[i] instanceof String) {
- variableMap.put((String) optionArgs[i], optionArgs[i + 1]);
- } else if (optionArgs[i] == null) {
- throw new OseeArgumentException(String.format("The %dth option must not be null", i));
- } else {
- throw new OseeArgumentException(String.format("The %dth option must be of type string but is of type %s",
- i, optionArgs[i].getClass().getName()));
- }
- }
- }
-
- public void setValue(String variableName, Object value) {
- variableMap.put(variableName, value);
- }
-
- public ArtifactType getArtifactType(String parameterName) throws OseeArgumentException {
- return getSingleCollectionValue(ArtifactType.class, parameterName);
- }
-
- public AttributeType getAttributeType(String parameterName) throws OseeArgumentException {
- return getSingleCollectionValue(AttributeType.class, parameterName);
- }
-
- public String getString(String parameterName) throws OseeArgumentException {
- return getValue(String.class, parameterName);
- }
-
- public Branch getBranch(String parameterName) throws OseeArgumentException {
- return getValue(Branch.class, parameterName);
- }
-
- public boolean getBoolean(String parameterName) throws OseeArgumentException {
- return getValue(Boolean.class, parameterName) != null && getValue(Boolean.class, parameterName);
- }
-
- @SuppressWarnings("unchecked")
- public <T> Collection<T> getCollection(Class<T> clazz, String parameterName) throws OseeArgumentException {
- return getValue(Collection.class, parameterName);
- }
-
- public User getUser(String parameterName) throws OseeArgumentException {
- return getValue(User.class, parameterName);
- }
-
- public List<Artifact> getArtifacts(String parameterName) throws OseeArgumentException {
- Collection<Artifact> artiafcts = getCollection(Artifact.class, parameterName);
- if (artiafcts == null) {
- return new ArrayList<Artifact>();
- }
- return new ArrayList<Artifact>(artiafcts);
- }
-
- private <T> T getSingleCollectionValue(Class<T> clazz, String parameterName) throws OseeArgumentException {
- Collection<T> objects = getCollection(clazz, parameterName);
- if (objects.size() != 1) {
- throw new OseeArgumentException("Require a collection of size 1 not " + objects.size());
- }
- return objects.iterator().next();
- }
-
- private <T> T getValue(Class<T> clazz, String variableName) throws OseeArgumentException {
- Object value = variableMap.get(variableName);
-
- if (value != null && !clazz.isInstance(value)) {
- throw new OseeArgumentException(
- "Expecting object of type " + clazz.getName() + " not " + value.getClass().getName());
- }
- return clazz.cast(value);
- }
-
- public Object getValue(String variableName) throws OseeArgumentException {
- return variableMap.get(variableName);
- }
+/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.ui.skynet.blam; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import org.eclipse.osee.framework.db.connection.exception.OseeArgumentException; +import org.eclipse.osee.framework.skynet.core.User; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactType; +import org.eclipse.osee.framework.skynet.core.artifact.Branch; +import org.eclipse.osee.framework.skynet.core.attribute.AttributeType; + +/** + * @author Ryan D. Brooks + */ +public class VariableMap { + private final HashMap<String, Object> variableMap = new HashMap<String, Object>(); + + public VariableMap() { + } + + /** + * @throws OseeArgumentException + */ + public VariableMap(Object... optionArgs) throws OseeArgumentException { + for (int i = 0; i < optionArgs.length; i += 2) { + if (optionArgs[i] instanceof String) { + variableMap.put((String) optionArgs[i], optionArgs[i + 1]); + } else if (optionArgs[i] == null) { + throw new OseeArgumentException(String.format("The %dth option must not be null", i)); + } else { + throw new OseeArgumentException(String.format("The %dth option must be of type string but is of type %s", + i, optionArgs[i].getClass().getName())); + } + } + } + + public void setValue(String variableName, Object value) { + variableMap.put(variableName, value); + } + + public ArtifactType getArtifactType(String parameterName) throws OseeArgumentException { + return getSingleCollectionValue(ArtifactType.class, parameterName); + } + + public AttributeType getAttributeType(String parameterName) throws OseeArgumentException { + return getSingleCollectionValue(AttributeType.class, parameterName); + } + + public String getString(String parameterName) throws OseeArgumentException { + return getValue(String.class, parameterName); + } + + public Branch getBranch(String parameterName) throws OseeArgumentException { + return getValue(Branch.class, parameterName); + } + + public Boolean getBoolean(String parameterName) throws OseeArgumentException { + return getValue(Boolean.class, parameterName); + } + + @SuppressWarnings("unchecked") + public <T> Collection<T> getCollection(Class<T> clazz, String parameterName) throws OseeArgumentException { + return getValue(Collection.class, parameterName); + } + + public User getUser(String parameterName) throws OseeArgumentException { + return getValue(User.class, parameterName); + } + + public List<Artifact> getArtifacts(String parameterName) throws OseeArgumentException { + Collection<Artifact> artiafcts = getCollection(Artifact.class, parameterName); + if (artiafcts == null) { + return new ArrayList<Artifact>(); + } + return new ArrayList<Artifact>(artiafcts); + } + + private <T> T getSingleCollectionValue(Class<T> clazz, String parameterName) throws OseeArgumentException { + Collection<T> objects = getCollection(clazz, parameterName); + if (objects.size() != 1) { + throw new OseeArgumentException("Require a collection of size 1 not " + objects.size()); + } + return objects.iterator().next(); + } + + private <T> T getValue(Class<T> clazz, String variableName) throws OseeArgumentException { + Object value = variableMap.get(variableName); + + if (value != null && !clazz.isInstance(value)) { + throw new OseeArgumentException( + "Expecting object of type " + clazz.getName() + " not " + value.getClass().getName()); + } + return clazz.cast(value); + } + + public Object getValue(String variableName) throws OseeArgumentException { + return variableMap.get(variableName); + } }
\ No newline at end of file |