BodyContent (Java EE 5)

Java EE API


javax.servlet.jsp.tagext Class BodyContent

java.lang.Object
  extended by java.io.Writer
      extended by javax.servlet.jsp.JspWriter
          extended by javax.servlet.jsp.tagext.BodyContent
All Implemented Interfaces:
Closeable, Flushable, Appendable

public abstract class BodyContent
extends JspWriter

Extends: java.io.Writer > JspWriter

对某一操作正文求值的封装,因此它可用于标记处理程序。BodyContent 是 JspWriter 的子类。

注意,BodyContent 的内容是求值的结果,因此除了操作调用的结果外,它不会包含任何操作和类似的东西。

BodyContent 有一些方法,这些方法可将其内容转换为 String、读取其内容和清除内容。

BodyContent 对象的缓冲区大小是无界的。BodyContent 对象不能处于 autoFlush 模式。不可能对 BodyContent 对象调用 flush,因为没有回溯流。

BodyContent 实例是通过调用 PageContext 类的 pushBody 和 popBody 方法创建的。BodyContent 按照与其关联的操作的结构被封闭在另一个 JspWriter(可能是另一个 BodyContent 对象)内。

通过调用 setBodyContent() 使 BodyContent 可用于 BodyTag。直到调用 doEndTag() 后,标记处理程序才可以使用该对象。

英文文档:

An encapsulation of the evaluation of the body of an action so it is available to a tag handler. BodyContent is a subclass of JspWriter.

Note that the content of BodyContent is the result of evaluation, so it will not contain actions and the like, but the result of their invocation.

BodyContent has methods to convert its contents into a String, to read its contents, and to clear the contents.

The buffer size of a BodyContent object is unbounded. A BodyContent object cannot be in autoFlush mode. It is not possible to invoke flush on a BodyContent object, as there is no backing stream.

Instances of BodyContent are created by invoking the pushBody and popBody methods of the PageContext class. A BodyContent is enclosed within another JspWriter (maybe another BodyContent object) following the structure of their associated actions.

A BodyContent is made available to a BodyTag through a setBodyContent() call. The tag handler can use the object until after the call to doEndTag().


Field Summary
 
Fields inherited from class javax.servlet.jsp.JspWriter
 
Fields inherited from class java.io.Writer
 
Constructor Summary
protected
 
Method Summary
 void
 void
 JspWriter
abstract  Reader
abstract  String
abstract  void
 
Methods inherited from class javax.servlet.jsp.JspWriter
 
Methods inherited from class java.io.Writer
 
Methods inherited from class java.lang.Object
 

Constructor Detail

protected BodyContent(JspWriter e)
受保护的构造方法。 无界缓冲区,不执行自动刷新。
e 封闭的 JspWriter
英文文档:

BodyContent

protected BodyContent(JspWriter e)
Protected constructor. Unbounded buffer, no autoflushing.

Parameters:
e - the enclosing JspWriter

Method Detail

public void flush() throws java.io.IOException
重定义的 flush(),因此它是不合法的。

刷新 BodyContent 是无效的,因为它后面没有回溯流。

Throwsjava.io.IOException: 始终抛出

英文文档:

flush

public void flush()
           throws IOException
Redefined flush() so it is not legal.

It is not valid to flush a BodyContent because there is no backing stream behind it.

Specified by:
flush in interface Flushable
Specified by:
flush in class JspWriter
Throws:
IOException - always thrown

public void clearBody()
清除正文,不抛出任何异常。
英文文档:

clearBody

public void clearBody()
Clear the body without throwing any exceptions.


abstract public java.io.Reader getReader()
以 Reader 形式返回此 BodyContent 的值。
return Reader 形式的此 BodyContent 的值
英文文档:

getReader

public abstract Reader getReader()
Return the value of this BodyContent as a Reader.

Returns:
the value of this BodyContent as a Reader

abstract public String getString()
以 String 形式返回 BodyContent 的值。
return String 形式的 BodyContent 的值
英文文档:

getString

public abstract String getString()
Return the value of the BodyContent as a String.

Returns:
the value of the BodyContent as a String

abstract public void writeOut(java.io.Writer out) throws java.io.IOException
将此 BodyContent 的内容写入 Writer。子类可优化常用调用模式。
out 要放置此正文求值的内容的 Writer
Throwsjava.io.IOException: 如果在将此 BodyContent 的内容写入给定 Writer 时发生 I/O 错误
英文文档:

writeOut

public abstract void writeOut(Writer out)
                       throws IOException
Write the contents of this BodyContent into a Writer. Subclasses may optimize common invocation patterns.

Parameters:
out - The writer into which to place the contents of this body evaluation
Throws:
IOException - if an I/O error occurred while writing the contents of this BodyContent to the given Writer

public JspWriter getEnclosingWriter()
获取封闭的 JspWriter。
return 构造时传递的封闭 JspWriter
英文文档:

getEnclosingWriter

public JspWriter getEnclosingWriter()
Get the enclosing JspWriter.

Returns:
the enclosing JspWriter passed at construction time


Submit a bug or feature

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

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

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