@Override
public int doEndTag() throws JspException {
final ServletRequest request = pageContext.getRequest();
MediaText text;
if (request.getAttribute("content") != null
&& request.getAttribute("content") instanceof MediaContent) {
text = ((MediaContent) request.getAttribute("content")).addExtension(MediaConstants.TEXT);
} else if (request.getAttribute("group") != null
&& request.getAttribute("group") instanceof MediaGroup) {
text = ((MediaGroup) request.getAttribute("group")).addExtension(MediaConstants.TEXT);
} else if (request.getAttribute("entry") != null
&& request.getAttribute("entry") instanceof Entry) {
text = ((Entry) request.getAttribute("entry")).addExtension(MediaConstants.TEXT);
} else {
text = ((Feed) request.getAttribute("feed")).addExtension(MediaConstants.TEXT);
}
// set the body content
text.setText(getBodyContent().getString());
// set the scheme
if (start != null) text.setStart(start);
if (end != null) text.setEnd(end);
if (lang != null) text.setLang(lang);
if (type != null) text.setType(Type.valueOf(type));
return super.doEndTag();
}