1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.tags;
17
18 import java.io.IOException;
19 import java.io.Writer;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import javax.servlet.jsp.JspContext;
24 import javax.servlet.jsp.JspException;
25 import javax.servlet.jsp.tagext.JspFragment;
26 import javax.servlet.jsp.tagext.SimpleTag;
27
28 public class MockJspFragment extends JspFragment {
29
30 private JspContext context;
31 private String body = "";
32 private List<SimpleTag> childTags = new ArrayList<SimpleTag>();
33
34 public void setJspContext(JspContext context) {
35 this.context = context;
36 }
37
38 @Override
39 public JspContext getJspContext() {
40 return context;
41 }
42
43 @Override
44 public void invoke(Writer out) throws JspException, IOException {
45 out.write(body);
46 for (SimpleTag tag : childTags) {
47 tag.setJspContext(getJspContext());
48 tag.doTag();
49 }
50 }
51
52 public void setBody(String body) {
53 this.body = body;
54 }
55
56 public void addChildTag(SimpleTag childTag) {
57 childTags.add(childTag);
58 }
59 }