Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/parsers/WstParser.java @ 6508:b2eab164a441
Backend: WST parser. Detect ranges of years in column-datum
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 28 Jun 2013 19:24:46 +0200 |
parents | 1c68d4b2a1c0 |
children | 49dd3e478ccd af70e3ab2e83 |
comparison
equal
deleted
inserted
replaced
6506:1c68d4b2a1c0 | 6508:b2eab164a441 |
---|---|
59 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)"); | 59 Pattern.compile("\\*\\s*[kK][mM]\\s+(.+)"); |
60 | 60 |
61 public static final Pattern UNIT = | 61 public static final Pattern UNIT = |
62 Pattern.compile("[^\\[]*\\[([^]]+)\\].*"); | 62 Pattern.compile("[^\\[]*\\[([^]]+)\\].*"); |
63 | 63 |
64 public static final Pattern YEAR_INTERVAL = | |
65 Pattern.compile("(\\d{4})\\s*[-/]\\s*(\\d{4})"); | |
66 | |
64 public static final double INTERVAL_GAP = 0.00001d; | 67 public static final double INTERVAL_GAP = 0.00001d; |
65 | 68 |
66 protected ImportWst wst; | 69 protected ImportWst wst; |
67 | 70 |
68 protected ImportRange lastRange; | 71 protected ImportRange lastRange; |
82 this.wst = wst; | 85 this.wst = wst; |
83 } | 86 } |
84 | 87 |
85 public static ImportTimeInterval guessDate(String string) { | 88 public static ImportTimeInterval guessDate(String string) { |
86 try { | 89 try { |
90 Matcher m = YEAR_INTERVAL.matcher(string); | |
91 if (m.matches()) { | |
92 return new ImportTimeInterval( | |
93 DateGuesser.guessDate(m.group(1)), | |
94 DateGuesser.guessDate(m.group(2))); | |
95 } | |
96 | |
87 return new ImportTimeInterval( | 97 return new ImportTimeInterval( |
88 DateGuesser.guessDate(string)); | 98 DateGuesser.guessDate(string)); |
89 } | 99 } |
90 catch (IllegalArgumentException iae) { | 100 catch (IllegalArgumentException iae) { |
91 log.warn("WST: String '" + string + | 101 log.warn("WST: String '" + string + |