001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2004 TOPP - www.openplans.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.validation;
018:
019: import java.util.ArrayList;
020:
021: import org.geotools.feature.Feature;
022:
023: /**
024: * RoadNetworkValidationResults purpose.
025: * <p>
026: * Description of RoadNetworkValidationResults ...
027: * <p>
028: * Capabilities:
029: * <ul>
030: * </li></li>
031: * </ul>
032: * Example Use:
033: * <pre><code>
034: * RoadNetworkValidationResults x = new RoadNetworkValidationResults(...);
035: * </code></pre>
036: *
037: * @author bowens, Refractions Research, Inc.
038: * @author $Author: sploreg $ (last modification)
039: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/test/java/org/geotools/validation/RoadNetworkValidationResults.java $
040: * @version $Id: RoadNetworkValidationResults.java 22266 2006-10-19 11:30:55Z acuster $
041: */
042: public class RoadNetworkValidationResults implements ValidationResults {
043:
044: ArrayList validationList; // list of validations that are to be performed
045: ArrayList failedFeatures;
046: ArrayList warningFeatures;
047: ArrayList failureMessages;
048: ArrayList warningMessages;
049:
050: /**
051: * RoadNetworkValidationResults constructor.
052: * <p>
053: * Description
054: * </p>
055: *
056: */
057: public RoadNetworkValidationResults() {
058: validationList = new ArrayList();
059: failedFeatures = new ArrayList();
060: warningFeatures = new ArrayList();
061: failureMessages = new ArrayList();
062: warningMessages = new ArrayList();
063: }
064:
065: /**
066: * Override setValidation.
067: * <p>
068: * Description ...
069: * </p>
070: * @see org.geotools.validation.ValidationResults#setValidation(org.geotools.validation.Validation)
071: *
072: * @param validation
073: */
074: public void setValidation(Validation validation) {
075: validationList.add(validation);
076: }
077:
078: /**
079: * Override error.
080: * <p>
081: * Description ...
082: * </p>
083: * @see org.geotools.validation.ValidationResults#error(org.geotools.feature.Feature, java.lang.String)
084: *
085: * @param feature
086: * @param message
087: */
088: public void error(Feature feature, String message) {
089: failedFeatures.add(feature);
090: failureMessages.add(feature.getID() + ": " + message);
091: }
092:
093: /**
094: * Override warning.
095: * <p>
096: * Description ...
097: * </p>
098: * @see org.geotools.validation.ValidationResults#warning(org.geotools.feature.Feature, java.lang.String)
099: *
100: * @param feature
101: * @param message
102: */
103: public void warning(Feature feature, String message) {
104: warningFeatures.add(feature);
105: warningMessages.add(feature.getID() + ": " + message);
106: }
107:
108: /**
109: * getFailedMessages purpose.
110: * <p>
111: * Description ...
112: * </p>
113: */
114: public String[] getFailedMessages() {
115: String[] result = new String[failureMessages.size()];
116: for (int i = 0; i < failureMessages.size(); i++) {
117: result[i] = (String) failureMessages.get(i);
118: }
119:
120: return result;
121: }
122:
123: /**
124: * getWarningMessages purpose.
125: * <p>
126: * Description ...
127: * </p>
128: */
129: public String[] getWarningMessages() {
130: String[] result = new String[warningMessages.size()];
131: for (int i = 0; i < warningMessages.size(); i++) {
132: result[i] = (String) warningMessages.get(i);
133: }
134:
135: return result;
136: }
137: }
|