possibility to use CSS prefix for menu items
[svjatoslav_commons.git] / src / main / java / eu / svjatoslav / commons / network / navigation / NavigationItem.java
index 0deca95..22ba6b0 100755 (executable)
@@ -1,7 +1,7 @@
 /*
  * Svjatoslav Commons - shared library of common functionality.
  * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- * 
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of version 3 of the GNU Lesser General Public License
  * or later as published by the Free Software Foundation.
@@ -26,6 +26,11 @@ public class NavigationItem {
        private NavigationItem parent;
        private final String linkUrl;
 
+       /**
+        * CSS prefix is inherited to child menu items.
+        */
+       private String cssPrefix;
+
        public NavigationItem(final Locale... localeOrder) {
                if (localeOrder.length == 0)
                        this.localeOrder = new Locale[] { Locale.ENG };
@@ -53,6 +58,16 @@ public class NavigationItem {
                return item;
        }
 
+       protected String getCssPrefix() {
+               if (cssPrefix != null)
+                       return cssPrefix;
+
+               if (parent == null)
+                       return null;
+
+               return parent.getCssPrefix();
+       }
+
        public String getLinkUrl() {
                return linkUrl;
        }
@@ -107,6 +122,10 @@ public class NavigationItem {
                return WildCardMatcher.match(url, matchingPattern);
        }
 
+       public void setCssPrefix(final String cssPrefix) {
+               this.cssPrefix = cssPrefix;
+       }
+
        public NavigationItem setPattern(final String pattern) {
                matchingPattern = pattern;
                return this;