Source Code Cross Referenced for XMLStreamReader.java in  » 6.0-JDK-Core » xml » javax » xml » stream » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » xml » javax.xml.stream 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        package javax.xml.stream;
002
003        import java.io.Reader;
004        import javax.xml.namespace.NamespaceContext;
005        import javax.xml.namespace.QName;
006
007        /**
008         *  The XMLStreamReader interface allows forward, read-only access to XML.
009         *  It is designed to be the lowest level and most efficient way to
010         *  read XML data.
011         *
012         * <p> The XMLStreamReader is designed to iterate over XML using
013         * next() and hasNext().  The data can be accessed using methods such as getEventType(),
014         * getNamespaceURI(), getLocalName() and getText();
015         *
016         * <p> The <a href="#next()">next()</a> method causes the reader to read the next parse event.
017         * The next() method returns an integer which identifies the type of event just read.
018         * <p> The event type can be determined using <a href="#getEventType()">getEventType()</a>.
019         * <p> Parsing events are defined as the XML Declaration, a DTD,
020         * start tag, character data, white space, end tag, comment,
021         * or processing instruction.  An attribute or namespace event may be encountered
022         * at the root level of a document as the result of a query operation.
023         *
024         * <p>For XML 1.0 compliance an XML processor must pass the
025         * identifiers of declared unparsed entities, notation declarations and their
026         * associated identifiers to the application.  This information is
027         * provided through the property API on this interface.
028         * The following two properties allow access to this information:
029         * javax.xml.stream.notations and javax.xml.stream.entities.
030         * When the current event is a DTD the following call will return a
031         * list of Notations
032         *  <code>List l = (List) getProperty("javax.xml.stream.notations");</code>
033         * The following call will return a list of entity declarations:
034         * <code>List l = (List) getProperty("javax.xml.stream.entities");</code>
035         * These properties can only be accessed during a DTD event and
036         * are defined to return null if the information is not available.
037         *
038         * <p>The following table describes which methods are valid in what state.
039         * If a method is called in an invalid state the method will throw a
040         * java.lang.IllegalStateException.
041         *
042         * <table border="2" rules="all" cellpadding="4">
043         *   <thead>
044         *     <tr>
045         *       <th align="center" colspan="2">
046         *         Valid methods for each state
047         *       </th>
048         *     </tr>
049         *   </thead>
050         *   <tbody>
051         *     <tr>
052         *       <th>Event Type</th>
053         *       <th>Valid Methods</th>
054         *     </tr>
055         *     <tr>
056         *       <td> All States  </td>
057         *       <td> getProperty(), hasNext(), require(), close(),
058         *            getNamespaceURI(), isStartElement(),
059         *            isEndElement(), isCharacters(), isWhiteSpace(),
060         *            getNamespaceContext(), getEventType(),getLocation(),
061         *            hasText(), hasName()
062         *       </td>
063         *     </tr>
064         *     <tr>
065         *       <td> START_ELEMENT  </td>
066         *       <td> next(), getName(), getLocalName(), hasName(), getPrefix(),
067         *            getAttributeXXX(), isAttributeSpecified(),
068         *            getNamespaceXXX(),
069         *            getElementText(), nextTag()
070         *       </td>
071         *     </tr>
072         *       <td> ATTRIBUTE  </td>
073         *       <td> next(), nextTag()
074         *            getAttributeXXX(), isAttributeSpecified(),
075         *       </td>
076         *     </tr>
077         *     </tr>
078         *       <td> NAMESPACE  </td>
079         *       <td> next(), nextTag()
080         *            getNamespaceXXX()
081         *       </td>
082         *     </tr>
083         *     <tr>
084         *       <td> END_ELEMENT  </td>
085         *       <td> next(), getName(), getLocalName(), hasName(), getPrefix(),
086         *            getNamespaceXXX(), nextTag()
087         *      </td>
088         *     </tr>
089         *     <tr>
090         *       <td> CHARACTERS  </td>
091         *       <td> next(), getTextXXX(), nextTag() </td>
092         *     </tr>
093         *     <tr>
094         *       <td> CDATA  </td>
095         *       <td> next(), getTextXXX(), nextTag() </td>
096         *     </tr>
097         *     <tr>
098         *       <td> COMMENT  </td>
099         *       <td> next(), getTextXXX(), nextTag() </td>
100         *     </tr>
101         *     <tr>
102         *       <td> SPACE  </td>
103         *       <td> next(), getTextXXX(), nextTag() </td>
104         *     </tr>
105         *     <tr>
106         *       <td> START_DOCUMENT  </td>
107         *       <td> next(), getEncoding(), getVersion(), isStandalone(), standaloneSet(),
108         *            getCharacterEncodingScheme(), nextTag()</td>
109         *     </tr>
110         *     <tr>
111         *       <td> END_DOCUMENT  </td>
112         *       <td> close()</td>
113         *     </tr>
114         *     <tr>
115         *       <td> PROCESSING_INSTRUCTION  </td>
116         *       <td> next(), getPITarget(), getPIData(), nextTag() </td>
117         *     </tr>
118         *     <tr>
119         *       <td> ENTITY_REFERENCE  </td>
120         *       <td> next(), getLocalName(), getText(), nextTag() </td>
121         *     </tr>
122         *     <tr>
123         *       <td> DTD  </td>
124         *       <td> next(), getText(), nextTag() </td>
125         *     </tr>
126         *   </tbody>
127         *  </table>
128         *
129         * @version 1.0
130         * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
131         * @see javax.xml.stream.events.XMLEvent
132         * @see XMLInputFactory
133         * @see XMLStreamWriter
134         * @since 1.6
135         */
136        public interface XMLStreamReader extends XMLStreamConstants {
137            /**
138             * Get the value of a feature/property from the underlying implementation
139             * @param name The name of the property, may not be null
140             * @return The value of the property
141             * @throws IllegalArgumentException if name is null
142             */
143            public Object getProperty(java.lang.String name)
144                    throws java.lang.IllegalArgumentException;
145
146            /**
147             * Get next parsing event - a processor may return all contiguous
148             * character data in a single chunk, or it may split it into several chunks.
149             * If the property javax.xml.stream.isCoalescing is set to true
150             * element content must be coalesced and only one CHARACTERS event
151             * must be returned for contiguous element content or
152             * CDATA Sections.  
153             *
154             * By default entity references must be 
155             * expanded and reported transparently to the application.
156             * An exception will be thrown if an entity reference cannot be expanded.
157             * If element content is empty (i.e. content is "") then no CHARACTERS event will be reported.
158             *
159             * <p>Given the following XML:<br>
160             * &lt;foo>&lt;!--description-->content text&lt;![CDATA[&lt;greeting>Hello&lt;/greeting>]]>other content&lt;/foo><br>
161             * The behavior of calling next() when being on foo will be:<br>
162             * 1- the comment (COMMENT)<br>
163             * 2- then the characters section (CHARACTERS)<br>
164             * 3- then the CDATA section (another CHARACTERS)<br>
165             * 4- then the next characters section (another CHARACTERS)<br>
166             * 5- then the END_ELEMENT<br>
167             *
168             * <p><b>NOTE:</b> empty element (such as &lt;tag/>) will be reported
169             *  with  two separate events: START_ELEMENT, END_ELEMENT - This preserves
170             *   parsing equivalency of empty element to &lt;tag>&lt;/tag>.
171             *
172             * This method will throw an IllegalStateException if it is called after hasNext() returns false.
173             * @see javax.xml.stream.events.XMLEvent
174             * @return the integer code corresponding to the current parse event
175             * @throws NoSuchElementException if this is called when hasNext() returns false
176             * @throws XMLStreamException  if there is an error processing the underlying XML source
177             */
178            public int next() throws XMLStreamException;
179
180            /**
181             * Test if the current event is of the given type and if the namespace and name match the current
182             * namespace and name of the current event.  If the namespaceURI is null it is not checked for equality,
183             * if the localName is null it is not checked for equality.
184             * @param type the event type
185             * @param namespaceURI the uri of the event, may be null
186             * @param localName the localName of the event, may be null
187             * @throws XMLStreamException if the required values are not matched.
188             */
189            public void require(int type, String namespaceURI, String localName)
190                    throws XMLStreamException;
191
192            /**
193             * Reads the content of a text-only element, an exception is thrown if this is
194             * not a text-only element.
195             * Regardless of value of javax.xml.stream.isCoalescing this method always returns coalesced content.
196             * <br /> Precondition: the current event is START_ELEMENT.
197             * <br /> Postcondition: the current event is the corresponding END_ELEMENT.
198             *
199             * <br />The method does the following (implementations are free to optimized 
200             * but must do equivalent processing):
201             * <pre>
202             * if(getEventType() != XMLStreamConstants.START_ELEMENT) {
203             * throw new XMLStreamException(
204             * "parser must be on START_ELEMENT to read next text", getLocation());
205             * }
206             * int eventType = next();
207             * StringBuffer content = new StringBuffer();
208             * while(eventType != XMLStreamConstants.END_ELEMENT ) {
209             * if(eventType == XMLStreamConstants.CHARACTERS
210             * || eventType == XMLStreamConstants.CDATA
211             * || eventType == XMLStreamConstants.SPACE
212             * || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
213             * buf.append(getText());
214             * } else if(eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
215             * || eventType == XMLStreamConstants.COMMENT) {
216             * // skipping
217             * } else if(eventType == XMLStreamConstants.END_DOCUMENT) {
218             * throw new XMLStreamException(
219             * "unexpected end of document when reading element text content", this);
220             * } else if(eventType == XMLStreamConstants.START_ELEMENT) {
221             * throw new XMLStreamException(
222             * "element text content may not contain START_ELEMENT", getLocation());
223             * } else {
224             * throw new XMLStreamException(
225             * "Unexpected event type "+eventType, getLocation());
226             * }
227             * eventType = next();
228             * }
229             * return buf.toString();
230             * </pre>
231             *
232             * @throws XMLStreamException if the current event is not a START_ELEMENT 
233             * or if a non text element is encountered
234             */
235            public String getElementText() throws XMLStreamException;
236
237            /**
238             * Skips any white space (isWhiteSpace() returns true), COMMENT,
239             * or PROCESSING_INSTRUCTION,
240             * until a START_ELEMENT or END_ELEMENT is reached.
241             * If other than white space characters, COMMENT, PROCESSING_INSTRUCTION, START_ELEMENT, END_ELEMENT
242             * are encountered, an exception is thrown. This method should
243             * be used when processing element-only content seperated by white space. 
244             *
245             * <br /> Precondition: none
246             * <br /> Postcondition: the current event is START_ELEMENT or END_ELEMENT
247             * and cursor may have moved over any whitespace event.
248             *
249             * <br />Essentially it does the following (implementations are free to optimized 
250             * but must do equivalent processing):
251             * <pre>
252             * int eventType = next();
253             * while((eventType == XMLStreamConstants.CHARACTERS &amp;&amp; isWhiteSpace()) // skip whitespace
254             * || (eventType == XMLStreamConstants.CDATA &amp;&amp; isWhiteSpace()) 
255             * // skip whitespace
256             * || eventType == XMLStreamConstants.SPACE
257             * || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
258             * || eventType == XMLStreamConstants.COMMENT
259             * ) {
260             * eventType = next();
261             * }
262             * if (eventType != XMLStreamConstants.START_ELEMENT &amp;&amp; eventType != XMLStreamConstants.END_ELEMENT) {
263             * throw new String XMLStreamException("expected start or end tag", getLocation());
264             * }
265             * return eventType;
266             * </pre>
267             *
268             * @return the event type of the element read (START_ELEMENT or END_ELEMENT)
269             * @throws XMLStreamException if the current event is not white space, PROCESSING_INSTRUCTION,
270             * START_ELEMENT or END_ELEMENT
271             * @throws NoSuchElementException if this is called when hasNext() returns false
272             */
273            public int nextTag() throws XMLStreamException;
274
275            /**
276             * Returns true if there are more parsing events and false
277             * if there are no more events.  This method will return
278             * false if the current state of the XMLStreamReader is
279             * END_DOCUMENT
280             * @return true if there are more events, false otherwise
281             * @throws XMLStreamException if there is a fatal error detecting the next state
282             */
283            public boolean hasNext() throws XMLStreamException;
284
285            /**
286             * Frees any resources associated with this Reader.  This method does not close the
287             * underlying input source.
288             * @throws XMLStreamException if there are errors freeing associated resources
289             */
290            public void close() throws XMLStreamException;
291
292            /**
293             * Return the uri for the given prefix.
294             * The uri returned depends on the current state of the processor.
295             *
296             * <p><strong>NOTE:</strong>The 'xml' prefix is bound as defined in
297             * <a href="http://www.w3.org/TR/REC-xml-names/#ns-using">Namespaces in XML</a>
298             * specification to "http://www.w3.org/XML/1998/namespace".
299             *
300             * <p><strong>NOTE:</strong> The 'xmlns' prefix must be resolved to following namespace
301             * <a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>
302             * @param prefix The prefix to lookup, may not be null
303             * @return the uri bound to the given prefix or null if it is not bound
304             * @throws IllegalArgumentException if the prefix is null
305             */
306            public String getNamespaceURI(String prefix);
307
308            /**
309             * Returns true if the cursor points to a start tag (otherwise false)
310             * @return true if the cursor points to a start tag, false otherwise
311             */
312            public boolean isStartElement();
313
314            /**
315             * Returns true if the cursor points to an end tag (otherwise false)
316             * @return true if the cursor points to an end tag, false otherwise
317             */
318            public boolean isEndElement();
319
320            /**
321             * Returns true if the cursor points to a character data event
322             * @return true if the cursor points to character data, false otherwise
323             */
324            public boolean isCharacters();
325
326            /**
327             * Returns true if the cursor points to a character data event
328             * that consists of all whitespace
329             * @return true if the cursor points to all whitespace, false otherwise
330             */
331            public boolean isWhiteSpace();
332
333            /**
334             * Returns the normalized attribute value of the
335             * attribute with the namespace and localName
336             * If the namespaceURI is null the namespace
337             * is not checked for equality
338             * @param namespaceURI the namespace of the attribute
339             * @param localName the local name of the attribute, cannot be null
340             * @return returns the value of the attribute , returns null if not found
341             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
342             */
343            public String getAttributeValue(String namespaceURI,
344                    String localName);
345
346            /**
347             * Returns the count of attributes on this START_ELEMENT,
348             * this method is only valid on a START_ELEMENT or ATTRIBUTE.  This
349             * count excludes namespace definitions.  Attribute indices are
350             * zero-based.
351             * @return returns the number of attributes
352             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
353             */
354            public int getAttributeCount();
355
356            /** Returns the qname of the attribute at the provided index
357             *
358             * @param index the position of the attribute
359             * @return the QName of the attribute
360             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
361             */
362            public QName getAttributeName(int index);
363
364            /**
365             * Returns the namespace of the attribute at the provided
366             * index
367             * @param index the position of the attribute
368             * @return the namespace URI (can be null)
369             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
370             */
371            public String getAttributeNamespace(int index);
372
373            /**
374             * Returns the localName of the attribute at the provided
375             * index
376             * @param index the position of the attribute
377             * @return the localName of the attribute
378             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
379             */
380            public String getAttributeLocalName(int index);
381
382            /**
383             * Returns the prefix of this attribute at the
384             * provided index
385             * @param index the position of the attribute
386             * @return the prefix of the attribute
387             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
388             */
389            public String getAttributePrefix(int index);
390
391            /**
392             * Returns the XML type of the attribute at the provided
393             * index
394             * @param index the position of the attribute
395             * @return the XML type of the attribute
396             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
397             */
398            public String getAttributeType(int index);
399
400            /**
401             * Returns the value of the attribute at the
402             * index
403             * @param index the position of the attribute
404             * @return the attribute value
405             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
406             */
407            public String getAttributeValue(int index);
408
409            /**
410             * Returns a boolean which indicates if this
411             * attribute was created by default
412             * @param index the position of the attribute
413             * @return true if this is a default attribute
414             * @throws IllegalStateException if this is not a START_ELEMENT or ATTRIBUTE
415             */
416            public boolean isAttributeSpecified(int index);
417
418            /**
419             * Returns the count of namespaces declared on this START_ELEMENT or END_ELEMENT,
420             * this method is only valid on a START_ELEMENT, END_ELEMENT or NAMESPACE. On
421             * an END_ELEMENT the count is of the namespaces that are about to go
422             * out of scope.  This is the equivalent of the information reported
423             * by SAX callback for an end element event.
424             * @return returns the number of namespace declarations on this specific element
425             * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
426             */
427            public int getNamespaceCount();
428
429            /**
430             * Returns the prefix for the namespace declared at the
431             * index.  Returns null if this is the default namespace
432             * declaration
433             *
434             * @param index the position of the namespace declaration
435             * @return returns the namespace prefix
436             * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
437             */
438            public String getNamespacePrefix(int index);
439
440            /**
441             * Returns the uri for the namespace declared at the
442             * index.
443             *
444             * @param index the position of the namespace declaration
445             * @return returns the namespace uri
446             * @throws IllegalStateException if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
447             */
448            public String getNamespaceURI(int index);
449
450            /**
451             * Returns a read only namespace context for the current
452             * position.  The context is transient and only valid until
453             * a call to next() changes the state of the reader.
454             * @return return a namespace context
455             */
456            public NamespaceContext getNamespaceContext();
457
458            /**
459             * Returns a reader that points to the current start element
460             * and all of its contents.  Throws an XMLStreamException if the
461             * cursor does not point to a START_ELEMENT.<p>
462             * The sub stream is read from it MUST be read before the parent stream is
463             * moved on, if not any call on the sub stream will cause an XMLStreamException to be
464             * thrown.   The parent stream will always return the same result from next()
465             * whatever is done to the sub stream.
466             * @return an XMLStreamReader which points to the next element
467             */
468            //  public XMLStreamReader subReader() throws XMLStreamException;
469            /**
470             * Allows the implementation to reset and reuse any underlying tables
471             */
472            //  public void recycle() throws XMLStreamException;
473            /**
474             * Returns an integer code that indicates the type
475             * of the event the cursor is pointing to.
476             */
477            public int getEventType();
478
479            /**
480             * Returns the current value of the parse event as a string,
481             * this returns the string value of a CHARACTERS event,
482             * returns the value of a COMMENT, the replacement value
483             * for an ENTITY_REFERENCE, the string value of a CDATA section,
484             * the string value for a SPACE event,
485             * or the String value of the internal subset of the DTD.
486             * If an ENTITY_REFERENCE has been resolved, any character data
487             * will be reported as CHARACTERS events.
488             * @return the current text or null
489             * @throws java.lang.IllegalStateException if this state is not
490             * a valid text state.
491             */
492            public String getText();
493
494            /**
495             * Returns an array which contains the characters from this event.
496             * This array should be treated as read-only and transient. I.e. the array will
497             * contain the text characters until the XMLStreamReader moves on to the next event.
498             * Attempts to hold onto the character array beyond that time or modify the
499             * contents of the array are breaches of the contract for this interface.
500             * @return the current text or an empty array
501             * @throws java.lang.IllegalStateException if this state is not
502             * a valid text state.
503             */
504            public char[] getTextCharacters();
505
506            /**
507             * Gets the the text associated with a CHARACTERS, SPACE or CDATA event.  
508             * Text starting a "sourceStart" is copied into "target" starting at "targetStart".  
509             * Up to "length" characters are copied.  The number of characters actually copied is returned.
510             *
511             * The "sourceStart" argument must be greater or equal to 0 and less than or equal to 
512             * the number of characters associated with the event.  Usually, one requests text starting at a "sourceStart" of 0.  
513             * If the number of characters actually copied is less than the "length", then there is no more text.  
514             * Otherwise, subsequent calls need to be made until all text has been retrieved. For example:
515             * 
516             *<code>
517             * int length = 1024;
518             * char[] myBuffer = new char[ length ];
519             * 
520             * for ( int sourceStart = 0 ; ; sourceStart += length )
521             * {
522             *    int nCopied = stream.getTextCharacters( sourceStart, myBuffer, 0, length );
523             *
524             *   if (nCopied < length)
525             *       break;
526             * }
527             * </code>
528             * XMLStreamException may be thrown if there are any XML errors in the underlying source. 
529             * The "targetStart" argument must be greater than or equal to 0 and less than the length of "target",  
530             * Length must be greater than 0 and "targetStart + length" must be less than or equal to length of "target".  
531             *
532             * @param sourceStart the index of the first character in the source array to copy
533             * @param target the destination array
534             * @param targetStart the start offset in the target array
535             * @param length the number of characters to copy
536             * @return the number of characters actually copied
537             * @throws XMLStreamException if the underlying XML source is not well-formed
538             * @throws IndexOutOfBoundsException if targetStart < 0 or > than the length of target
539             * @throws IndexOutOfBoundsException if length < 0 or targetStart + length > length of target
540             * @throws UnsupportedOperationException if this method is not supported 
541             * @throws NullPointerException is if target is null
542             */
543            public int getTextCharacters(int sourceStart, char[] target,
544                    int targetStart, int length) throws XMLStreamException;
545
546            /**
547             * Gets the text associated with a CHARACTERS, SPACE or CDATA event.  Allows the underlying
548             * implementation to return the text as a stream of characters.  The reference to the 
549             * Reader returned by this method is only valid until next() is called.
550             *
551             * All characters must have been checked for well-formedness.
552             *
553             * <p> This method is optional and will throw UnsupportedOperationException if it is not supported.  
554             * @throws UnsupportedOperationException if this method is not supported
555             * @throws IllegalStateException if this is not a valid text state
556             */
557            //public Reader getTextStream();
558            /**
559             * Returns the offset into the text character array where the first
560             * character (of this text event) is stored.
561             * @throws java.lang.IllegalStateException if this state is not
562             * a valid text state.
563             */
564            public int getTextStart();
565
566            /**
567             * Returns the length of the sequence of characters for this
568             * Text event within the text character array.
569             * @throws java.lang.IllegalStateException if this state is not
570             * a valid text state.
571             */
572            public int getTextLength();
573
574            /**
575             * Return input encoding if known or null if unknown.
576             * @return the encoding of this instance or null
577             */
578            public String getEncoding();
579
580            /**
581             * Return true if the current event has text, false otherwise
582             * The following events have text:
583             * CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT, SPACE
584             */
585            public boolean hasText();
586
587            /**
588             * Return the current location of the processor.
589             * If the Location is unknown the processor should return
590             * an implementation of Location that returns -1 for the
591             * location and null for the publicId and systemId.
592             * The location information is only valid until next() is
593             * called.
594             */
595            public Location getLocation();
596
597            /**
598             * Returns a QName for the current START_ELEMENT or END_ELEMENT event
599             * @return the QName for the current START_ELEMENT or END_ELEMENT event
600             * @throws IllegalStateException if this is not a START_ELEMENT or
601             * END_ELEMENT
602             */
603            public QName getName();
604
605            /**
606             * Returns the (local) name of the current event.
607             * For START_ELEMENT or END_ELEMENT returns the (local) name of the current element.
608             * For ENTITY_REFERENCE it returns entity name.
609             * The current event must be START_ELEMENT or END_ELEMENT, 
610             * or ENTITY_REFERENCE
611             * @return the localName
612             * @throws IllegalStateException if this not a START_ELEMENT,
613             * END_ELEMENT or ENTITY_REFERENCE
614             */
615            public String getLocalName();
616
617            /**
618             * returns true if the current event has a name (is a START_ELEMENT or END_ELEMENT)
619             * returns false otherwise
620             */
621            public boolean hasName();
622
623            /**
624             * If the current event is a START_ELEMENT or END_ELEMENT  this method
625             * returns the URI of the prefix or the default namespace.
626             * Returns null if the event does not have a prefix.
627             * @return the URI bound to this elements prefix, the default namespace, or null
628             */
629            public String getNamespaceURI();
630
631            /**
632             * Returns the prefix of the current event or null if the event does not have a prefix
633             * @return the prefix or null
634             */
635            public String getPrefix();
636
637            /**
638             * Get the xml version declared on the xml declaration
639             * Returns null if none was declared
640             * @return the XML version or null
641             */
642            public String getVersion();
643
644            /**
645             * Get the standalone declaration from the xml declaration
646             * @return true if this is standalone, or false otherwise
647             */
648            public boolean isStandalone();
649
650            /**
651             * Checks if standalone was set in the document
652             * @return true if standalone was set in the document, or false otherwise
653             */
654            public boolean standaloneSet();
655
656            /**
657             * Returns the character encoding declared on the xml declaration
658             * Returns null if none was declared
659             * @return the encoding declared in the document or null
660             */
661            public String getCharacterEncodingScheme();
662
663            /**
664             * Get the target of a processing instruction
665             * @return the target or null
666             */
667            public String getPITarget();
668
669            /**
670             * Get the data section of a processing instruction
671             * @return the data or null
672             */
673            public String getPIData();
674        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.