# HG changeset patch # User Felix Wolfsteller # Date 1357642623 -3600 # Node ID a70de52982481262bce0ef0a0dd288daa217a5f9 # Parent 34398f424cfd8b03fc2beba594866d5d192a2b8c ImportRiver: Add helper implementation of a CrossSectionParserCallback. diff -r 34398f424cfd -r a70de5298248 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Mon Jan 07 11:55:46 2013 +0100 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Tue Jan 08 11:57:03 2013 +0100 @@ -156,6 +156,42 @@ protected River peer; + + /** Callback-implementation for CrossSectionParsers. */ + class ImportRiverCrossSectionParserCallback implements CrossSectionParser.Callback { + Set files = new HashSet(); + String type; + + + /** + * Create new Callback, given type which is used for logging + * purposes only. + */ + public ImportRiverCrossSectionParserCallback (String type) { + this.type = type; + } + + + /** Accept file if not duplicate. */ + public boolean accept(File file) { + HashedFile hf = new HashedFile(file); + boolean success = files.add(hf); + if (!success) { + log.warn(type + " file '" + file + "' seems to be a duplicate."); + } + return success; + } + + + /** Add crosssection. */ + public void parsed(CrossSectionParser parser) { + log.debug("callback from " + type + " parser"); + + addCrossSections(parser); + } + } + + public ImportRiver() { hyks = new ArrayList(); crossSections = new ArrayList();