001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package com.caucho.jsp;
031:
032: import com.caucho.log.Log;
033: import com.caucho.util.L10N;
034: import com.caucho.bytecode.JavaClass;
035:
036: import java.util.logging.Logger;
037:
038: /**
039: * Stores analyzed information about a tag.
040: */
041: public class AnalyzedTag {
042: private static final Logger log = Log.open(AnalyzedTag.class);
043: static final L10N L = new L10N(AnalyzedTag.class);
044:
045: private AnalyzedTag _parent;
046: private JavaClass _javaClass;
047:
048: private boolean _isBodyTag;
049:
050: private boolean _doStart;
051: private boolean _startReturnsSkip;
052: private boolean _startReturnsInclude;
053: private boolean _startReturnsBuffered;
054:
055: private boolean _doEnd;
056: private boolean _endReturnsSkip;
057: private boolean _endReturnsEval;
058:
059: private boolean _doAfter;
060: private boolean _afterReturnsAgain;
061:
062: private boolean _doInit;
063:
064: private boolean _doCatch;
065: private boolean _doFinally;
066:
067: private boolean _hasInjection;
068:
069: public AnalyzedTag getParent() {
070: return _parent;
071: }
072:
073: public void setParent(AnalyzedTag parent) {
074: _parent = parent;
075: }
076:
077: /**
078: * Set true for a body tag.
079: */
080: public void setBodyTag(boolean isBodyTag) {
081: _isBodyTag = isBodyTag;
082: }
083:
084: /**
085: * Set true for a body tag.
086: */
087: public boolean isBodyTag() {
088: return _isBodyTag;
089: }
090:
091: /**
092: * Set true if the tag implements doStart.
093: */
094: public boolean getDoStart() {
095: return _doStart;
096: }
097:
098: /**
099: * Set true if the tag implements doStart.
100: */
101: public void setDoStart(boolean doStart) {
102: _doStart = doStart;
103: }
104:
105: /**
106: * Set true if the doStart can return SKIP_BODY
107: */
108: public boolean getStartReturnsSkip() {
109: return _startReturnsSkip;
110: }
111:
112: /**
113: * Set true if the doStart can return SKIP_BODY
114: */
115: public void setStartReturnsSkip(boolean skip) {
116: _startReturnsSkip = skip;
117: }
118:
119: /**
120: * Set true if the doStart can return INCLUDE_BODY
121: */
122: public boolean getStartReturnsInclude() {
123: return _startReturnsInclude;
124: }
125:
126: /**
127: * Set true if the doStart can return INCLUDE_BODY
128: */
129: public void setStartReturnsInclude(boolean include) {
130: _startReturnsInclude = include;
131: }
132:
133: /**
134: * Set true if the doStart can return INCLUDE_BODY_BUFFERED
135: */
136: public boolean getStartReturnsBuffered() {
137: return _isBodyTag && _startReturnsBuffered;
138: }
139:
140: /**
141: * Set true if the doStart can return INCLUDE_BODY_BUFFERED
142: */
143: public boolean getStartReturnsBufferedAsParent() {
144: return _startReturnsBuffered;
145: }
146:
147: /**
148: * Set true if the doStart can return INCLUDE_BODY_BUFFERED
149: */
150: public void setStartReturnsBuffered(boolean buffered) {
151: _startReturnsBuffered = buffered;
152: }
153:
154: /**
155: * Set true if the tag implements doEndTag.
156: */
157: public boolean getDoEnd() {
158: if (_doEnd)
159: return true;
160:
161: int count = 0;
162: count += (getEndReturnsSkip() ? 1 : 0);
163: count += (getEndReturnsEval() ? 1 : 0);
164:
165: return count > 1;
166: }
167:
168: /**
169: * Set true if the tag implements doEndTag.
170: */
171: public void setDoEnd(boolean doEnd) {
172: _doEnd = doEnd;
173: }
174:
175: /**
176: * Set true if the doEndTag can return SKIP_PAGE
177: */
178: public boolean getEndReturnsSkip() {
179: return _endReturnsSkip;
180: }
181:
182: /**
183: * Set true if the doEndTag can return SKIP_PAGE
184: */
185: public void setEndReturnsSkip(boolean skip) {
186: _endReturnsSkip = skip;
187: }
188:
189: /**
190: * Set true if the doEndTag can return EVAL_PAGE
191: */
192: public boolean getEndReturnsEval() {
193: return _endReturnsEval;
194: }
195:
196: /**
197: * Set true if the doEndTag can return EVAL_PAGE
198: */
199: public void setEndReturnsEval(boolean eval) {
200: _endReturnsEval = eval;
201: }
202:
203: /**
204: * Set true if the tag implements doAfterBody
205: */
206: public boolean getDoAfter() {
207: return _doAfter;
208: }
209:
210: /**
211: * Set true if the tag implements doAfterBody
212: */
213: public void setDoAfter(boolean doAfter) {
214: _doAfter = doAfter;
215: }
216:
217: /**
218: * Set true if the doAfterBody can return EVAL_BODY_AGAIN
219: */
220: public boolean getAfterReturnsAgain() {
221: return _afterReturnsAgain;
222: }
223:
224: /**
225: * Set true if the doAfterBody can return EVAL_BODY_AGAIN
226: */
227: public void setAfterReturnsAgain(boolean again) {
228: _afterReturnsAgain = again;
229: }
230:
231: /**
232: * Set true if the tag implements doInitBody.
233: */
234: public boolean getDoInit() {
235: return _doInit;
236: }
237:
238: /**
239: * Set true if the tag implements doInitBody.
240: */
241: public void setDoInit(boolean doInit) {
242: _doInit = doInit;
243: }
244:
245: /**
246: * Set true if the tag implements doCatch
247: */
248: public boolean getDoCatch() {
249: return _doCatch;
250: }
251:
252: /**
253: * Set true if the tag implements doCatch
254: */
255: public void setDoCatch(boolean doCatch) {
256: _doCatch = doCatch;
257: }
258:
259: /**
260: * Set true if the tag implements doFinally
261: */
262: public boolean getDoFinally() {
263: return _doFinally;
264: }
265:
266: /**
267: * Set true if the tag implements doFinally
268: */
269: public void setDoFinally(boolean doFinally) {
270: _doFinally = doFinally;
271: }
272:
273: /**
274: * True if the tag has a @Resource.
275: */
276: public boolean getHasInjection() {
277: return _hasInjection;
278: }
279:
280: /**
281: * True if the tag has a @Resource.
282: */
283: public void setHasInjection(boolean hasInjection) {
284: _hasInjection = hasInjection;
285: }
286:
287: public JavaClass getJavaClass() {
288: return _javaClass;
289: }
290:
291: public void setJavaClass(JavaClass javaClass) {
292: _javaClass = javaClass;
293: }
294:
295: public String toString() {
296: return getClass().getSimpleName() + "[" + _javaClass + "]";
297: }
298: }
|