TagAdapter (Java EE 5)

Java EE API


javax.servlet.jsp.tagext Class TagAdapter

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagAdapter
All Implemented Interfaces:
JspTag, Tag

public class TagAdapter
extends Object
implements Tag

Implements: Tag

包装任何 SimpleTag,并使用 Tag 接口公开它。此类用于支持经典标记处理程序与 SimpleTag 处理程序之间的协作。

因为 SimpleTag 没有扩展 Tag,并且因为 Tag.setParent() 只接受 Tag 实例,所以经典标记处理程序(实现 Tag 的经典标记处理程序)无法使 SimpleTag 成为其父标记。为了对此进行补救,可创建 TagAdapter 来包装 SimpleTag 父标记,并将适配器传递给 setParent()。经典标记处理程序可以调用 getAdaptee() 来获取已封装的 SimpleTag 实例。

英文文档:

Wraps any SimpleTag and exposes it using a Tag interface. This is used to allow collaboration between classic Tag handlers and SimpleTag handlers.

Because SimpleTag does not extend Tag, and because Tag.setParent() only accepts a Tag instance, a classic tag handler (one that implements Tag) cannot have a SimpleTag as its parent. To remedy this, a TagAdapter is created to wrap the SimpleTag parent, and the adapter is passed to setParent() instead. A classic Tag Handler can call getAdaptee() to retrieve the encapsulated SimpleTag instance.

Since:
JSP 2.0

Field Summary
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
 
Constructor Summary
 
Method Summary
 int
 int
 JspTag
 Tag
 void
 void
 void
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public TagAdapter(SimpleTag adaptee)
创建包装给定 SimpleTag 的新 TagAdapter,并在调用 getParent() 时返回父标记。
adaptee 将被适配为 Tag 的 SimpleTag。
英文文档:

TagAdapter

public TagAdapter(SimpleTag adaptee)
Creates a new TagAdapter that wraps the given SimpleTag and returns the parent tag when getParent() is called.

Parameters:
adaptee - The SimpleTag being adapted as a Tag.

Method Detail

public void setPageContext(PageContext pc)
不得调用。
pc 忽略。
ThrowsUnsupportedOperationException: 不得调用
英文文档:

setPageContext

public void setPageContext(PageContext pc)
Must not be called.

Specified by:
setPageContext in interface Tag
Parameters:
pc - ignored.
Throws:
UnsupportedOperationException - Must not be called

public void setParent(Tag parentTag)
不得调用。此标记的父标记始终是 getAdaptee().getParent()。
parentTag 忽略。
ThrowsUnsupportedOperationException: 不得调用。
英文文档:

setParent

public void setParent(Tag parentTag)
Must not be called. The parent of this tag is always getAdaptee().getParent().

Specified by:
setParent in interface Tag
Parameters:
parentTag - ignored.
Throws:
UnsupportedOperationException - Must not be called.

public Tag getParent()
返回此标记的父标记,该父标记始终是 getAdaptee().getParent()。 此父标记可能是封闭 Tag(如果 getAdaptee().getParent() 实现了 Tag),也可能是封闭 Tag 的适配器(如果 getAdaptee().getParent() 没有实现 Tag)。
return 将被适配的标记的父标记。
英文文档:

getParent

public Tag getParent()
Returns the parent of this tag, which is always getAdaptee().getParent(). This will either be the enclosing Tag (if getAdaptee().getParent() implements Tag), or an adapter to the enclosing Tag (if getAdaptee().getParent() does not implement Tag).

Specified by:
getParent in interface Tag
Returns:
The parent of the tag being adapted.
See Also:
TagSupport.findAncestorWithClass(javax.servlet.jsp.tagext.Tag, java.lang.Class)

public JspTag getAdaptee()
获取将被适配到 Tag 接口的标记。在 JSP 2.0 中,此标记应该是 SimpleTag 实例,但为以后规范版本中的其他种类的标记保留了空间。
return 将被适配的标记
英文文档:

getAdaptee

public JspTag getAdaptee()
Gets the tag that is being adapted to the Tag interface. This should be an instance of SimpleTag in JSP 2.0, but room is left for other kinds of tags in future spec versions.

Returns:
the tag that is being adapted

public int doStartTag() throws JspException
不得调用。
return 总是抛出 UnsupportedOperationException
ThrowsUnsupportedOperationException: 不得调用
ThrowsJspException: 不会抛出
英文文档:

doStartTag

public int doStartTag()
               throws JspException
Must not be called.

Specified by:
doStartTag in interface Tag
Returns:
always throws UnsupportedOperationException
Throws:
UnsupportedOperationException - Must not be called
JspException - never thrown
See Also:
BodyTag

public int doEndTag() throws JspException
不得调用。
return 总是抛出 UnsupportedOperationException
ThrowsUnsupportedOperationException: 不得调用
ThrowsJspException: 不会抛出
英文文档:

doEndTag

public int doEndTag()
             throws JspException
Must not be called.

Specified by:
doEndTag in interface Tag
Returns:
always throws UnsupportedOperationException
Throws:
UnsupportedOperationException - Must not be called
JspException - never thrown

public void release()
不得调用。
ThrowsUnsupportedOperationException: 不得调用
英文文档:

release

public void release()
Must not be called.

Specified by:
release in interface Tag
Throws:
UnsupportedOperationException - Must not be called


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!