Skip to content

Package: BodyTagSupport

BodyTagSupport

nameinstructionbranchcomplexitylinemethod
BodyTagSupport()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
doAfterBody()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
doEndTag()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
doInitBody()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
doStartTag()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getBodyContent()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPreviousOut()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
release()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setBodyContent(BodyContent)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2020 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: * Copyright 2004 The Apache Software Foundation
5: *
6: * Licensed under the Apache License, Version 2.0 (the "License");
7: * you may not use this file except in compliance with the License.
8: * You may obtain a copy of the License at
9: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: package jakarta.servlet.jsp.tagext;
20:
21: import jakarta.servlet.jsp.JspException;
22: import jakarta.servlet.jsp.JspWriter;
23:
24: /**
25: * A base class for defining tag handlers implementing BodyTag.
26: *
27: * <p>
28: * The BodyTagSupport class implements the BodyTag interface and adds additional convenience methods including getter
29: * methods for the bodyContent property and methods to get at the previous out JspWriter.
30: *
31: * <p>
32: * Many tag handlers will extend BodyTagSupport and only redefine a few methods.
33: */
34: public class BodyTagSupport extends TagSupport implements BodyTag {
35:
36: private static final long serialVersionUID = -7235752615580319833L;
37:
38: /**
39: * Default constructor, all subclasses are required to only define a public constructor with the same signature, and
40: * to call the superclass constructor.
41: *
42: * This constructor is called by the code generated by the JSP translator.
43: */
44: public BodyTagSupport() {
45: super();
46: }
47:
48: /**
49: * Default processing of the start tag returning EVAL_BODY_BUFFERED.
50: *
51: * @return EVAL_BODY_BUFFERED
52: * @throws JspException if an error occurred while processing this tag
53: * @see BodyTag#doStartTag
54: */
55: @Override
56: public int doStartTag() throws JspException {
57: return EVAL_BODY_BUFFERED;
58: }
59:
60: /**
61: * Default processing of the end tag returning EVAL_PAGE.
62: *
63: * @return EVAL_PAGE
64: * @throws JspException if an error occurred while processing this tag
65: * @see Tag#doEndTag
66: */
67: @Override
68: public int doEndTag() throws JspException {
69: return super.doEndTag();
70: }
71:
72: // Actions related to body evaluation
73:
74: /**
75: * Prepare for evaluation of the body: stash the bodyContent away.
76: *
77: * @param b the BodyContent
78: * @see #doAfterBody
79: * @see #doInitBody()
80: * @see BodyTag#setBodyContent
81: */
82: @Override
83: public void setBodyContent(BodyContent b) {
84: this.bodyContent = b;
85: }
86:
87: /**
88: * Prepare for evaluation of the body just before the first body evaluation: no action.
89: *
90: * @throws JspException if an error occurred while processing this tag
91: * @see #setBodyContent
92: * @see #doAfterBody
93: * @see BodyTag#doInitBody
94: */
95: @Override
96: public void doInitBody() throws JspException {
97: }
98:
99: /**
100: * After the body evaluation: do not reevaluate and continue with the page. By default nothing is done with the
101: * bodyContent data (if any).
102: *
103: * @return SKIP_BODY
104: * @throws JspException if an error occurred while processing this tag
105: * @see #doInitBody
106: * @see BodyTag#doAfterBody
107: */
108: @Override
109: public int doAfterBody() throws JspException {
110: return SKIP_BODY;
111: }
112:
113: /**
114: * Release state.
115: *
116: * @see Tag#release
117: */
118: @Override
119: public void release() {
120: bodyContent = null;
121:
122: super.release();
123: }
124:
125: /**
126: * Get current bodyContent.
127: *
128: * @return the body content.
129: */
130: public BodyContent getBodyContent() {
131: return bodyContent;
132: }
133:
134: /**
135: * Get surrounding out JspWriter.
136: *
137: * @return the enclosing JspWriter, from the bodyContent.
138: */
139: public JspWriter getPreviousOut() {
140: return bodyContent.getEnclosingWriter();
141: }
142:
143: // protected fields
144:
145: /**
146: * The current BodyContent for this BodyTag.
147: */
148: protected BodyContent bodyContent;
149: }