001 package javax.xml.stream.events;
002
003 import java.io.Writer;
004 import javax.xml.namespace.QName;
005
006 /**
007 * This is the base event interface for handling markup events.
008 * Events are value objects that are used to communicate the
009 * XML 1.0 InfoSet to the Application. Events may be cached
010 * and referenced after the parse has completed.
011 *
012 * @version 1.0
013 * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
014 * @see javax.xml.stream.XMLEventReader
015 * @see Characters
016 * @see ProcessingInstruction
017 * @see StartElement
018 * @see EndElement
019 * @see StartDocument
020 * @see EndDocument
021 * @see EntityReference
022 * @see EntityDeclaration
023 * @see NotationDeclaration
024 * @since 1.6
025 */
026 public interface XMLEvent extends javax.xml.stream.XMLStreamConstants {
027
028 /**
029 * Returns an integer code for this event.
030 * @see #START_ELEMENT
031 * @see #END_ELEMENT
032 * @see #CHARACTERS
033 * @see #ATTRIBUTE
034 * @see #NAMESPACE
035 * @see #PROCESSING_INSTRUCTION
036 * @see #COMMENT
037 * @see #START_DOCUMENT
038 * @see #END_DOCUMENT
039 * @see #DTD
040 */
041 public int getEventType();
042
043 /**
044 * Return the location of this event. The Location
045 * returned from this method is non-volatile and
046 * will retain its information.
047 * @see javax.xml.stream.Location
048 */
049 javax.xml.stream.Location getLocation();
050
051 /**
052 * A utility function to check if this event is a StartElement.
053 * @see StartElement
054 */
055 public boolean isStartElement();
056
057 /**
058 * A utility function to check if this event is an Attribute.
059 * @see Attribute
060 */
061 public boolean isAttribute();
062
063 /**
064 * A utility function to check if this event is a Namespace.
065 * @see Namespace
066 */
067 public boolean isNamespace();
068
069 /**
070 * A utility function to check if this event is a EndElement.
071 * @see EndElement
072 */
073 public boolean isEndElement();
074
075 /**
076 * A utility function to check if this event is an EntityReference.
077 * @see EntityReference
078 */
079 public boolean isEntityReference();
080
081 /**
082 * A utility function to check if this event is a ProcessingInstruction.
083 * @see ProcessingInstruction
084 */
085 public boolean isProcessingInstruction();
086
087 /**
088 * A utility function to check if this event is Characters.
089 * @see Characters
090 */
091 public boolean isCharacters();
092
093 /**
094 * A utility function to check if this event is a StartDocument.
095 * @see StartDocument
096 */
097 public boolean isStartDocument();
098
099 /**
100 * A utility function to check if this event is an EndDocument.
101 * @see EndDocument
102 */
103 public boolean isEndDocument();
104
105 /**
106 * Returns this event as a start element event, may result in
107 * a class cast exception if this event is not a start element.
108 */
109 public StartElement asStartElement();
110
111 /**
112 * Returns this event as an end element event, may result in
113 * a class cast exception if this event is not a end element.
114 */
115 public EndElement asEndElement();
116
117 /**
118 * Returns this event as Characters, may result in
119 * a class cast exception if this event is not Characters.
120 */
121 public Characters asCharacters();
122
123 /**
124 * This method is provided for implementations to provide
125 * optional type information about the associated event.
126 * It is optional and will return null if no information
127 * is available.
128 */
129 public QName getSchemaType();
130
131 /**
132 * This method will write the XMLEvent as per the XML 1.0 specification as Unicode characters.
133 * No indentation or whitespace should be outputted.
134 *
135 * Any user defined event type SHALL have this method
136 * called when being written to on an output stream.
137 * Built in Event types MUST implement this method,
138 * but implementations MAY choose not call these methods
139 * for optimizations reasons when writing out built in
140 * Events to an output stream.
141 * The output generated MUST be equivalent in terms of the
142 * infoset expressed.
143 *
144 * @param writer The writer that will output the data
145 * @throws XMLStreamException if there is a fatal error writing the event
146 */
147 public void writeAsEncodedUnicode(Writer writer)
148 throws javax.xml.stream.XMLStreamException;
149
150 }
|