Source Code Cross Referenced for NestedSimpleTag.java in  » Testing » mockrunner-0.4 » com » mockrunner » tag » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.tag 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.tag;
002:
003:        import java.io.IOException;
004:        import java.util.HashMap;
005:        import java.util.List;
006:        import java.util.Map;
007:
008:        import javax.servlet.jsp.JspContext;
009:        import javax.servlet.jsp.JspException;
010:        import javax.servlet.jsp.tagext.JspFragment;
011:        import javax.servlet.jsp.tagext.JspTag;
012:        import javax.servlet.jsp.tagext.SimpleTag;
013:        import javax.servlet.jsp.tagext.SimpleTagSupport;
014:        import javax.servlet.jsp.tagext.TagSupport;
015:
016:        import com.mockrunner.base.NestedApplicationException;
017:        import com.mockrunner.mock.web.MockJspFragment;
018:
019:        /**
020:         * Implementation of {@link NestedTag} wrapping tags of
021:         * type <code>SimpleTag</code>. <code>NestedSimpleTag</code> instances 
022:         * are created with the help of {@link TagTestModule#createNestedTag}. 
023:         * You do not need to create them on your own in the tests.
024:         */
025:        public class NestedSimpleTag extends SimpleTagSupport implements 
026:                NestedTag {
027:            private SimpleTag tag;
028:            private JspContext jspContext;
029:            private JspFragment jspBody;
030:            private Map attributes;
031:
032:            /**
033:             * Constructor for a tag with an empty attribute map.
034:             * @param tag the tag
035:             * @param jspContext the corresponding <code>JspContext</code>
036:             */
037:            public NestedSimpleTag(SimpleTag tag, JspContext jspContext) {
038:                this (tag, jspContext, new HashMap());
039:            }
040:
041:            /**
042:             * Constructor for a tag with the specified attribute map.
043:             * @param tag the tag
044:             * @param jspContext the corresponding <code>JspContext</code>
045:             * @param attributes the attribute map
046:             */
047:            public NestedSimpleTag(SimpleTag tag, JspContext jspContext,
048:                    Map attributes) {
049:                this .tag = tag;
050:                this .jspContext = jspContext;
051:                jspBody = new MockJspFragment(jspContext, tag);
052:                tag.setJspContext(jspContext);
053:                tag.setJspBody(jspBody);
054:                this .attributes = attributes;
055:            }
056:
057:            /**
058:             * Constructor for a tag with an empty attribute map.
059:             * @param tag the tag
060:             * @param jspContext the corresponding <code>JspContext</code>
061:             */
062:            public NestedSimpleTag(SimpleTagSupport tag, JspContext jspContext) {
063:                this (tag, jspContext, new HashMap());
064:            }
065:
066:            /**
067:             * Constructor for a tag with the specified attribute map.
068:             * @param tag the tag
069:             * @param jspContext the corresponding <code>JspContext</code>
070:             * @param attributes the attribute map
071:             */
072:            public NestedSimpleTag(SimpleTagSupport tag, JspContext jspContext,
073:                    Map attributes) {
074:                this ((SimpleTag) tag, jspContext, attributes);
075:            }
076:
077:            /**
078:             * Implementation of {@link NestedTag#setDoRelease}.
079:             * Does nothing in this case.
080:             */
081:            public void setDoRelease(boolean doRelease) {
082:
083:            }
084:
085:            /**
086:             * Implementation of {@link NestedTag#setDoReleaseRecursive}.
087:             * Does nothing in this case.
088:             */
089:            public void setDoReleaseRecursive(boolean doRelease) {
090:
091:            }
092:
093:            /**
094:             * @inheritDoc
095:             */
096:            public void populateAttributes() {
097:                TagUtil.populateTag(tag, attributes);
098:            }
099:
100:            /**
101:             * Implementation of {@link NestedTag#doLifecycle} for simple
102:             * tags. Returns <code>-1</code> in this case, because
103:             * <code>doTag()</code> does not have a return value.
104:             */
105:            public int doLifecycle() throws JspException {
106:                try {
107:                    populateAttributes();
108:                    tag.doTag();
109:                } catch (IOException exc) {
110:                    throw new NestedApplicationException(exc);
111:                }
112:                return -1;
113:            }
114:
115:            /**
116:             * Implementation of {@link NestedTag#getTag}.
117:             * Should not be called and throws a <code>RuntimeException</code>,
118:             * because a simple tag is not an instance of <code>TagSupport</code>.
119:             */
120:            public TagSupport getTag() {
121:                throw new RuntimeException(
122:                        "getTag() method cannot be called for simple tags.");
123:            }
124:
125:            /**
126:             * @inheritDoc
127:             */
128:            public JspTag getWrappedTag() {
129:                return tag;
130:            }
131:
132:            /**
133:             * @inheritDoc
134:             */
135:            public void removeChilds() {
136:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
137:                    ((MockJspFragment) jspBody).removeChilds();
138:                }
139:            }
140:
141:            /**
142:             * @inheritDoc
143:             */
144:            public List getChilds() {
145:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
146:                    return ((MockJspFragment) jspBody).getChilds();
147:                }
148:                return null;
149:            }
150:
151:            /**
152:             * @inheritDoc
153:             */
154:            public Object getChild(int index) {
155:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
156:                    return ((MockJspFragment) jspBody).getChild(index);
157:                }
158:                return null;
159:            }
160:
161:            /**
162:             * @inheritDoc
163:             */
164:            public void addTextChild(String text) {
165:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
166:                    ((MockJspFragment) jspBody).addTextChild(text);
167:                }
168:            }
169:
170:            /**
171:             * @inheritDoc
172:             */
173:            public void addDynamicChild(DynamicChild child) {
174:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
175:                    ((MockJspFragment) jspBody).addDynamicChild(child);
176:                }
177:            }
178:
179:            /**
180:             * @inheritDoc
181:             */
182:            public NestedTag addTagChild(Class tag) {
183:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
184:                    return ((MockJspFragment) jspBody).addTagChild(tag);
185:                }
186:                return null;
187:            }
188:
189:            /**
190:             * @inheritDoc
191:             */
192:            public NestedTag addTagChild(Class tag, Map attributeMap) {
193:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
194:                    return ((MockJspFragment) jspBody).addTagChild(tag,
195:                            attributeMap);
196:                }
197:                return null;
198:            }
199:
200:            /**
201:             * @inheritDoc
202:             */
203:            public NestedTag addTagChild(TagSupport tag) {
204:                return addTagChild(tag, new HashMap());
205:            }
206:
207:            /**
208:             * @inheritDoc
209:             */
210:            public NestedTag addTagChild(TagSupport tag, Map attributeMap) {
211:                return addTagChild((JspTag) tag, attributeMap);
212:            }
213:
214:            /**
215:             * @inheritDoc
216:             */
217:            public NestedTag addTagChild(JspTag tag) {
218:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
219:                    return ((MockJspFragment) jspBody).addTagChild(tag);
220:                }
221:                return null;
222:            }
223:
224:            /**
225:             * @inheritDoc
226:             */
227:            public NestedTag addTagChild(JspTag tag, Map attributeMap) {
228:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
229:                    return ((MockJspFragment) jspBody).addTagChild(tag,
230:                            attributeMap);
231:                }
232:                return null;
233:            }
234:
235:            /**
236:             * Delegates to wrapped tag.
237:             */
238:            public void doTag() throws JspException, IOException {
239:                tag.doTag();
240:            }
241:
242:            /**
243:             * Returns the body fragment.
244:             * @return the body fragment
245:             */
246:            public JspFragment getJspBody() {
247:                return jspBody;
248:            }
249:
250:            /**
251:             * Returns the <code>JspContext</code>.
252:             * @return the <code>JspContext</code>
253:             */
254:            public JspContext getJspContext() {
255:                return jspContext;
256:            }
257:
258:            /**
259:             * Delegates to wrapped tag.
260:             */
261:            public JspTag getParent() {
262:                return tag.getParent();
263:            }
264:
265:            /**
266:             * Delegates to wrapped tag.
267:             */
268:            public void setJspBody(JspFragment jspBody) {
269:                this .jspBody = jspBody;
270:                tag.setJspBody(jspBody);
271:            }
272:
273:            /**
274:             * Delegates to wrapped tag. Also calls <code>setJspContext</code>
275:             * on the body fragment, if the body fragment is an instance of
276:             * {@link com.mockrunner.mock.web.MockJspFragment}
277:             */
278:            public void setJspContext(JspContext jspContext) {
279:                this .jspContext = jspContext;
280:                tag.setJspContext(jspContext);
281:                if (null != jspBody && jspBody instanceof  MockJspFragment) {
282:                    ((MockJspFragment) jspBody).setJspContext(jspContext);
283:                }
284:            }
285:
286:            /**
287:             * Delegates to wrapped tag.
288:             */
289:            public void setParent(JspTag parent) {
290:                tag.setParent(parent);
291:            }
292:
293:            /**
294:             * Dumps the content of this and the nested tags.
295:             */
296:            public String toString() {
297:                return TagUtil.dumpTag(this , new StringBuffer(), 0);
298:            }
299:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.