/*
 *    GeoTools - OpenSource mapping toolkit
 *    http://geotools.org
 *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
 *    (C) 2004 TOPP - www.openplans.org
 *
 *    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.
 */
package org.geotools.validation;

import java.util.ArrayList;

import org.geotools.feature.Feature;

/**
 * RoadNetworkValidationResults purpose.
 * <p>
 * Description of RoadNetworkValidationResults ...
 * <p>
 * Capabilities:
 * <ul>
 * </li></li>
 * </ul>
 * Example Use:
 * <pre><code>
 * RoadNetworkValidationResults x = new RoadNetworkValidationResults(...);
 * </code></pre>
 * 
 * @author bowens, Refractions Research, Inc.
 * @author $Author: sploreg $ (last modification)
 * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/test/java/org/geotools/validation/RoadNetworkValidationResults.java $
 * @version $Id: RoadNetworkValidationResults.java 22266 2006-10-19 11:30:55Z acuster $
 */
public class RoadNetworkValidationResults implements ValidationResults {


	ArrayList validationList;	// list of validations that are to be performed
	ArrayList failedFeatures;
	ArrayList warningFeatures;
	ArrayList failureMessages;
	ArrayList warningMessages;
	
	
	/**
	 * RoadNetworkValidationResults constructor.
	 * <p>
	 * Description
	 * </p>
	 * 
	 */
	public RoadNetworkValidationResults() {
		validationList = new ArrayList();
		failedFeatures = new ArrayList();
		warningFeatures = new ArrayList();
		failureMessages = new ArrayList();
		warningMessages = new ArrayList();
	}

	/**
	 * Override setValidation.
	 * <p>
	 * Description ...
	 * </p>
	 * @see org.geotools.validation.ValidationResults#setValidation(org.geotools.validation.Validation)
	 * 
	 * @param validation
	 */
	public void setValidation(Validation validation) {
		validationList.add(validation);
	}

	/**
	 * Override error.
	 * <p>
	 * Description ...
	 * </p>
	 * @see org.geotools.validation.ValidationResults#error(org.geotools.feature.Feature, java.lang.String)
	 * 
	 * @param feature
	 * @param message
	 */
	public void error(Feature feature, String message) {
		failedFeatures.add(feature);
		failureMessages.add(feature.getID() + ": " + message);
	}

	/**
	 * Override warning.
	 * <p>
	 * Description ...
	 * </p>
	 * @see org.geotools.validation.ValidationResults#warning(org.geotools.feature.Feature, java.lang.String)
	 * 
	 * @param feature
	 * @param message
	 */
	public void warning(Feature feature, String message) {
		warningFeatures.add(feature);
		warningMessages.add(feature.getID() + ": " + message);
	}


	/**
	 * getFailedMessages purpose.
	 * <p>
	 * Description ...
	 * </p>
	 */
	public String[] getFailedMessages()
	{
		String[] result = new String[failureMessages.size()];
		for (int i=0; i<failureMessages.size(); i++)
		{
			result[i] = (String)failureMessages.get(i);
		}
		
		return result;
	}
	
	
	/**
	 * getWarningMessages purpose.
	 * <p>
	 * Description ...
	 * </p>
	 */
	public String[] getWarningMessages()
	{
		String[] result = new String[warningMessages.size()];
		for (int i=0; i<warningMessages.size(); i++)
		{
			result[i] = (String)warningMessages.get(i);
		}
	
		return result;
	}
}
