01: package com.opensymphony.module.sitemesh.html;
02:
03: import com.opensymphony.module.sitemesh.html.util.CharArray;
04:
05: public abstract class BlockExtractingRule extends BasicRule {
06:
07: private boolean includeEnclosingTags;
08:
09: protected BlockExtractingRule(boolean includeEnclosingTags,
10: String acceptableTagName) {
11: super (acceptableTagName);
12: this .includeEnclosingTags = includeEnclosingTags;
13: }
14:
15: protected BlockExtractingRule(boolean includeEnclosingTags) {
16: this .includeEnclosingTags = includeEnclosingTags;
17: }
18:
19: public void process(Tag tag) {
20: if (tag.getType() == Tag.OPEN) {
21: if (includeEnclosingTags) {
22: tag.writeTo(context.currentBuffer());
23: }
24: context.pushBuffer(createBuffer());
25: start(tag);
26: } else if (tag.getType() == Tag.CLOSE) {
27: end(tag);
28: context.popBuffer();
29: if (includeEnclosingTags) {
30: tag.writeTo(context.currentBuffer());
31: }
32: }
33: }
34:
35: protected void start(Tag tag) {
36: }
37:
38: protected void end(Tag tag) {
39: }
40:
41: protected CharArray createBuffer() {
42: return new CharArray(512);
43: }
44:
45: }
|