diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java	Thu Oct 20 13:45:45 2011 +0000
@@ -0,0 +1,51 @@
+package de.intevation.flys.themes;
+
+import java.io.Serializable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public class ThemeMapping implements Serializable {
+
+    protected String from;
+    protected String to;
+    protected String patternStr;
+
+    protected Pattern pattern;
+
+
+    public ThemeMapping(String from, String to) {
+        this(from, to, null);
+    }
+
+
+    public ThemeMapping(String from, String to, String patternStr) {
+        this.from       = from;
+        this.to         = to;
+        this.patternStr = patternStr;
+
+        this.pattern = Pattern.compile(patternStr);
+    }
+
+
+    public String getFrom() {
+        return from;
+    }
+
+
+    public String getTo() {
+        return to;
+    }
+
+
+    public String getPatternStr() {
+        return patternStr;
+    }
+
+
+    public boolean applyPattern(String text) {
+        Matcher m = pattern.matcher(text);
+        return m.matches();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org