diff flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java @ 1828:9562ca537143

Added new optional condition for theme-mappings: the output name. flys-artifacts/trunk@3158 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 04 Nov 2011 08:59:42 +0000
parents 6ed439ff61bf
children e74e707ff650
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java	Fri Nov 04 08:52:33 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeMapping.java	Fri Nov 04 08:59:42 2011 +0000
@@ -28,11 +28,14 @@
     /** Given masterAttr pattern (held against masterartifacts attributes). */
     protected String masterAttr;
 
+    /** Given output for which mapping is valid. */
+    protected String output;
+
     protected Pattern pattern;
 
 
     public ThemeMapping(String from, String to) {
-        this(from, to, null, null);
+        this(from, to, null, null, null);
     }
 
 
@@ -40,12 +43,14 @@
         String from,
         String to,
         String patternStr,
-        String masterAttr)
+        String masterAttr,
+        String output)
    {
         this.from       = from;
         this.to         = to;
         this.patternStr = patternStr;
         this.masterAttr = masterAttr;
+        this.output     = output;
 
         this.pattern = Pattern.compile(patternStr);
     }
@@ -113,5 +118,18 @@
         // Test.
         return artifact.getDataAsString(parts[0]).equals(parts[1]);
     }
+
+
+    /**
+     * Returns true if no output condition exists, or the condition is met
+     * in parameter output.
+     */
+    public boolean outputMatches(String output) {
+        if (this.output == null || this.output.equals("")) {
+            return true;
+        }
+
+        return this.output.equals(output);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org