Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java @ 1747:d2a17e990c70
Improved the Themes: we now support special themes for facets which need to match a given pattern string.
flys-artifacts/trunk@3047 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 20 Oct 2011 13:45:45 +0000 |
parents | |
children | 6ed439ff61bf |
comparison
equal
deleted
inserted
replaced
1746:94faf08d143c | 1747:d2a17e990c70 |
---|---|
1 package de.intevation.flys.themes; | |
2 | |
3 import java.io.Serializable; | |
4 import java.util.regex.Matcher; | |
5 import java.util.regex.Pattern; | |
6 | |
7 | |
8 public class ThemeMapping implements Serializable { | |
9 | |
10 protected String from; | |
11 protected String to; | |
12 protected String patternStr; | |
13 | |
14 protected Pattern pattern; | |
15 | |
16 | |
17 public ThemeMapping(String from, String to) { | |
18 this(from, to, null); | |
19 } | |
20 | |
21 | |
22 public ThemeMapping(String from, String to, String patternStr) { | |
23 this.from = from; | |
24 this.to = to; | |
25 this.patternStr = patternStr; | |
26 | |
27 this.pattern = Pattern.compile(patternStr); | |
28 } | |
29 | |
30 | |
31 public String getFrom() { | |
32 return from; | |
33 } | |
34 | |
35 | |
36 public String getTo() { | |
37 return to; | |
38 } | |
39 | |
40 | |
41 public String getPatternStr() { | |
42 return patternStr; | |
43 } | |
44 | |
45 | |
46 public boolean applyPattern(String text) { | |
47 Matcher m = pattern.matcher(text); | |
48 return m.matches(); | |
49 } | |
50 } | |
51 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |