< prev index next >

src/java.xml/share/classes/javax/xml/stream/XMLStreamReader.java

Print this page


   1 /*
   2  * Copyright (c) 2009, 2017, 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


 180    * CDATA Sections.
 181    *
 182    * By default entity references must be
 183    * expanded and reported transparently to the application.
 184    * An exception will be thrown if an entity reference cannot be expanded.
 185    * If element content is empty (i.e. content is "") then no CHARACTERS event will be reported.
 186    *
 187    * <p>Given the following XML:<br>
 188    * {@code <foo><!--description-->content text<![CDATA[<greeting>Hello>/greeting>]]>other content>/foo>}<br>
 189    * The behavior of calling next() when being on foo will be:<br>
 190    * 1- the comment (COMMENT)<br>
 191    * 2- then the characters section (CHARACTERS)<br>
 192    * 3- then the CDATA section (another CHARACTERS)<br>
 193    * 4- then the next characters section (another CHARACTERS)<br>
 194    * 5- then the END_ELEMENT<br>
 195    *
 196    * <p><b>NOTE:</b> empty element (such as {@code <tag/>}) will be reported
 197    *  with  two separate events: START_ELEMENT, END_ELEMENT - This preserves
 198    *   parsing equivalency of empty element to {@code <tag></tag>}.
 199    *
 200    * This method will throw an IllegalStateException if it is called after hasNext() returns false.
 201    * @see javax.xml.stream.events.XMLEvent
 202    * @return the integer code corresponding to the current parse event
 203    * @throws java.util.NoSuchElementException if this is called when hasNext() returns false
 204    * @throws XMLStreamException  if there is an error processing the underlying XML source
 205    */
 206   public int next() throws XMLStreamException;
 207 
 208   /**
 209    * Test if the current event is of the given type and if the namespace and name match the current
 210    * namespace and name of the current event.  If the namespaceURI is null it is not checked for equality,
 211    * if the localName is null it is not checked for equality.
 212    * @param type the event type
 213    * @param namespaceURI the uri of the event, may be null
 214    * @param localName the localName of the event, may be null
 215    * @throws XMLStreamException if the required values are not matched.
 216    */
 217   public void require(int type, String namespaceURI, String localName) throws XMLStreamException;
 218 
 219   /**
 220    * Reads the content of a text-only element, an exception is thrown if this is


   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


 180    * CDATA Sections.
 181    *
 182    * By default entity references must be
 183    * expanded and reported transparently to the application.
 184    * An exception will be thrown if an entity reference cannot be expanded.
 185    * If element content is empty (i.e. content is "") then no CHARACTERS event will be reported.
 186    *
 187    * <p>Given the following XML:<br>
 188    * {@code <foo><!--description-->content text<![CDATA[<greeting>Hello>/greeting>]]>other content>/foo>}<br>
 189    * The behavior of calling next() when being on foo will be:<br>
 190    * 1- the comment (COMMENT)<br>
 191    * 2- then the characters section (CHARACTERS)<br>
 192    * 3- then the CDATA section (another CHARACTERS)<br>
 193    * 4- then the next characters section (another CHARACTERS)<br>
 194    * 5- then the END_ELEMENT<br>
 195    *
 196    * <p><b>NOTE:</b> empty element (such as {@code <tag/>}) will be reported
 197    *  with  two separate events: START_ELEMENT, END_ELEMENT - This preserves
 198    *   parsing equivalency of empty element to {@code <tag></tag>}.
 199    *

 200    * @see javax.xml.stream.events.XMLEvent
 201    * @return the integer code corresponding to the current parse event
 202    * @throws java.util.NoSuchElementException if this is called when hasNext() returns false
 203    * @throws XMLStreamException  if there is an error processing the underlying XML source
 204    */
 205   public int next() throws XMLStreamException;
 206 
 207   /**
 208    * Test if the current event is of the given type and if the namespace and name match the current
 209    * namespace and name of the current event.  If the namespaceURI is null it is not checked for equality,
 210    * if the localName is null it is not checked for equality.
 211    * @param type the event type
 212    * @param namespaceURI the uri of the event, may be null
 213    * @param localName the localName of the event, may be null
 214    * @throws XMLStreamException if the required values are not matched.
 215    */
 216   public void require(int type, String namespaceURI, String localName) throws XMLStreamException;
 217 
 218   /**
 219    * Reads the content of a text-only element, an exception is thrown if this is


< prev index next >