01: package javax.xml.stream;
02:
03: import javax.xml.stream.events.XMLEvent;
04: import java.util.Iterator;
05:
06: /**
07: *
08: * This is the top level interface for parsing XML Events. It provides
09: * the ability to peek at the next event and returns configuration
10: * information through the property interface.
11: *
12: * @version 1.0
13: * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
14: * @see XMLInputFactory
15: * @see XMLEventWriter
16: */
17: public interface XMLEventReader extends Iterator {
18: /**
19: * Get the next XMLEvent
20: * @see XMLEvent
21: * @throws XMLStreamException if there is an error with the underlying XML.
22: * @throws NoSuchElementException iteration has no more elements.
23: */
24: public XMLEvent nextEvent() throws XMLStreamException;
25:
26: /**
27: * Check if there are more events.
28: * Returns true if there are more events and false otherwise.
29: * @return true if the event reader has more events, false otherwise
30: */
31: public boolean hasNext();
32:
33: /**
34: * Check the next XMLEvent without reading it from the stream.
35: * Returns null if the stream is at EOF or has no more XMLEvents.
36: * A call to peek() will be equal to the next return of next().
37: * @see XMLEvent
38: * @throws XMLStreamException
39: */
40: public XMLEvent peek() throws XMLStreamException;
41:
42: /**
43: * Reads the content of a text-only element. Precondition:
44: * the current event is START_ELEMENT. Postcondition:
45: * The current event is the corresponding END_ELEMENT.
46: * @throws XMLStreamException if the current event is not a START_ELEMENT
47: * or if a non text element is encountered
48: */
49: public String getElementText() throws XMLStreamException;
50:
51: /**
52: * Skips any insignificant space events until a START_ELEMENT or
53: * END_ELEMENT is reached. If anything other than space characters are
54: * encountered, an exception is thrown. This method should
55: * be used when processing element-only content because
56: * the parser is not able to recognize ignorable whitespace if
57: * the DTD is missing or not interpreted.
58: * @throws XMLStreamException if anything other than space characters are encountered
59: */
60: public XMLEvent nextTag() throws XMLStreamException;
61:
62: /**
63: * Get the value of a feature/property from the underlying implementation
64: * @param name The name of the property
65: * @return The value of the property
66: * @throws IllegalArgumentException if the property is not supported
67: */
68: public Object getProperty(java.lang.String name)
69: throws java.lang.IllegalArgumentException;
70:
71: /**
72: * Frees any resources associated with this Reader. This method does not close the
73: * underlying input source.
74: * @throws XMLStreamException if there are errors freeing associated resources
75: */
76: public void close() throws XMLStreamException;
77: }
|