package com.jaamsim.input;

import java.util.ArrayList;

import com.jaamsim.render.Action;
import com.sandwell.JavaSimulation.InputErrorException;
import com.sandwell.JavaSimulation.ListInput;
import com.sandwell.JavaSimulation.StringVector;

public class ActionListInput extends ListInput<ArrayList<Action.Binding>>{

	public ActionListInput(String key, String cat, ArrayList<Action.Binding> def) {
		super(key, cat, def);
	}

	@Override
	public void parse(StringVector input) throws InputErrorException {
		ArrayList<String> strings = new ArrayList<String>(input.size());
		for (String s : input) {
			strings.add(s);
		}

		value = new ArrayList<Action.Binding>();

		ArrayList<ArrayList<String>> bindings = InputAgent.splitForNestedBraces(strings);
		for( ArrayList<String> b : bindings) {
			Action.Binding binding = parseBinding(b);
			value.add(binding);
		}
	}

	public Action.Binding parseBinding(ArrayList<String> tokens) {
		if (tokens.size() != 4|| !tokens.get(0).equals("{") || !tokens.get(3).equals("}")) {
			throw new InputErrorException("Malformed binding entry: %s", tokens.toString());
		}

		Action.Binding binding = new Action.Binding();
		binding.actionName = tokens.get(1);
		binding.outputName = tokens.get(2);
		return binding;
	}
}

@@ -1,8 +1,610 @@
+/*%0A * JaamSim Discrete Event Simulation%0A * Copyright (C) 2013 Ausenco Engineering Canada Inc.%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A */%0A
 package 

add copyright header that was missed