Save This Page
Home » sitemesh-2.3 » com.opensymphony.module » sitemesh » html » [javadoc | source]
    1   package com.opensymphony.module.sitemesh.html;
    2   
    3   import com.opensymphony.module.sitemesh.html.util.CharArray;
    4   
    5   public abstract class BlockExtractingRule extends BasicRule {
    6   
    7       private boolean includeEnclosingTags;
    8   
    9       protected BlockExtractingRule(boolean includeEnclosingTags, String acceptableTagName) {
   10           super(acceptableTagName);
   11           this.includeEnclosingTags = includeEnclosingTags;
   12       }
   13   
   14       protected BlockExtractingRule(boolean includeEnclosingTags) {
   15           this.includeEnclosingTags = includeEnclosingTags;
   16       }
   17   
   18       public void process(Tag tag) {
   19           if (tag.getType() == Tag.OPEN) {
   20               if (includeEnclosingTags) {
   21                   tag.writeTo(context.currentBuffer());
   22               }
   23               context.pushBuffer(createBuffer());
   24               start(tag);
   25           } else if (tag.getType() == Tag.CLOSE) {
   26               end(tag);
   27               context.popBuffer();
   28               if (includeEnclosingTags) {
   29                   tag.writeTo(context.currentBuffer());
   30               }
   31           }
   32       }
   33   
   34       protected void start(Tag tag) {
   35       }
   36   
   37       protected void end(Tag tag) {
   38       }
   39   
   40       protected CharArray createBuffer() {
   41           return new CharArray(512);
   42       }
   43   
   44   }

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