Save This Page
Home » sitemesh-2.3 » com.opensymphony.module » sitemesh » parser » rules » [javadoc | source]
    1   package com.opensymphony.module.sitemesh.parser.rules;
    2   
    3   import com.opensymphony.module.sitemesh.HTMLPage;
    4   import com.opensymphony.module.sitemesh.html.BasicRule;
    5   import com.opensymphony.module.sitemesh.html.Tag;
    6   import com.opensymphony.module.sitemesh.html.util.CharArray;
    7   
    8   public class BodyTagRule extends BasicRule {
    9   
   10       private final HTMLPage page;
   11       private final CharArray body;
   12   
   13       public BodyTagRule(HTMLPage page, CharArray body) {
   14           super("body");
   15           this.page = page;
   16           this.body = body;
   17       }
   18   
   19       public void process(Tag tag) {
   20           if (tag.getType() == Tag.OPEN || tag.getType() == Tag.EMPTY) {
   21               for (int i = 0; i < tag.getAttributeCount(); i++) {
   22                   page.addProperty("body." + tag.getAttributeName(i), tag.getAttributeValue(i));
   23               }
   24               body.clear();
   25           } else {
   26               context.pushBuffer(new CharArray(64)); // unused buffer: everything after </body> is discarded.
   27           }
   28       }
   29   
   30   }

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