1 /*
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
51 * @throws XMLStreamException if there is an error with the underlying XML.
52 * @throws java.util.NoSuchElementException iteration has no more elements.
53 */
54 public XMLEvent nextEvent() throws XMLStreamException;
55
56 /**
57 * Check if there are more events.
58 * Returns true if there are more events and false otherwise.
59 * @return true if the event reader has more events, false otherwise
60 */
61 @Override
62 public boolean hasNext();
63
64 /**
65 * Check the next XMLEvent without reading it from the stream.
66 * Returns null if the stream is at EOF or has no more XMLEvents.
67 * A call to peek() will be equal to the next return of next().
68 *
69 * @return the next XMLEvent
70 * @see XMLEvent
71 * @throws XMLStreamException
72 */
73 public XMLEvent peek() throws XMLStreamException;
74
75 /**
76 * Reads the content of a text-only element. Precondition:
77 * the current event is START_ELEMENT. Postcondition:
78 * The current event is the corresponding END_ELEMENT.
79 *
80 * @return the text of the element
81 * @throws XMLStreamException if the current event is not a START_ELEMENT
82 * or if a non text element is encountered
83 */
84 public String getElementText() throws XMLStreamException;
85
86 /**
87 * Skips any insignificant space events until a START_ELEMENT or
88 * END_ELEMENT is reached. If anything other than space characters are
89 * encountered, an exception is thrown. This method should
90 * be used when processing element-only content because
91 * the parser is not able to recognize ignorable whitespace if
|
1 /*
2 * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
51 * @throws XMLStreamException if there is an error with the underlying XML.
52 * @throws java.util.NoSuchElementException iteration has no more elements.
53 */
54 public XMLEvent nextEvent() throws XMLStreamException;
55
56 /**
57 * Check if there are more events.
58 * Returns true if there are more events and false otherwise.
59 * @return true if the event reader has more events, false otherwise
60 */
61 @Override
62 public boolean hasNext();
63
64 /**
65 * Check the next XMLEvent without reading it from the stream.
66 * Returns null if the stream is at EOF or has no more XMLEvents.
67 * A call to peek() will be equal to the next return of next().
68 *
69 * @return the next XMLEvent
70 * @see XMLEvent
71 * @throws XMLStreamException if an error occurs
72 */
73 public XMLEvent peek() throws XMLStreamException;
74
75 /**
76 * Reads the content of a text-only element. Precondition:
77 * the current event is START_ELEMENT. Postcondition:
78 * The current event is the corresponding END_ELEMENT.
79 *
80 * @return the text of the element
81 * @throws XMLStreamException if the current event is not a START_ELEMENT
82 * or if a non text element is encountered
83 */
84 public String getElementText() throws XMLStreamException;
85
86 /**
87 * Skips any insignificant space events until a START_ELEMENT or
88 * END_ELEMENT is reached. If anything other than space characters are
89 * encountered, an exception is thrown. This method should
90 * be used when processing element-only content because
91 * the parser is not able to recognize ignorable whitespace if
|