Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/wsplgen/ProblemObserver.java @ 1148:302461d5d071
Cosmetics.
flys-artifacts/trunk@2678 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 08 Sep 2011 11:29:04 +0000 |
parents | e7d5452a7381 |
children | 64b465699a24 |
line wrap: on
line source
package de.intevation.flys.wsplgen; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.log4j.Logger; import de.intevation.flys.artifacts.model.WSPLGENJob; public class ProblemObserver extends JobObserver { private static Logger logger = Logger.getLogger(ProblemObserver.class); public static final Pattern WSPLGEN_ERROR_START = Pattern.compile( ".*->Fehler\\s*\\((\\d+)\\).*", Pattern.DOTALL); public static final Pattern WSPLGEN_ERROR_END = Pattern.compile( ".*<-Fehler .*", Pattern.DOTALL); public static final Pattern WSPLGEN_WARNING_START = Pattern.compile( ".*->Warnung\\s*\\((\\d+)\\).*", Pattern.DOTALL); public static final Pattern WSPLGEN_WARNING_END = Pattern.compile( ".*<-Warnung .*", Pattern.DOTALL); protected int error; protected int warning; protected Map<Integer, String> errorMsg; protected Map<Integer, String> warningMsg; public ProblemObserver(WSPLGENJob job) { super(job); error = -1; warning = -1; errorMsg = new HashMap<Integer, String>(); warningMsg = new HashMap<Integer, String>(); } public void run() { logger.debug("Start observation..."); super.run(); } @Override protected void prepareRegexes() { // do nothing } @Override protected void update(String log) { Matcher startError = WSPLGEN_ERROR_START.matcher(log); if (startError.matches()) { error = Integer.parseInt(startError.group(1)); return; } Matcher endError = WSPLGEN_ERROR_END.matcher(log); if (endError.matches()) { error = -1; } if (error > 0) { errorMsg.put(new Integer(error), log); } Matcher startWarning = WSPLGEN_WARNING_START.matcher(log); if (startWarning.matches()) { warning = Integer.parseInt(startWarning.group(1)); return; } Matcher endWarning = WSPLGEN_WARNING_END.matcher(log); if (endWarning.matches()) { warning = -1; } if (warning > 0) { warningMsg.put(new Integer(warning), log); } } public int numErrors() { return errorMsg.size(); } public int numWarnings() { return warningMsg.size(); } } // vim:set ts=4 sw=4 si et sta sts=5 fenc=utf-8 :