001: /*
002: * Created on Feb 27, 2004
003: *
004: * To change the template for this generated file go to
005: * Window - Preferences - Java - Code Generation - Code and Comments
006: */
007: package org.vfny.geoserver.action.validation;
008:
009: import org.geotools.feature.Feature;
010: import org.geotools.validation.Validation;
011: import org.geotools.validation.ValidationResults;
012: import java.util.HashMap;
013: import java.util.Map;
014: import java.util.logging.Level;
015: import java.util.logging.Logger;
016:
017: /**
018: * TestValidationResults purpose.
019: * <p>
020: * Description of TestValidationResults ...
021: * </p>
022: *
023: * @author dzwiers, Refractions Research, Inc.
024: * @author $Author: jive $ (last modification)
025: * @version $Id: TestValidationResults.java 7746 2007-11-13 15:38:35Z aaime $
026: */
027: public class TestValidationResults implements ValidationResults {
028: public static final String CURRENTLY_SELECTED_KEY = "TestValidationResults";
029: Validation v = null;
030:
031: //HACK for JODY cause he messed up and then whined alot.
032: boolean run = false;
033:
034: public void setValidation(Validation v) {
035: this .v = v;
036: run = true;
037: }
038:
039: private String toMessage(String message) {
040: StringBuffer buf = new StringBuffer();
041: buf.append(v.getName());
042: buf.append(": ");
043: buf.append(message);
044: buf.append("\n");
045: buf.append(v.getDescription());
046:
047: return buf.toString();
048: }
049:
050: Map errors = new HashMap();
051:
052: public Map getErrors() {
053: return errors;
054: }
055:
056: public void error(Feature f, String s) {
057: String message = toMessage(s);
058: Logger logger = org.geotools.util.logging.Logging
059: .getLogger("org.vfny.geoserver");
060:
061: if (logger.getLevel().equals(Level.FINEST)) {
062: logger.warning(message);
063: }
064:
065: errors.put(f, message);
066: }
067:
068: Map warning = new HashMap();
069:
070: public Map getWarnings() {
071: return warning;
072: }
073:
074: public void warning(Feature f, String s) {
075: String message = toMessage(s);
076: Logger logger = Logger.getLogger("org.vfny.geoserver");
077:
078: if (logger.getLevel().equals(Level.FINEST)) {
079: logger.warning(message);
080: }
081:
082: warning.put(f, message);
083: }
084:
085: /**
086: * Access run property.
087: *
088: * @return Returns the run.
089: */
090: public boolean isRun() {
091: return run;
092: }
093:
094: /**
095: * Set run to run.
096: *
097: * @param run The run to set.
098: */
099: public void setRun(boolean run) {
100: this.run = run;
101: }
102: }
|