XMLEvent (Java EE 5)

Java EE API


javax.xml.stream.events Interface XMLEvent

All Superinterfaces:
XMLStreamConstants
All Known Subinterfaces:
Attribute, Characters, Comment, DTD, EndDocument, EndElement, EntityDeclaration, EntityReference, Namespace, NotationDeclaration, ProcessingInstruction, StartDocument, StartElement

public interface XMLEvent
extends XMLStreamConstants

Implements: XMLStreamConstants

处理标记事件的基础事件接口。事件是用来与应用程序交流 XML 1.0 InfoSet 的 value 对象。可以在解析完事件之后缓存和引用事件。
英文文档:

This is the base event interface for handling markup events. Events are value objects that are used to communicate the XML 1.0 InfoSet to the Application. Events may be cached and referenced after the parse has completed.

Version:
1.0
Author:
Copyright (c) 2003 by BEA Systems. All Rights Reserved.
See Also:
XMLEventReader, Characters, ProcessingInstruction, StartElement, EndElement, StartDocument, EndDocument, EntityReference, EntityDeclaration, NotationDeclaration

Field Summary
 
Fields inherited from interface javax.xml.stream.XMLStreamConstants
 
Method Summary
 Characters
 EndElement
 StartElement
 int
 Location
 QName
 boolean
 boolean
 boolean
 boolean
 boolean
 boolean
 boolean
 boolean
 boolean
 void
 

Method Detail

public int getEventType()
返回此事件的整数码。
See also START_ELEMENT, END_ELEMENT, CHARACTERS, ATTRIBUTE, NAMESPACE, PROCESSING_INSTRUCTION, COMMENT, START_DOCUMENT, END_DOCUMENT, DTD
英文文档:

getEventType

int getEventType()
Returns an integer code for this event.

See Also:
XMLStreamConstants.START_ELEMENT, XMLStreamConstants.END_ELEMENT, XMLStreamConstants.CHARACTERS, XMLStreamConstants.ATTRIBUTE, XMLStreamConstants.NAMESPACE, XMLStreamConstants.PROCESSING_INSTRUCTION, XMLStreamConstants.COMMENT, XMLStreamConstants.START_DOCUMENT, XMLStreamConstants.END_DOCUMENT, XMLStreamConstants.DTD

public Location getLocation()
返回此事件的位置。此方法返回的 Location 是不易改变的,将保留其信息。
See also javax.xml.stream.Location
英文文档:

getLocation

Location getLocation()
Return the location of this event. The Location returned from this method is non-volatile and will retain its information.

See Also:
Location

public boolean isStartElement()
检查此事件是否为 StartElement 的实用工具函数。
See also javax.xml.stream.events.StartElement
英文文档:

isStartElement

boolean isStartElement()
A utility function to check if this event is a StartElement.

See Also:
StartElement

public boolean isAttribute()
检查此事件是否为 Attribute 的实用工具函数。
See also javax.xml.stream.events.Attribute
英文文档:

isAttribute

boolean isAttribute()
A utility function to check if this event is an Attribute.

See Also:
Attribute

public boolean isNamespace()
检查此事件是否为 Namespace 的实用工具函数。
See also javax.xml.stream.events.Namespace
英文文档:

isNamespace

boolean isNamespace()
A utility function to check if this event is a Namespace.

See Also:
Namespace

public boolean isEndElement()
检查此事件是否为 EndElement 的实用工具函数。
See also javax.xml.stream.events.EndElement
英文文档:

isEndElement

boolean isEndElement()
A utility function to check if this event is a EndElement.

See Also:
EndElement

public boolean isEntityReference()
检查此事件是否为 EntityReference 的实用工具函数。
See also javax.xml.stream.events.EntityReference
英文文档:

isEntityReference

boolean isEntityReference()
A utility function to check if this event is an EntityReference.

See Also:
EntityReference

public boolean isProcessingInstruction()
检查此事件是否为 ProcessingInstruction 的实用工具函数。
See also javax.xml.stream.events.ProcessingInstruction
英文文档:

isProcessingInstruction

boolean isProcessingInstruction()
A utility function to check if this event is a ProcessingInstruction.

See Also:
ProcessingInstruction

public boolean isCharacters()
检查此事件是否为 Characters 的实用工具函数。
See also javax.xml.stream.events.Characters
英文文档:

isCharacters

boolean isCharacters()
A utility function to check if this event is Characters.

See Also:
Characters

public boolean isStartDocument()
检查此事件是否为 StartDocument 的实用工具函数。
See also javax.xml.stream.events.StartDocument
英文文档:

isStartDocument

boolean isStartDocument()
A utility function to check if this event is a StartDocument.

See Also:
StartDocument

public boolean isEndDocument()
检查此事件是否为 EndDocument 的实用工具函数。
See also javax.xml.stream.events.EndDocument
英文文档:

isEndDocument

boolean isEndDocument()
A utility function to check if this event is an EndDocument.

See Also:
EndDocument

public StartElement asStartElement()
将此事件作为开始元素事件返回,如果此事件不是开始元素,则可能导致类强制转换异常。
英文文档:

asStartElement

StartElement asStartElement()
Returns this event as a start element event, may result in a class cast exception if this event is not a start element.


public EndElement asEndElement()
将此事件作为结束元素事件返回,如果此事件不是结束元素,则可能导致类强制转换异常。
英文文档:

asEndElement

EndElement asEndElement()
Returns this event as an end element event, may result in a class cast exception if this event is not a end element.


public Characters asCharacters()
将此事件作为 Characters 返回,如果此事件不是字符,则可能导致类强制转化异常。
英文文档:

asCharacters

Characters asCharacters()
Returns this event as Characters, may result in a class cast exception if this event is not Characters.


public javax.xml.namespace.QName getSchemaType()
提供此方法是为了提供有关关联事件的可选类型信息。信息是可选的,如果没有可用信息,则返回 null。
英文文档:

getSchemaType

QName getSchemaType()
This method is provided for implementations to provide optional type information about the associated event. It is optional and will return null if no information is available.


public void writeAsEncodedUnicode(java.io.Writer writer) throws XMLStreamException
此方法根据 XML 1.0 规范将 XMLEvent 编写为 Unicode 字符。不应输出缩排或空格。 在将任何用户定义的事件类型写入输出流时,都应当调用此方法。内置 Event 类型必须实现此方法,但是在将内置 Event 写出到输出流时,为了优化目的,可以选择而不调用这些方法。生成的输出必须与所表示的信息集等效。
writer 将输出数据的编写器
ThrowsXMLStreamException: 如果在写入事件时发生严重错误
英文文档:

writeAsEncodedUnicode

void writeAsEncodedUnicode(Writer writer)
                           throws XMLStreamException
This method will write the XMLEvent as per the XML 1.0 specification as Unicode characters. No indentation or whitespace should be outputted. Any user defined event type SHALL have this method called when being written to on an output stream. Built in Event types MUST implement this method, but implementations MAY choose not call these methods for optimizations reasons when writing out built in Events to an output stream. The output generated MUST be equivalent in terms of the infoset expressed.

Parameters:
writer - The writer that will output the data
Throws:
XMLStreamException - if there is a fatal error writing the event


Submit a bug or feature

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

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

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