Save This Page
Home » sitemesh-2.3 » com.opensymphony.module » sitemesh » html » [javadoc | source]
    1   package com.opensymphony.module.sitemesh.html;
    2   
    3   public abstract class BasicRule implements TagRule {
    4   
    5       private final String[] acceptableTagNames;
    6   
    7       protected HTMLProcessorContext context;
    8   
    9       protected BasicRule(String[] acceptableTagNames) {
   10           this.acceptableTagNames = acceptableTagNames;
   11       }
   12   
   13       protected BasicRule(String acceptableTagName) {
   14           this.acceptableTagNames = new String[] {acceptableTagName};
   15       }
   16   
   17       protected BasicRule() {
   18           this.acceptableTagNames = null;
   19       }
   20   
   21       public void setContext(HTMLProcessorContext context) {
   22           this.context = context;
   23       }
   24   
   25       public boolean shouldProcess(String name) {
   26           if (acceptableTagNames == null || acceptableTagNames.length < 1) {
   27               throw new UnsupportedOperationException(getClass().getName()
   28                       + " should be constructed with acceptableTagNames OR should implement shouldProcess()");
   29           }
   30   
   31           for (int i=0; i<acceptableTagNames.length; i++) {
   32               if (name.toLowerCase().equals(acceptableTagNames[i])) return true;
   33           }
   34           return false;
   35       }
   36   
   37       public abstract void process(Tag tag);
   38   
   39   }

Save This Page
Home » sitemesh-2.3 » com.opensymphony.module » sitemesh » html » [javadoc | source]