1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Sun designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Sun in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 */
24
25 /*
26 * Copyright (c) 2003 by BEA Systems, Inc. All Rights Reserved.
27 */
28
29 package javax.xml.stream;
30
31 import java.io.Reader;
32 import javax.xml.namespace.NamespaceContext;
33 import javax.xml.namespace.QName;
34
35 /**
36 * The XMLStreamReader interface allows forward, read-only access to XML.
37 * It is designed to be the lowest level and most efficient way to
38 * read XML data.
39 *
40 * <p> The XMLStreamReader is designed to iterate over XML using
41 * next() and hasNext(). The data can be accessed using methods such as getEventType(),
42 * getNamespaceURI(), getLocalName() and getText();
43 *
44 * <p> The <a href="#next()">next()</a> method causes the reader to read the next parse event.
45 * The next() method returns an integer which identifies the type of event just read.
46 * <p> The event type can be determined using <a href="#getEventType()">getEventType()</a>.
47 * <p> Parsing events are defined as the XML Declaration, a DTD,
48 * start tag, character data, white space, end tag, comment,
49 * or processing instruction. An attribute or namespace event may be encountered
50 * at the root level of a document as the result of a query operation.
51 *
52 * <p>For XML 1.0 compliance an XML processor must pass the
53 * identifiers of declared unparsed entities, notation declarations and their
54 * associated identifiers to the application. This information is
55 * provided through the property API on this interface.
56 * The following two properties allow access to this information:
57 * javax.xml.stream.notations and javax.xml.stream.entities.
58 * When the current event is a DTD the following call will return a
59 * list of Notations
60 * <code>List l = (List) getProperty("javax.xml.stream.notations");</code>
61 * The following call will return a list of entity declarations:
62 * <code>List l = (List) getProperty("javax.xml.stream.entities");</code>
63 * These properties can only be accessed during a DTD event and
64 * are defined to return null if the information is not available.
65 *
66 * <p>The following table describes which methods are valid in what state.
67 * If a method is called in an invalid state the method will throw a
68 * java.lang.IllegalStateException.
69 *
70 * <table border="2" rules="all" cellpadding="4">
71 * <thead>
72 * <tr>
73 * <th align="center" colspan="2">
74 * Valid methods for each state
75 * </th>
76 * </tr>
77 * </thead>
78 * <tbody>
79 * <tr>
80 * <th>Event Type</th>
81 * <th>Valid Methods</th>
82 * </tr>
83 * <tr>
84 * <td> All States </td>
85 * <td> getProperty(), hasNext(), require(), close(),
86 * getNamespaceURI(), isStartElement(),
87 * isEndElement(), isCharacters(), isWhiteSpace(),
88 * getNamespaceContext(), getEventType(),getLocation(),
89 * hasText(), hasName()
90 * </td>
91 * </tr>
92 * <tr>
93 * <td> START_ELEMENT </td>
94 * <td> next(), getName(), getLocalName(), hasName(), getPrefix(),
95 * getAttributeXXX(), isAttributeSpecified(),
96 * getNamespaceXXX(),
97 * getElementText(), nextTag()
98 * </td>
99 * </tr>
100 * <td> ATTRIBUTE </td>
101 * <td> next(), nextTag()
102 * getAttributeXXX(), isAttributeSpecified(),
103 * </td>
104 * </tr>
105 * </tr>
106 * <td> NAMESPACE </td>
107 * <td> next(), nextTag()
108 * getNamespaceXXX()
109 * </td>
110 * </tr>
111 * <tr>
112 * <td> END_ELEMENT </td>
113 * <td> next(), getName(), getLocalName(), hasName(), getPrefix(),
114 * getNamespaceXXX(), nextTag()
115 * </td>
116 * </tr>
117 * <tr>
118 * <td> CHARACTERS </td>
119 * <td> next(), getTextXXX(), nextTag() </td>
120 * </tr>
121 * <tr>
122 * <td> CDATA </td>
123 * <td> next(), getTextXXX(), nextTag() </td>
124 * </tr>
125 * <tr>
126 * <td> COMMENT </td>
127 * <td> next(), getTextXXX(), nextTag() </td>
128 * </tr>
129 * <tr>
130 * <td> SPACE </td>
131 * <td> next(), getTextXXX(), nextTag() </td>
132 * </tr>
133 * <tr>
134 * <td> START_DOCUMENT </td>
135 * <td> next(), getEncoding(), getVersion(), isStandalone(), standaloneSet(),
136 * getCharacterEncodingScheme(), nextTag()</td>
137 * </tr>
138 * <tr>
139 * <td> END_DOCUMENT </td>
140 * <td> close()</td>
141 * </tr>
142 * <tr>
143 * <td> PROCESSING_INSTRUCTION </td>
144 * <td> next(), getPITarget(), getPIData(), nextTag() </td>
145 * </tr>
146 * <tr>
147 * <td> ENTITY_REFERENCE </td>
148 * <td> next(), getLocalName(), getText(), nextTag() </td>
149 * </tr>
150 * <tr>
151 * <td> DTD </td>
152 * <td> next(), getText(), nextTag() </td>
153 * </tr>
154 * </tbody>
155 * </table>
156 *
157 * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
158 * @see javax.xml.stream.events.XMLEvent
159 * @see XMLInputFactory
160 * @see XMLStreamWriter
161 * @since 1.6
162 */
163 public interface XMLStreamReader extends XMLStreamConstants {
164 /**
165 * Get the value of a feature/property from the underlying implementation
166 * @param name The name of the property, may not be null
167 * @return The value of the property
168 * @throws IllegalArgumentException if name is null
169 */
170 public Object getProperty(java.lang.String name) throws java.lang.IllegalArgumentException;
171
172 /**
173 * Get next parsing event - a processor may return all contiguous
174 * character data in a single chunk, or it may split it into several chunks.
175 * If the property javax.xml.stream.isCoalescing is set to true
176 * element content must be coalesced and only one CHARACTERS event
177 * must be returned for contiguous element content or
178 * CDATA Sections.
179 *
180 * By default entity references must be
181 * expanded and reported transparently to the application.
182 * An exception will be thrown if an entity reference cannot be expanded.
183 * If element content is empty (i.e. content is "") then no CHARACTERS event will be reported.
184 *
185 * <p>Given the following XML:<br>
186 * <foo><!--description-->content text<![CDATA[<greeting>Hello</greeting>]]>other content</foo><br>
187 * The behavior of calling next() when being on foo will be:<br>
188 * 1- the comment (COMMENT)<br>
189 * 2- then the characters section (CHARACTERS)<br>
190 * 3- then the CDATA section (another CHARACTERS)<br>
191 * 4- then the next characters section (another CHARACTERS)<br>
192 * 5- then the END_ELEMENT<br>
193 *
194 * <p><b>NOTE:</b> empty element (such as <tag/>) will be reported
195 * with two separate events: START_ELEMENT, END_ELEMENT - This preserves
196 * parsing equivalency of empty element to <tag></tag>.
197 *
198 * This method will throw an IllegalStateException if it is called after hasNext() returns false.
199 * @see javax.xml.stream.events.XMLEvent
200 * @return the integer code corresponding to the current parse event
201 * @throws NoSuchElementException if this is called when hasNext() returns false
202 * @throws XMLStreamException if there is an error processing the underlying XML source
203 */
204 public int next() throws XMLStreamException;
205
206 /**
207 * Test if the current event is of the given type and if the namespace and name match the current
208 * namespace and name of the current event. If the namespaceURI is null it is not checked for equality,
209 * if the localName is null it is not checked for equality.
210 * @param type the event type
211 * @param namespaceURI the uri of the event, may be null
212 * @param localName the localName of the event, may be null
213 * @throws XMLStreamException if the required values are not matched.
214 */
215 public void require(int type, String namespaceURI, String localName) throws XMLStreamException;
216
217 /**
218 * Reads the content of a text-only element, an exception is thrown if this is
219 * not a text-only element.
220 * Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content.
221 * <br /> Precondition: the current event is START_ELEMENT.
222 * <br /> Postcondition: the current event is the corresponding END_ELEMENT.
223 *
224 * <br />The method does the following (implementations are free to optimized
225 * but must do equivalent processing):
226 * <pre>
227 * if(getEventType() != XMLStreamConstants.START_ELEMENT) {
228 * throw new XMLStreamException(
229 * "parser must be on START_ELEMENT to read next text", getLocation());
230 * }
231 * int eventType = next();
232 * StringBuffer content = new StringBuffer();
233 * while(eventType != XMLStreamConstants.END_ELEMENT ) {
234 * if(eventType == XMLStreamConstants.CHARACTERS
235 * || eventType == XMLStreamConstants.CDATA
236 * || eventType == XMLStreamConstants.SPACE
237 * || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
238 * buf.append(getText());
239 * } else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
240 * || eventType == XMLStreamConstants.COMMENT) {
241 * // skipping
242 * } else if(eventType == XMLStreamConstants.END_DOCUMENT) {
243 * throw new XMLStreamException(
244 * "unexpected end of document when reading element text content", this);
245 * } else if(eventType == XMLStreamConstants.START_ELEMENT) {
246 * throw new XMLStreamException(
247 * "element text content may not contain START_ELEMENT", getLocation());
248 * } else {
249 * throw new XMLStreamException(
250 * "Unexpected event type "+eventType, getLocation());
251 * }
252 * eventType = next();
253 * }
254 * return buf.toString();
255 * </pre>
256 *
257 * @throws XMLStreamException if the current event is not a START_ELEMENT
258 * or if a non text element is encountered
259 */
260 public String getElementText() throws XMLStreamException;
261
262 /**
263 * Skips any white space (isWhiteSpace() returns true), COMMENT,
264 * or PROCESSING_INSTRUCTION,
265 * until a START_ELEMENT or END_ELEMENT is reached.
266 * If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT
267 * are encountered, an exception is thrown. This method should
268 * be used when processing element-only content seperated by white space.
269 *
270 * <br /> Precondition: none
271 * <br /> Postcondition: the current event is START_ELEMENT or END_ELEMENT
272 * and cursor may have moved over any whitespace event.
273 *
274 * <br />Essentially it does the following (implementations are free to optimized
275 * but must do equivalent processing):
276 * <pre>
277 * int eventType = next();
278 * while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace
279 * || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
280 * // skip whitespace
281 * || eventType == XMLStreamConstants.SPACE
282 * || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
283 * || eventType == XMLStreamConstants.COMMENT
284 * ) {
285 * eventType = next();
286 * }
287 * if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) {
288 * throw new String XMLStreamException("expected start or end tag", getLocation());
289 * }
290 * return eventType;
291 * </pre>
292 *
293 * @return the event type of the element read (START_ELEMENT or END_ELEMENT)
294 * @throws XMLStreamException if the current event is not white space, PROCESSING_INSTRUCTION,
295 * START_ELEMENT or END_ELEMENT
296 * @throws NoSuchElementException if this is called when hasNext() returns false
297 */
298 public int nextTag() throws XMLStreamException;
299
300 /**
301 * Returns true if there are more parsing events and false
302 * if there are no more events. This method will return
303 * false if the current state of the XMLStreamReader is
304 * END_DOCUMENT
305 * @return true if there are more events, false otherwise
306 * @throws XMLStreamException if there is a fatal error detecting the next state
307 */
308 public boolean hasNext() throws XMLStreamException;
309
310 /**
311 * Frees any resources associated with this Reader. This method does not close the
312 * underlying input source.
313 * @throws XMLStreamException if there are errors freeing associated resources
314 */
315 public void close() throws XMLStreamException;
316
317 /**
318 * Return the uri for the given prefix.
319 * The uri returned depends on the current state of the processor.
320 *
321 * <p><strong>NOTE:</strong>The 'xml' prefix is bound as defined in
322 * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a>
323 * specification to "http://www.w3.org/XML/1998/namespace".
324 *
325 * <p><strong>NOTE:</strong> The 'xmlns' prefix must be resolved to following namespace
326 * <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
327 * @param prefix The prefix to lookup, may not be null
328 * @return the uri bound to the given prefix or null if it is not bound
329 * @throws IllegalArgumentException if the prefix is null
330 */
331 public String getNamespaceURI(String prefix);
332
333 /**
334 * Returns true if the cursor points to a start tag (otherwise false)
335 * @return true if the cursor points to a start tag, false otherwise
336 */
337 public boolean isStartElement();
338
339 /**
340 * Returns true if the cursor points to an end tag (otherwise false)
341 * @return true if the cursor points to an end tag, false otherwise
342 */
343 public boolean isEndElement();
344
345 /**
346 * Returns true if the cursor points to a character data event
347 * @return true if the cursor points to character data, false otherwise
348 */
349 public boolean isCharacters();
350
351 /**
352 * Returns true if the cursor points to a character data event
353 * that consists of all whitespace
354 * @return true if the cursor points to all whitespace, false otherwise
355 */
356 public boolean isWhiteSpace();
357
358
359 /**
360 * Returns the normalized attribute value of the
361 * attribute with the namespace and localName
362 * If the namespaceURI is null the namespace
363 * is not checked for equality
364 * @param namespaceURI the namespace of the attribute
365 * @param localName the local name of the attribute, cannot be null
366 * @return returns the value of the attribute , returns null if not found
367 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
368 */
369 public String getAttributeValue(String namespaceURI,
370 String localName);
371
372 /**
373 * Returns the count of attributes on this START_ELEMENT,
374 * this method is only valid on a START_ELEMENT or ATTRIBUTE. This
375 * count excludes namespace definitions. Attribute indices are
376 * zero-based.
377 * @return returns the number of attributes
378 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
379 */
380 public int getAttributeCount();
381
382 /** Returns the qname of the attribute at the provided index
383 *
384 * @param index the position of the attribute
385 * @return the QName of the attribute
386 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
387 */
388 public QName getAttributeName(int index);
389
390 /**
391 * Returns the namespace of the attribute at the provided
392 * index
393 * @param index the position of the attribute
394 * @return the namespace URI (can be null)
395 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
396 */
397 public String getAttributeNamespace(int index);
398
399 /**
400 * Returns the localName of the attribute at the provided
401 * index
402 * @param index the position of the attribute
403 * @return the localName of the attribute
404 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
405 */
406 public String getAttributeLocalName(int index);
407
408 /**
409 * Returns the prefix of this attribute at the
410 * provided index
411 * @param index the position of the attribute
412 * @return the prefix of the attribute
413 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
414 */
415 public String getAttributePrefix(int index);
416
417 /**
418 * Returns the XML type of the attribute at the provided
419 * index
420 * @param index the position of the attribute
421 * @return the XML type of the attribute
422 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
423 */
424 public String getAttributeType(int index);
425
426 /**
427 * Returns the value of the attribute at the
428 * index
429 * @param index the position of the attribute
430 * @return the attribute value
431 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
432 */
433 public String getAttributeValue(int index);
434
435 /**
436 * Returns a boolean which indicates if this
437 * attribute was created by default
438 * @param index the position of the attribute
439 * @return true if this is a default attribute
440 * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
441 */
442 public boolean isAttributeSpecified(int index);
443
444 /**
445 * Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT,
446 * this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE. On
447 * an END_ELEMENT the count is of the namespaces that are about to go
448 * out of scope. This is the equivalent of the information reported
449 * by SAX callback for an end element event.
450 * @return returns the number of namespace declarations on this specific element
451 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
452 */
453 public int getNamespaceCount();
454
455 /**
456 * Returns the prefix for the namespace declared at the
457 * index. Returns null if this is the default namespace
458 * declaration
459 *
460 * @param index the position of the namespace declaration
461 * @return returns the namespace prefix
462 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
463 */
464 public String getNamespacePrefix(int index);
465
466 /**
467 * Returns the uri for the namespace declared at the
468 * index.
469 *
470 * @param index the position of the namespace declaration
471 * @return returns the namespace uri
472 * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
473 */
474 public String getNamespaceURI(int index);
475
476 /**
477 * Returns a read only namespace context for the current
478 * position. The context is transient and only valid until
479 * a call to next() changes the state of the reader.
480 * @return return a namespace context
481 */
482 public NamespaceContext getNamespaceContext();
483
484 /**
485 * Returns a reader that points to the current start element
486 * and all of its contents. Throws an XMLStreamException if the
487 * cursor does not point to a START_ELEMENT.<p>
488 * The sub stream is read from it MUST be read before the parent stream is
489 * moved on, if not any call on the sub stream will cause an XMLStreamException to be
490 * thrown. The parent stream will always return the same result from next()
491 * whatever is done to the sub stream.
492 * @return an XMLStreamReader which points to the next element
493 */
494 // public XMLStreamReader subReader() throws XMLStreamException;
495
496 /**
497 * Allows the implementation to reset and reuse any underlying tables
498 */
499 // public void recycle() throws XMLStreamException;
500
501 /**
502 * Returns an integer code that indicates the type
503 * of the event the cursor is pointing to.
504 */
505 public int getEventType();
506
507 /**
508 * Returns the current value of the parse event as a string,
509 * this returns the string value of a CHARACTERS event,
510 * returns the value of a COMMENT, the replacement value
511 * for an ENTITY_REFERENCE, the string value of a CDATA section,
512 * the string value for a SPACE event,
513 * or the String value of the internal subset of the DTD.
514 * If an ENTITY_REFERENCE has been resolved, any character data
515 * will be reported as CHARACTERS events.
516 * @return the current text or null
517 * @throws java.lang.IllegalStateException if this state is not
518 * a valid text state.
519 */
520 public String getText();
521
522 /**
523 * Returns an array which contains the characters from this event.
524 * This array should be treated as read-only and transient. I.e. the array will
525 * contain the text characters until the XMLStreamReader moves on to the next event.
526 * Attempts to hold onto the character array beyond that time or modify the
527 * contents of the array are breaches of the contract for this interface.
528 * @return the current text or an empty array
529 * @throws java.lang.IllegalStateException if this state is not
530 * a valid text state.
531 */
532 public char[] getTextCharacters();
533
534 /**
535 * Gets the the text associated with a CHARACTERS, SPACE or CDATA event.
536 * Text starting a "sourceStart" is copied into "target" starting at "targetStart".
537 * Up to "length" characters are copied. The number of characters actually copied is returned.
538 *
539 * The "sourceStart" argument must be greater or equal to 0 and less than or equal to
540 * the number of characters associated with the event. Usually, one requests text starting at a "sourceStart" of 0.
541 * If the number of characters actually copied is less than the "length", then there is no more text.
542 * Otherwise, subsequent calls need to be made until all text has been retrieved. For example:
543 *
544 *<code>
545 * int length = 1024;
546 * char[] myBuffer = new char[ length ];
547 *
548 * for ( int sourceStart = 0 ; ; sourceStart += length )
549 * {
550 * int nCopied = stream.getTextCharacters( sourceStart, myBuffer, 0, length );
551 *
552 * if (nCopied < length)
553 * break;
554 * }
555 * </code>
556 * XMLStreamException may be thrown if there are any XML errors in the underlying source.
557 * The "targetStart" argument must be greater than or equal to 0 and less than the length of "target",
558 * Length must be greater than 0 and "targetStart + length" must be less than or equal to length of "target".
559 *
560 * @param sourceStart the index of the first character in the source array to copy
561 * @param target the destination array
562 * @param targetStart the start offset in the target array
563 * @param length the number of characters to copy
564 * @return the number of characters actually copied
565 * @throws XMLStreamException if the underlying XML source is not well-formed
566 * @throws IndexOutOfBoundsException if targetStart < 0 or > than the length of target
567 * @throws IndexOutOfBoundsException if length < 0 or targetStart + length > length of target
568 * @throws UnsupportedOperationException if this method is not supported
569 * @throws NullPointerException is if target is null
570 */
571 public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
572 throws XMLStreamException;
573
574 /**
575 * Gets the text associated with a CHARACTERS, SPACE or CDATA event. Allows the underlying
576 * implementation to return the text as a stream of characters. The reference to the
577 * Reader returned by this method is only valid until next() is called.
578 *
579 * All characters must have been checked for well-formedness.
580 *
581 * <p> This method is optional and will throw UnsupportedOperationException if it is not supported.
582 * @throws UnsupportedOperationException if this method is not supported
583 * @throws IllegalStateException if this is not a valid text state
584 */
585 //public Reader getTextStream();
586
587 /**
588 * Returns the offset into the text character array where the first
589 * character (of this text event) is stored.
590 * @throws java.lang.IllegalStateException if this state is not
591 * a valid text state.
592 */
593 public int getTextStart();
594
595 /**
596 * Returns the length of the sequence of characters for this
597 * Text event within the text character array.
598 * @throws java.lang.IllegalStateException if this state is not
599 * a valid text state.
600 */
601 public int getTextLength();
602
603 /**
604 * Return input encoding if known or null if unknown.
605 * @return the encoding of this instance or null
606 */
607 public String getEncoding();
608
609 /**
610 * Return true if the current event has text, false otherwise
611 * The following events have text:
612 * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT, SPACE
613 */
614 public boolean hasText();
615
616 /**
617 * Return the current location of the processor.
618 * If the Location is unknown the processor should return
619 * an implementation of Location that returns -1 for the
620 * location and null for the publicId and systemId.
621 * The location information is only valid until next() is
622 * called.
623 */
624 public Location getLocation();
625
626 /**
627 * Returns a QName for the current START_ELEMENT or END_ELEMENT event
628 * @return the QName for the current START_ELEMENT or END_ELEMENT event
629 * @throws IllegalStateException if this is not a START_ELEMENT or
630 * END_ELEMENT
631 */
632 public QName getName();
633
634 /**
635 * Returns the (local) name of the current event.
636 * For START_ELEMENT or END_ELEMENT returns the (local) name of the current element.
637 * For ENTITY_REFERENCE it returns entity name.
638 * The current event must be START_ELEMENT or END_ELEMENT,
639 * or ENTITY_REFERENCE
640 * @return the localName
641 * @throws IllegalStateException if this not a START_ELEMENT,
642 * END_ELEMENT or ENTITY_REFERENCE
643 */
644 public String getLocalName();
645
646 /**
647 * returns true if the current event has a name (is a START_ELEMENT or END_ELEMENT)
648 * returns false otherwise
649 */
650 public boolean hasName();
651
652 /**
653 * If the current event is a START_ELEMENT or END_ELEMENT this method
654 * returns the URI of the prefix or the default namespace.
655 * Returns null if the event does not have a prefix.
656 * @return the URI bound to this elements prefix, the default namespace, or null
657 */
658 public String getNamespaceURI();
659
660 /**
661 * Returns the prefix of the current event or null if the event does not have a prefix
662 * @return the prefix or null
663 */
664 public String getPrefix();
665
666 /**
667 * Get the xml version declared on the xml declaration
668 * Returns null if none was declared
669 * @return the XML version or null
670 */
671 public String getVersion();
672
673 /**
674 * Get the standalone declaration from the xml declaration
675 * @return true if this is standalone, or false otherwise
676 */
677 public boolean isStandalone();
678
679 /**
680 * Checks if standalone was set in the document
681 * @return true if standalone was set in the document, or false otherwise
682 */
683 public boolean standaloneSet();
684
685 /**
686 * Returns the character encoding declared on the xml declaration
687 * Returns null if none was declared
688 * @return the encoding declared in the document or null
689 */
690 public String getCharacterEncodingScheme();
691
692 /**
693 * Get the target of a processing instruction
694 * @return the target or null
695 */
696 public String getPITarget();
697
698 /**
699 * Get the data section of a processing instruction
700 * @return the data or null
701 */
702 public String getPIData();
703 }