<commit_before>package edu.kit.iks.Cryptographics;

import java.lang.reflect.Constructor;
import java.util.List;

import edu.kit.iks.CryptographicsLib.AbstractController;
import edu.kit.iks.CryptographicsLib.AbstractVisualizationController;
import edu.kit.iks.CryptographicsLib.AbstractVisualizationInfo;

/**
 * An instance of this class is a wrapper for visualization controller to
 * outsource common UI elements like navigation buttons
 * 
 * @author <NAME>
 */
public class VisualizationContainerController extends AbstractController {

	/**
	 * Active child controller. Overrides {_activeChildController} from
	 * {AbstractController}
	 */
	private int currentVisualizationControllerIndex;

	private AbstractVisualizationController[] visualizationControllers;

	private AbstractVisualizationInfo visualizationInfo;

	/**
	 * Container to display the actual visualization of a procedure
	 */
	private VisualizationContainerView view;

	/**
	 * Constructor initializing a new instance of
	 * {VisualizationContainerController}
	 * 
	 * @param visualizationInfo
	 *            Object of {VisualizationInfo} containing the data to
	 *            instantiate related controllers from
	 */
	public VisualizationContainerController(
			AbstractVisualizationInfo visualizationInfo) {
		this.visualizationInfo = visualizationInfo;
		List<Class> childClasses = this.visualizationInfo
				.getControllerClasses();

		// Create an array that can hold all visualization controllers.
		// The controller's will be instantiated on demand (lazily).
		this.visualizationControllers = new AbstractVisualizationController[childClasses
				.size()];
	}

	/**
	 * Gets the {VisualizationInfo}-object of the current visualization
	 * 
	 * @return {VizualizationInfo}-object of the current visualization
	 */
	public AbstractVisualizationInfo getVisualizationInfo() {
		return this.visualizationInfo;
	}

	@Override
	public void loadView() {
		this.view = new VisualizationContainerView();
	}

	@Override
	public VisualizationContainerView getView() {
		return this.view;
	}

	public void setCurrentVisualizationControllerIndex(int index) {
		AbstractVisualizationController oldController = this
				.getCurrentVisualizationController();
		if (oldController != null) {
			this.removeChildController(oldController);

			// Remove view
			this.getView().remove(oldController.getView());
			oldController.unloadView();
		}

		// Load new controller if necessary.
		AbstractVisualizationController newController = this.visualizationControllers[index];
		if (newController == null) {
			newController = this.loadVisualizationController(index);
		}

		// Set new controller
		this.currentVisualizationControllerIndex = index;
		this.addChildController(newController);

		// Load new view
		newController.loadView();
		this.getView().add(newController.getView());
	}

	public AbstractVisualizationController getCurrentVisualizationController() {
		return this.visualizationControllers[this.currentVisualizationControllerIndex];
	}

	public AbstractVisualizationController currentVisualizationController() {
		return this.visualizationControllers[this.currentVisualizationControllerIndex];
	}

	public boolean hasNextVisualizationController() {
		return (this.currentVisualizationControllerIndex < this.visualizationInfo
				.getControllerClasses().size() - 1);
	}

	public void presentNextVisualizationController() {
		this.setCurrentVisualizationControllerIndex(this.currentVisualizationControllerIndex + 1);
	}

	public boolean hasPreviousVisualizationController() {
		return (this.currentVisualizationControllerIndex > 1);
	}

	public void presentPreviousVisualizationController() {
		this.setCurrentVisualizationControllerIndex(this.currentVisualizationControllerIndex - 1);
	}

	private AbstractVisualizationController loadVisualizationController(int index) {
		Constructor<AbstractVisualizationController> controllerConstructor = null;
		Class<AbstractVisualizationController> controllerClass = this.visualizationInfo.getControllerClasses().get(index);
		AbstractVisualizationController controller = null;
		try {
			// visualizationinfo is now passed to the contructor.
			controllerConstructor = controllerClass.getConstructor(AbstractVisualizationInfo.class);
	        controller = controllerConstructor.newInstance(this.visualizationInfo);	
		} catch (InstantiationException | IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		this.visualizationControllers[index] = controller;
		return controller;
	}
}<commit_msg>add catch clauses for unhandled exceptions<commit_after>package edu.kit.iks.Cryptographics;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

import edu.kit.iks.CryptographicsLib.AbstractController;
import edu.kit.iks.CryptographicsLib.AbstractVisualizationController;
import edu.kit.iks.CryptographicsLib.AbstractVisualizationInfo;

/**
 * An instance of this class is a wrapper for visualization controller to
 * outsource common UI elements like navigation buttons
 * 
 * @author <NAME>
 */
public class VisualizationContainerController extends AbstractController {

	/**
	 * Active child controller. Overrides {_activeChildController} from
	 * {AbstractController}
	 */
	private int currentVisualizationControllerIndex;

	private AbstractVisualizationController[] visualizationControllers;

	private AbstractVisualizationInfo visualizationInfo;

	/**
	 * Container to display the actual visualization of a procedure
	 */
	private VisualizationContainerView view;

	/**
	 * Constructor initializing a new instance of
	 * {VisualizationContainerController}
	 * 
	 * @param visualizationInfo
	 *            Object of {VisualizationInfo} containing the data to
	 *            instantiate related controllers from
	 */
	public VisualizationContainerController(
			AbstractVisualizationInfo visualizationInfo) {
		this.visualizationInfo = visualizationInfo;
		List<Class> childClasses = this.visualizationInfo
				.getControllerClasses();

		// Create an array that can hold all visualization controllers.
		// The controller's will be instantiated on demand (lazily).
		this.visualizationControllers = new AbstractVisualizationController[childClasses
				.size()];
	}

	/**
	 * Gets the {VisualizationInfo}-object of the current visualization
	 * 
	 * @return {VizualizationInfo}-object of the current visualization
	 */
	public AbstractVisualizationInfo getVisualizationInfo() {
		return this.visualizationInfo;
	}

	@Override
	public void loadView() {
		this.view = new VisualizationContainerView();
	}

	@Override
	public VisualizationContainerView getView() {
		return this.view;
	}

	public void setCurrentVisualizationControllerIndex(int index) {
		AbstractVisualizationController oldController = this
				.getCurrentVisualizationController();
		if (oldController != null) {
			this.removeChildController(oldController);

			// Remove view
			this.getView().remove(oldController.getView());
			oldController.unloadView();
		}

		// Load new controller if necessary.
		AbstractVisualizationController newController = this.visualizationControllers[index];
		if (newController == null) {
			newController = this.loadVisualizationController(index);
		}

		// Set new controller
		this.currentVisualizationControllerIndex = index;
		this.addChildController(newController);

		// Load new view
		newController.loadView();
		this.getView().add(newController.getView());
	}

	public AbstractVisualizationController getCurrentVisualizationController() {
		return this.visualizationControllers[this.currentVisualizationControllerIndex];
	}

	public AbstractVisualizationController currentVisualizationController() {
		return this.visualizationControllers[this.currentVisualizationControllerIndex];
	}

	public boolean hasNextVisualizationController() {
		return (this.currentVisualizationControllerIndex < this.visualizationInfo
				.getControllerClasses().size() - 1);
	}

	public void presentNextVisualizationController() {
		this.setCurrentVisualizationControllerIndex(this.currentVisualizationControllerIndex + 1);
	}

	public boolean hasPreviousVisualizationController() {
		return (this.currentVisualizationControllerIndex > 1);
	}

	public void presentPreviousVisualizationController() {
		this.setCurrentVisualizationControllerIndex(this.currentVisualizationControllerIndex - 1);
	}

	private AbstractVisualizationController loadVisualizationController(int index) {
		Constructor<AbstractVisualizationController> controllerConstructor = null;
		Class<AbstractVisualizationController> controllerClass = this.visualizationInfo.getControllerClasses().get(index);
		AbstractVisualizationController controller = null;
		try {
			// visualizationinfo is now passed to the contructor.
			controllerConstructor = controllerClass.getConstructor(AbstractVisualizationInfo.class);
	        controller = controllerConstructor.newInstance(this.visualizationInfo);	
		} catch (InstantiationException | IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		this.visualizationControllers[index] = controller;
		return controller;
	}
}
{'fraction_non_alphanumeric': 0.07851325955314262, 'fraction_numerical': 0.0008352474420547087, 'mean_word_length': 5.415941058271936, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5741748', 'n_tokens_mistral': 2618, 'n_tokens_neox': 2316, 'n_words': 559}