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