xmlstreamreader.html
来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 1,517 行 · 第 1/5 页
HTML
1,517 行
<TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#isStartElement()">isStartElement</A></B>()</CODE><BR> Returns true if the cursor points to a start tag (otherwise false)</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#isWhiteSpace()">isWhiteSpace</A></B>()</CODE><BR> Returns true if the cursor points to a character data event that consists of all whitespace</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#next()">next</A></B>()</CODE><BR> Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#nextTag()">nextTag</A></B>()</CODE><BR> Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#require(int, java.lang.String, java.lang.String)">require</A></B>(int type, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> namespaceURI, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> localName)</CODE><BR> Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/xml/stream/XMLStreamReader.html#standaloneSet()">standaloneSet</A></B>()</CODE><BR> Checks if standalone was set in the document</TD></TR></TABLE> <P><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="getProperty(java.lang.String)"><!-- --></A><H3>getProperty</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A> <B>getProperty</B>(<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> name) throws <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></PRE><DL><DD>Get the value of a feature/property from the underlying implementation<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the property, may not be null<DT><B>Returns:</B><DD>The value of the property<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if name is null</DL></DD></DL><HR><A NAME="next()"><!-- --></A><H3>next</H3><PRE>int <B>next</B>() throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks. If the property javax.xml.stream.isCoalescing is set to true element content must be coalesced and only one CHARACTERS event must be returned for contiguous element content or CDATA Sections. By default entity references must be expanded and reported transparently to the application. An exception will be thrown if an entity reference cannot be expanded. If element content is empty (i.e. content is "") then no CHARACTERS event will be reported. <p>Given the following XML:<br> <foo><!--description-->content text<![CDATA[<greeting>Hello</greeting>]]>other content</foo><br> The behavior of calling next() when being on foo will be:<br> 1- the comment (COMMENT)<br> 2- then the characters section (CHARACTERS)<br> 3- then the CDATA section (another CHARACTERS)<br> 4- then the next characters section (another CHARACTERS)<br> 5- then the END_ELEMENT<br> <p><b>NOTE:</b> empty element (such as <tag/>) will be reported with two separate events: START_ELEMENT, END_ELEMENT - This preserves parsing equivalency of empty element to <tag></tag>. This method will throw an IllegalStateException if it is called after hasNext() returns false.<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the integer code corresponding to the current parse event<DT><B>Throws:</B><DD><CODE>NoSuchElementException</CODE> - if this is called when hasNext() returns false<DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if there is an error processing the underlying XML source<DT><B>See Also:</B><DD><A HREF="../../../javax/xml/stream/events/XMLEvent.html" title="interface in javax.xml.stream.events"><CODE>XMLEvent</CODE></A></DL></DD></DL><HR><A NAME="require(int, java.lang.String, java.lang.String)"><!-- --></A><H3>require</H3><PRE>void <B>require</B>(int type, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> namespaceURI, <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> localName) throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Test if the current event is of the given type and if the namespace and name match the current namespace and name of the current event. If the namespaceURI is null it is not checked for equality, if the localName is null it is not checked for equality.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>type</CODE> - the event type<DD><CODE>namespaceURI</CODE> - the uri of the event, may be null<DD><CODE>localName</CODE> - the localName of the event, may be null<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if the required values are not matched.</DL></DD></DL><HR><A NAME="getElementText()"><!-- --></A><H3>getElementText</H3><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getElementText</B>() throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Reads the content of a text-only element, an exception is thrown if this is not a text-only element. Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content. <br /> Precondition: the current event is START_ELEMENT. <br /> Postcondition: the current event is the corresponding END_ELEMENT. <br />The method does the following (implementations are free to optimized but must do equivalent processing): <pre> if(getEventType() != XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException( "parser must be on START_ELEMENT to read next text", getLocation()); } int eventType = next(); StringBuffer content = new StringBuffer(); while(eventType != XMLStreamConstants.END_ELEMENT ) { if(eventType == XMLStreamConstants.CHARACTERS || eventType == XMLStreamConstants.CDATA || eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.ENTITY_REFERENCE) { buf.append(getText()); } else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION || eventType == XMLStreamConstants.COMMENT) { // skipping } else if(eventType == XMLStreamConstants.END_DOCUMENT) { throw new XMLStreamException( "unexpected end of document when reading element text content", this); } else if(eventType == XMLStreamConstants.START_ELEMENT) { throw new XMLStreamException( "element text content may not contain START_ELEMENT", getLocation()); } else { throw new XMLStreamException( "Unexpected event type "+eventType, getLocation()); } eventType = next(); } return buf.toString(); </pre><P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if the current event is not a START_ELEMENT or if a non text element is encountered</DL></DD></DL><HR><A NAME="nextTag()"><!-- --></A><H3>nextTag</H3><PRE>int <B>nextTag</B>() throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Skips any white space (isWhiteSpace() returns true), COMMENT, or PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached. If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT are encountered, an exception is thrown. This method should be used when processing element-only content seperated by white space. <br /> Precondition: none <br /> Postcondition: the current event is START_ELEMENT or END_ELEMENT and cursor may have moved over any whitespace event. <br />Essentially it does the following (implementations are free to optimized but must do equivalent processing): <pre> int eventType = next(); while((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip whitespace || (eventType == XMLStreamConstants.CDATA && isWhiteSpace()) // skip whitespace || eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION || eventType == XMLStreamConstants.COMMENT ) { eventType = next(); } if (eventType != XMLStreamConstants.START_ELEMENT && eventType != XMLStreamConstants.END_ELEMENT) { throw new String XMLStreamException("expected start or end tag", getLocation()); } return eventType; </pre><P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the event type of the element read (START_ELEMENT or END_ELEMENT)<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if the current event is not white space, PROCESSING_INSTRUCTION, START_ELEMENT or END_ELEMENT<DD><CODE>NoSuchElementException</CODE> - if this is called when hasNext() returns false</DL></DD></DL><HR><A NAME="hasNext()"><!-- --></A><H3>hasNext</H3><PRE>boolean <B>hasNext</B>() throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Returns true if there are more parsing events and false if there are no more events. This method will return false if the current state of the XMLStreamReader is END_DOCUMENT<P><DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if there are more events, false otherwise<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if there is a fatal error detecting the next state</DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>void <B>close</B>() throws <A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD>Frees any resources associated with this Reader. This method does not close the underlying input source.<P><DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></CODE> - if there are errors freeing associated resources</DL>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?