01: package com.opensymphony.module.sitemesh.html.rules;
02:
03: import com.opensymphony.module.sitemesh.html.BasicRule;
04: import com.opensymphony.module.sitemesh.html.Tag;
05: import com.opensymphony.module.sitemesh.html.util.CharArray;
06:
07: public class BodyTagRule extends BasicRule {
08:
09: private final PageBuilder page;
10: private final CharArray body;
11:
12: public BodyTagRule(PageBuilder page, CharArray body) {
13: super ("body");
14: this .page = page;
15: this .body = body;
16: }
17:
18: public void process(Tag tag) {
19: if (tag.getType() == Tag.OPEN || tag.getType() == Tag.EMPTY) {
20: for (int i = 0; i < tag.getAttributeCount(); i++) {
21: page.addProperty("body." + tag.getAttributeName(i), tag
22: .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: }
|