package pt.ist.renderers.components; import java.util.ArrayList; import java.util.List; import javax.servlet.jsp.PageContext; import pt.ist.renderers.components.tags.HtmlTag; public class HtmlListItem extends HtmlComponent { private List body; public HtmlListItem() { super(); this.body = new ArrayList(); } public void setBody(HtmlComponent body) { this.body = new ArrayList(); this.body.add(body); } public HtmlComponent getBody() { if (this.body.isEmpty()) { return null; } else { return this.body.get(0); } } public void addChild(HtmlComponent component) { this.body.add(component); } @Override public List getChildren() { List children = super.getChildren(); if (this.body != null) { children.addAll(this.body); } return children; } @Override public HtmlTag getOwnTag(PageContext context) { HtmlTag tag = super.getOwnTag(context); tag.setName("li"); for (HtmlComponent child : this.body) { if (child != null) { tag.addChild(child.getOwnTag(context)); } } return tag; } }