1 /*
2 * Copyright (c) 2009, 2018, 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
239 * || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
240 * buf.append(getText());
241 * } else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
242 * || eventType == XMLStreamConstants.COMMENT) {
243 * // skipping
244 * } else if(eventType == XMLStreamConstants.END_DOCUMENT) {
245 * throw new XMLStreamException(
246 * "unexpected end of document when reading element text content", this);
247 * } else if(eventType == XMLStreamConstants.START_ELEMENT) {
248 * throw new XMLStreamException(
249 * "element text content may not contain START_ELEMENT", getLocation());
250 * } else {
251 * throw new XMLStreamException(
252 * "Unexpected event type "+eventType, getLocation());
253 * }
254 * eventType = next();
255 * }
256 * return buf.toString();
257 * </pre>
258 *
259 * @throws XMLStreamException if the current event is not a START_ELEMENT
260 * or if a non text element is encountered
261 */
262 public String getElementText() throws XMLStreamException;
263
264 /**
265 * Skips any white space (isWhiteSpace() returns true), COMMENT,
266 * or PROCESSING_INSTRUCTION,
267 * until a START_ELEMENT or END_ELEMENT is reached.
268 * If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT
269 * are encountered, an exception is thrown. This method should
270 * be used when processing element-only content seperated by white space.
271 *
272 * <br> Precondition: none
273 * <br> Postcondition: the current event is START_ELEMENT or END_ELEMENT
274 * and cursor may have moved over any whitespace event.
275 *
276 * <br>Essentially it does the following (implementations are free to optimized
277 * but must do equivalent processing):
278 * <pre> {@code
|
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
239 * || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
240 * buf.append(getText());
241 * } else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
242 * || eventType == XMLStreamConstants.COMMENT) {
243 * // skipping
244 * } else if(eventType == XMLStreamConstants.END_DOCUMENT) {
245 * throw new XMLStreamException(
246 * "unexpected end of document when reading element text content", this);
247 * } else if(eventType == XMLStreamConstants.START_ELEMENT) {
248 * throw new XMLStreamException(
249 * "element text content may not contain START_ELEMENT", getLocation());
250 * } else {
251 * throw new XMLStreamException(
252 * "Unexpected event type "+eventType, getLocation());
253 * }
254 * eventType = next();
255 * }
256 * return buf.toString();
257 * </pre>
258 *
259 * @return the content of a text-only element
260 * @throws XMLStreamException if the current event is not a START_ELEMENT
261 * or if a non text element is encountered
262 */
263 public String getElementText() throws XMLStreamException;
264
265 /**
266 * Skips any white space (isWhiteSpace() returns true), COMMENT,
267 * or PROCESSING_INSTRUCTION,
268 * until a START_ELEMENT or END_ELEMENT is reached.
269 * If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT
270 * are encountered, an exception is thrown. This method should
271 * be used when processing element-only content seperated by white space.
272 *
273 * <br> Precondition: none
274 * <br> Postcondition: the current event is START_ELEMENT or END_ELEMENT
275 * and cursor may have moved over any whitespace event.
276 *
277 * <br>Essentially it does the following (implementations are free to optimized
278 * but must do equivalent processing):
279 * <pre> {@code
|