⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streamreaderdelegate.html

📁 j2ee帮助文档软件设计/软件工程 文件格式
💻 HTML
📖 第 1 页 / 共 5 页
字号:
 <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 &amp;&amp; isWhiteSpace()) // skip whitespace || (eventType == XMLStreamConstants.CDATA &amp;&amp; isWhiteSpace())  // skip whitespace || eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION || eventType == XMLStreamConstants.COMMENT ) { eventType = next(); } if (eventType != XMLStreamConstants.START_ELEMENT &amp;&amp; eventType != XMLStreamConstants.END_ELEMENT) { throw new String XMLStreamException("expected start or end tag", getLocation()); } return eventType; </pre><P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#nextTag()">nextTag</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></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</DL></DD></DL><HR><A NAME="getElementText()"><!-- --></A><H3>getElementText</H3><PRE>public <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><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getElementText()">XMLStreamReader</A></CODE></B></DD><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><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getElementText()">getElementText</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></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="require(int, java.lang.String, java.lang.String)"><!-- --></A><H3>require</H3><PRE>public void <B>require</B>(int&nbsp;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>&nbsp;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>&nbsp;localName)             throws <A HREF="../../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#require(int, java.lang.String, java.lang.String)">XMLStreamReader</A></CODE></B></DD><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><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#require(int, java.lang.String, java.lang.String)">require</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></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="hasNext()"><!-- --></A><H3>hasNext</H3><PRE>public boolean <B>hasNext</B>()                throws <A HREF="../../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#hasNext()">XMLStreamReader</A></CODE></B></DD><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><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#hasNext()">hasNext</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></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>public void <B>close</B>()           throws <A HREF="../../../../javax/xml/stream/XMLStreamException.html" title="class in javax.xml.stream">XMLStreamException</A></PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#close()">XMLStreamReader</A></CODE></B></DD><DD>Frees any resources associated with this Reader.  This method does not close the underlying input source.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#close()">close</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></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></DD></DL><HR><A NAME="getNamespaceURI(java.lang.String)"><!-- --></A><H3>getNamespaceURI</H3><PRE>public <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>getNamespaceURI</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>&nbsp;prefix)</PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getNamespaceURI(java.lang.String)">XMLStreamReader</A></CODE></B></DD><DD>Return the uri for the given prefix. The uri returned depends on the current state of the processor. <p><strong>NOTE:</strong>The 'xml' prefix is bound as defined in <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a> specification to "http://www.w3.org/XML/1998/namespace". <p><strong>NOTE:</strong> The 'xmlns' prefix must be resolved to following namespace <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a><P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getNamespaceURI(java.lang.String)">getNamespaceURI</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>prefix</CODE> - The prefix to lookup, may not be null<DT><B>Returns:</B><DD>the uri bound to the given prefix or null if it is not bound</DL></DD></DL><HR><A NAME="getNamespaceContext()"><!-- --></A><H3>getNamespaceContext</H3><PRE>public <A HREF="http://java.sun.com/j2se/1.5/docs/api/javax/xml/namespace/NamespaceContext.html" title="class or interface in javax.xml.namespace">NamespaceContext</A> <B>getNamespaceContext</B>()</PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getNamespaceContext()">XMLStreamReader</A></CODE></B></DD><DD>Returns a read only namespace context for the current position.  The context is transient and only valid until a call to next() changes the state of the reader.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#getNamespaceContext()">getNamespaceContext</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>return a namespace context</DL></DD></DL><HR><A NAME="isStartElement()"><!-- --></A><H3>isStartElement</H3><PRE>public boolean <B>isStartElement</B>()</PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#isStartElement()">XMLStreamReader</A></CODE></B></DD><DD>Returns true if the cursor points to a start tag (otherwise false)<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#isStartElement()">isStartElement</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if the cursor points to a start tag, false otherwise</DL></DD></DL><HR><A NAME="isEndElement()"><!-- --></A><H3>isEndElement</H3><PRE>public boolean <B>isEndElement</B>()</PRE><DL><DD><B>Description copied from interface: <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#isEndElement()">XMLStreamReader</A></CODE></B></DD><DD>Returns true if the cursor points to an end tag (otherwise false)<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html#isEndElement()">isEndElement</A></CODE> in interface <CODE><A HREF="../../../../javax/xml/stream/XMLStreamReader.html" title="interface in javax.xml.stream">XMLStreamReader</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>true if the cursor points to an end tag, false otherwise</DL></DD></DL><HR><A NAME="isCharacters()"><!-- --></A><H3>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -