|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.faces.context Class ResponseWriter
java.lang.Object java.io.Writer javax.faces.context.ResponseWriter
- All Implemented Interfaces:
- Closeable, Flushable, Appendable
- Direct Known Subclasses:
- ResponseWriterWrapper
public abstract class ResponseWriter
- extends Writer
ResponseWriter 是一个抽象类,该类描述基于字符输出的底层输出机制的适配器。除了从 java.io.Writer
继承的低级别 write()
方法之外,此类还提供一些实用程序方法,这些方法在生成标记语言(如 HTML 和 XML)的元素和属性方面非常有用。
ResponseWriter is an abstract class describing an
adapter to an underlying output mechanism for character-based output.
In addition to the low-level write()
methods inherited from
java.io.Writer
, this class provides utility methods
that are useful in producing elements and attributes for markup languages
like HTML and XML.
Field Summary |
---|
Fields inherited from class java.io.Writer |
---|
lock |
Constructor Summary | |
---|---|
ResponseWriter()
|
Method Summary | |
---|---|
abstract ResponseWriter |
cloneWithWriter(Writer writer)
Create and return a new instance of this ResponseWriter ,
using the specified Writer as the output destination. |
abstract void |
endDocument()
Write whatever text should end a response. |
abstract void |
endElement(String name)
Write the end of an element, after closing any open element created by a call to startElement() . |
abstract void |
flush()
Flush any ouput buffered by the output method to the underlying Writer or OutputStream. |
abstract String |
getCharacterEncoding()
Return the character encoding (such as "ISO-8859-1") for this ResponseWriter . |
abstract String |
getContentType()
Return the content type (such as "text/html") for this ResponseWriter . |
abstract void |
startDocument()
Write whatever text should begin a response. |
abstract void |
startElement(String name,
UIComponent component)
Write the start of an element, up to and including the element name. |
abstract void |
writeAttribute(String name,
Object value,
String property)
Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. |
abstract void |
writeComment(Object comment)
Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. |
abstract void |
writeText(char[] text,
int off,
int len)
Write text from a character array, after any performing any escaping appropriate for the markup language being rendered. |
abstract void |
writeText(Object text,
String property)
Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. |
void |
writeText(Object text,
UIComponent component,
String property)
Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. |
abstract void |
writeURIAttribute(String name,
Object value,
String property)
Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding appropriate to the markup language being rendered. |
Methods inherited from class java.io.Writer |
---|
append, append, append, close, write, write, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public
ResponseWriter()
英文文档:
ResponseWriter
public ResponseWriter()
Method Detail |
---|
abstract public String
getContentType()
返回此 ResponseWriter
的内容类型(如 "text/html")。注:这不得包括 "charset=" 后缀。
getContentType
public abstract String getContentType()
Return the content type (such as "text/html") for this
ResponseWriter
. Note: this must not include the "charset=" suffix.
abstract public String
getCharacterEncoding()
返回此 ResponseWriter
的字符编码(如 "ISO-8859-1")。有关字符编码的列表,请参见 the IANA。
getCharacterEncoding
public abstract String getCharacterEncoding()
Return the character encoding (such as "ISO-8859-1") for this
ResponseWriter
. Please see the IANA for a list of character encodings.
abstract public void
flush() throws java.io.IOException
将由输出方法缓冲的任何输出刷新到底层 Writer 或 OutputStream。此方法将不刷新底层 Writer 或 OutputStream;它只清除由此 ResponseWriter
缓冲的任何值。
flush
public abstract void flush() throws IOException
Flush any ouput buffered by the output method to the underlying Writer or OutputStream. This method will not flush the underlying Writer or OutputStream; it simply clears any values buffered by this
ResponseWriter
.- Throws:
IOException
abstract public void
startDocument() throws java.io.IOException
无论写入什么文本都应开始响应。
Throws | java.io.IOException: 如果发生输入/输出错误 |
startDocument
public abstract void startDocument() throws IOException
Write whatever text should begin a response.
- Throws:
IOException
- if an input/output error occurs
abstract public void
endDocument() throws java.io.IOException
无论写入什么文本都应结束响应。如果存在调用 startElement()
创建的公开元素,则将首先关闭该元素。
Throws | java.io.IOException: 如果发生输入/输出错误 |
endDocument
public abstract void endDocument() throws IOException
Write whatever text should end a response. If there is an open element that has been created by a call to
startElement()
, that element will be closed first.- Throws:
IOException
- if an input/output error occurs
abstract public void
startElement(String name, UIComponent component) throws java.io.IOException
写入元素的开头部分,直到包含元素名称。调用此方法后,客户端便可以调用 writeAttribute()
或 writeURIAttribute()
方法添加属性和相应的值。后续所有对 startElement()
、writeComment()
、writeText()
、endElement()
、endDocument()
、close()
、flush()
或 write()
的调用将关闭开始元素(即,在结尾添加 ">" 字符)。
name | 将开始的元素名称 |
component |
此元素对应的 UIComponent (如果有) |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 name 为 null |
startElement
public abstract void startElement(String name, UIComponent component) throws IOException
Write the start of an element, up to and including the element name. Once this method has been called, clients can call the
writeAttribute()
orwriteURIAttribute()
methods to add attributes and corresponding values. The starting element will be closed (that is, the trailing '>' character added) on any subsequent call tostartElement()
,writeComment()
,writeText()
,endElement()
,endDocument()
,close()
,flush()
, orwrite()
.- Parameters:
name
- Name of the element to be startedcomponent
- TheUIComponent
(if any) to which this element corresponds- Throws:
IOException
- if an input/output error occursNullPointerException
- ifname
isnull
abstract public void
endElement(String name) throws java.io.IOException
关闭通过调用 startElement()
创建的任何开放元素之后,写入元素的结尾。必须按照与打开顺序相反的顺序关闭元素;否则会出现错误。
name | 将结束的元素的名称。 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 name 为 null |
endElement
public abstract void endElement(String name) throws IOException
Write the end of an element, after closing any open element created by a call to
startElement()
. Elements must be closed in the inverse order from which they were opened; it is an error to do otherwise.- Parameters:
name
- Name of the element to be ended- Throws:
IOException
- if an input/output error occursNullPointerException
- ifname
isnull
abstract public void
writeAttribute(String name, Object value, String property) throws java.io.IOException
在将该文本转换为 String(如果必要)并执行与呈现的标记语言相应的任何转义之后,写入属性名称和相应的值。此方法只能在调用 startElement()
之后、关闭开放的元素之前调用。
name | 要添加的属性名称 |
value | 要添加的属性值 |
property |
与包含元素(对应于生成的属性)关联的 UIComponent 的属性(如果有)名称 |
Throws | IllegalStateException: 如果在当前没有打开的元素时调用此方法 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 name 为 null |
writeAttribute
public abstract void writeAttribute(String name, Object value, String property) throws IOException
Write an attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method may only be called after a call to
startElement()
, and before the opened element has been closed.- Parameters:
name
- Attribute name to be addedvalue
- Attribute value to be addedproperty
- Name of the property or attribute (if any) of theUIComponent
associated with the containing element, to which this generated attribute corresponds- Throws:
IllegalStateException
- if this method is called when there is no currently open elementIOException
- if an input/output error occursNullPointerException
- ifname
isnull
abstract public void
writeURIAttribute(String name, Object value, String property) throws java.io.IOException
在将该文本转换为 String(如果必要)并执行与呈现的标记语言相应的任何编码之后,写入 URI 属性名称和相应的值。此方法只能在调用 startElement()
之后、关闭开放的元素之前调用。
name | 要添加的属性名称 |
value | 要添加的属性值 |
property |
与包含元素(对应于生成的属性)关联的 UIComponent 的属性(如果有)名称 |
Throws | IllegalStateException: 如果在当前没有打开的元素时调用此方法 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 name 为 null |
writeURIAttribute
public abstract void writeURIAttribute(String name, Object value, String property) throws IOException
Write a URI attribute name and corresponding value, after converting that text to a String (if necessary), and after performing any encoding appropriate to the markup language being rendered. This method may only be called after a call to
startElement()
, and before the opened element has been closed.- Parameters:
name
- Attribute name to be addedvalue
- Attribute value to be addedproperty
- Name of the property or attribute (if any) of theUIComponent
associated with the containing element, to which this generated attribute corresponds- Throws:
IllegalStateException
- if this method is called when there is no currently open elementIOException
- if an input/output error occursNullPointerException
- ifname
isnull
abstract public void
writeComment(Object comment) throws java.io.IOException
在将该文本转换为 String(如果必要)并执行与呈现的标记语言相应的任何转义之后,写入包含指定文本的注释。如果存在调用 startElement()
创建的公开元素,则将首先关闭该元素。
comment | 注释的文本内容 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 comment 为 null |
writeComment
public abstract void writeComment(Object comment) throws IOException
Write a comment containing the specified text, after converting that text to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to
startElement()
, that element will be closed first.- Parameters:
comment
- Text content of the comment- Throws:
IOException
- if an input/output error occursNullPointerException
- ifcomment
isnull
abstract public void
writeText(Object text, String property) throws java.io.IOException
在转换为 String(如果必要),并执行与呈现的标记语言相应的转义之后,写入对象。如果存在调用 startElement()
创建的公开元素,则将首先关闭该元素。
text | 要写入的文本 |
property |
与包含元素(对应于生成的文本)关联的 UIComponent 的属性(如果有)名称 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 text 为 null |
writeText
public abstract void writeText(Object text, String property) throws IOException
Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to
startElement()
, that element will be closed first.- Parameters:
text
- Text to be writtenproperty
- Name of the property or attribute (if any) of theUIComponent
associated with the containing element, to which this generated text corresponds- Throws:
IOException
- if an input/output error occursNullPointerException
- iftext
isnull
public void
writeText(Object text, UIComponent component, String property) throws java.io.IOException
在转换为 String(如果必要),并执行与呈现的标记语言相应的转义之后,写入对象。该方法等效于 #writeText(java.lang.Object,java.lang.String)
,但添加了一个 component
属性,以允许自定义的 ResponseWriter
实现将组件与文本的任意部分关联。
默认的实现忽略 component
参数并接通 #writeText(java.lang.Object,java.lang.String)
text | 要写入的文本 |
component |
此元素对应的 UIComponent (如果有) |
property |
与包含元素(对应于生成的文本)关联的 UIComponent 的属性(如果有)名称 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 text 为 null |
since | 1.2 |
writeText
public void writeText(Object text, UIComponent component, String property) throws IOException
Write an object, after converting it to a String (if necessary), and after performing any escaping appropriate for the markup language being rendered. This method is equivalent to
writeText(java.lang.Object,java.lang.String)
but adds acomponent
property to allow customResponseWriter
implementations to associate a component with an arbitrary portion of text.The default implementation simply ignores the
component
argument and calls through towriteText(java.lang.Object,java.lang.String)
- Parameters:
text
- Text to be writtencomponent
- TheUIComponent
(if any) to which this element correspondsproperty
- Name of the property or attribute (if any) of theUIComponent
associated with the containing element, to which this generated text corresponds- Throws:
IOException
- if an input/output error occursNullPointerException
- iftext
isnull
- Since:
- 1.2
abstract public void
writeText(char[] text, int off, int len) throws java.io.IOException
执行呈现的标记语言相应的任何转义之后,从字符数组中写入文本。如果存在调用 startElement()
创建的公开元素,则将首先关闭该元素。
text | 要写入的文本 |
off | 起始偏移量(相对于 0) |
len | 要写入字符的数量 |
Throws | IndexOutOfBoundsException: 如果计算的开始或结束位置位于字符数组的边界之外 |
Throws | java.io.IOException: 如果发生输入/输出错误 |
Throws | NullPointerException:
如果 text 为 null |
writeText
public abstract void writeText(char[] text, int off, int len) throws IOException
Write text from a character array, after any performing any escaping appropriate for the markup language being rendered. If there is an open element that has been created by a call to
startElement()
, that element will be closed first.- Parameters:
text
- Text to be writtenoff
- Starting offset (zero-relative)len
- Number of characters to be written- Throws:
IndexOutOfBoundsException
- if the calculated starting or ending position is outside the bounds of the character arrayIOException
- if an input/output error occursNullPointerException
- iftext
isnull
abstract public ResponseWriter
cloneWithWriter(java.io.Writer writer)
使用指定的 Writer
作为输出目标,创建并返回此 ResponseWriter
的一个新实例。
writer |
作为输出目标的 Writer |
cloneWithWriter
public abstract ResponseWriter cloneWithWriter(Writer writer)
Create and return a new instance of this
ResponseWriter
, using the specifiedWriter
as the output destination.- Parameters:
writer
- TheWriter
that is the output destination
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!