01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.tag.entity;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.jsp.tag.BaseTag;
20:
21: /**
22: * Entity tag.
23: *
24: * @author Oleg Mürk
25: *
26: * @jsp.tag
27: * name = "entity"
28: * body-content = "empty"
29: * description = "Represents an HTML entity, for instance <i>&nbsp;</i>."
30: */
31: public class EntityHtmlTag extends BaseTag {
32: protected String code = null;
33: protected long count = 1;
34:
35: public EntityHtmlTag() {
36: }
37:
38: public EntityHtmlTag(String code) {
39: this .code = code;
40: }
41:
42: protected int doStartTag(Writer out) throws Exception {
43: super .doStartTag(out);
44:
45: for (long i = 0; i < count; i++) {
46: out.write("&");
47: out.write(code);
48: out.write(";");
49: }
50:
51: // Continue
52: return EVAL_BODY_INCLUDE;
53: }
54:
55: /* ***********************************************************************************
56: * Tag attributes
57: * ***********************************************************************************/
58:
59: /**
60: * @jsp.attribute
61: * type = "java.lang.String"
62: * required = "false"
63: * description = "HTML entity code, e.g. <i>nbsp</i> or <i>#012</i>."
64: */
65: public void setCode(String code) throws JspException {
66: this .code = (String) evaluateNotNull("code", code, String.class);
67: }
68:
69: /**
70: * @jsp.attribute
71: * type = "java.lang.String"
72: * required = "false"
73: * description = "Number of times to repeat the entity."
74: */
75: public void setCount(String count) throws JspException {
76: this .count = ((Long) evaluate("count", count, Long.class))
77: .longValue();
78: }
79: }
|