Source Code Cross Referenced for TagAdapter.java in  » 6.0-JDK-Core » Servlet-API-by-tomcat » javax » servlet » jsp » tagext » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Servlet API by tomcat » javax.servlet.jsp.tagext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2004 The Apache Software Foundation
003         *
004         * Licensed under the Apache License, Version 2.0 (the "License");
005         * you may not use this file except in compliance with the License.
006         * You may obtain a copy of the License at
007         *
008         *     http://www.apache.org/licenses/LICENSE-2.0
009         *
010         * Unless required by applicable law or agreed to in writing, software
011         * distributed under the License is distributed on an "AS IS" BASIS,
012         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013         * See the License for the specific language governing permissions and
014         * limitations under the License.
015         */
016
017        package javax.servlet.jsp.tagext;
018
019        import javax.servlet.jsp.*;
020
021        /**
022         * Wraps any SimpleTag and exposes it using a Tag interface.  This is used
023         * to allow collaboration between classic Tag handlers and SimpleTag
024         * handlers.
025         * <p>
026         * Because SimpleTag does not extend Tag, and because Tag.setParent()
027         * only accepts a Tag instance, a classic tag handler (one
028         * that implements Tag) cannot have a SimpleTag as its parent.  To remedy
029         * this, a TagAdapter is created to wrap the SimpleTag parent, and the
030         * adapter is passed to setParent() instead.  A classic Tag Handler can
031         * call getAdaptee() to retrieve the encapsulated SimpleTag instance.
032         *
033         * @since 2.0
034         */
035        public class TagAdapter implements  Tag {
036            /** The simple tag that's being adapted. */
037            private SimpleTag simpleTagAdaptee;
038
039            /** The parent, of this tag, converted (if necessary) to be of type Tag. */
040            private Tag parent;
041
042            // Flag indicating whether we have already determined the parent
043            private boolean parentDetermined;
044
045            /**
046             * Creates a new TagAdapter that wraps the given SimpleTag and 
047             * returns the parent tag when getParent() is called.
048             *
049             * @param adaptee The SimpleTag being adapted as a Tag.
050             */
051            public TagAdapter(SimpleTag adaptee) {
052                if (adaptee == null) {
053                    // Cannot wrap a null adaptee.
054                    throw new IllegalArgumentException();
055                }
056                this .simpleTagAdaptee = adaptee;
057            }
058
059            /**
060             * Must not be called.
061             *
062             * @param pc ignored.
063             * @throws UnsupportedOperationException Must not be called
064             */
065            public void setPageContext(PageContext pc) {
066                throw new UnsupportedOperationException(
067                        "Illegal to invoke setPageContext() on TagAdapter wrapper");
068            }
069
070            /**
071             * Must not be called.  The parent of this tag is always 
072             * getAdaptee().getParent().
073             *
074             * @param parentTag ignored.
075             * @throws UnsupportedOperationException Must not be called.
076             */
077            public void setParent(Tag parentTag) {
078                throw new UnsupportedOperationException(
079                        "Illegal to invoke setParent() on TagAdapter wrapper");
080            }
081
082            /**
083             * Returns the parent of this tag, which is always
084             * getAdaptee().getParent().  
085             *
086             * This will either be the enclosing Tag (if getAdaptee().getParent()
087             * implements Tag), or an adapter to the enclosing Tag (if 
088             * getAdaptee().getParent() does not implement Tag).
089             *
090             * @return The parent of the tag being adapted.
091             */
092            public Tag getParent() {
093                if (!parentDetermined) {
094                    JspTag adapteeParent = simpleTagAdaptee.getParent();
095                    if (adapteeParent != null) {
096                        if (adapteeParent instanceof  Tag) {
097                            this .parent = (Tag) adapteeParent;
098                        } else {
099                            // Must be SimpleTag - no other types defined.
100                            this .parent = new TagAdapter(
101                                    (SimpleTag) adapteeParent);
102                        }
103                    }
104                    parentDetermined = true;
105                }
106
107                return this .parent;
108            }
109
110            /**
111             * Gets the tag that is being adapted to the Tag interface.
112             * This should be an instance of SimpleTag in JSP 2.0, but room
113             * is left for other kinds of tags in future spec versions.
114             *
115             * @return the tag that is being adapted
116             */
117            public JspTag getAdaptee() {
118                return this .simpleTagAdaptee;
119            }
120
121            /**
122             * Must not be called.
123             *
124             * @return always throws UnsupportedOperationException
125             * @throws UnsupportedOperationException Must not be called
126             * @throws JspException never thrown
127             */
128            public int doStartTag() throws JspException {
129                throw new UnsupportedOperationException(
130                        "Illegal to invoke doStartTag() on TagAdapter wrapper");
131            }
132
133            /**
134             * Must not be called.
135             *
136             * @return always throws UnsupportedOperationException
137             * @throws UnsupportedOperationException Must not be called
138             * @throws JspException never thrown
139             */
140            public int doEndTag() throws JspException {
141                throw new UnsupportedOperationException(
142                        "Illegal to invoke doEndTag() on TagAdapter wrapper");
143            }
144
145            /**
146             * Must not be called.
147             *
148             * @throws UnsupportedOperationException Must not be called
149             */
150            public void release() {
151                throw new UnsupportedOperationException(
152                        "Illegal to invoke release() on TagAdapter wrapper");
153            }
154        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.