Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.znerd.xmlenc
Interface XMLEventListener  view XMLEventListener download XMLEventListener.java

All Superinterfaces:
XMLEventListenerStates
All Known Subinterfaces:
StatefulXMLEventListener
All Known Implementing Classes:
XMLOutputter

public interface XMLEventListener
extends XMLEventListenerStates

Interface for XML event listeners.

State transitions

XML event sources must obey a state model when calling XMLEventListeners. However, an XMLEventListener is not required to check that this state model is actually respected. If it does, then it will throw an java.lang.IllegalStateException if the state model is violated.

Stateful XMLEventListener implementations should implement the StatefulXMLEventListener interface instead of implementing XMLEventListener directly.

Initially the state of an uninitialized XMLEventListener is UNINITIALIZED 55 .

The following table defines how the state changes when a certain method is called in a certain state. Horizontally are the current states, vertically the notification methods. The cells self contain the new state.

S0 S1 S2 S3 S4 S5 S6
declaration() 55 S1 ISE ISE ISE ISE ISE ISE
dtd(String,String,String) 55 S2 S2 ISE ISE ISE ISE ISE
startTag(String) 55 S3 S3 S3 S3 S3 ISE ISE
attribute(String,String) 55 ISE ISE ISE S3 ISE ISE ISE
endTag() 55 ISE ISE ISE S4/S5 S4/S5 ISE ISE
pcdata(String) 55 ISE ISE ISE S4 S4 ISE ISE
pcdata(char[],int,int) 55 ISE ISE ISE S4 S4 ISE ISE
cdata(String) 55 ISE ISE ISE S4 S4 ISE ISE
whitespace(String) 55 S1 S1 S4 S4 S4 S5 ISE
whitespace(char[],int,int) 55 S1 S1 S4 S4 S4 S5 ISE
comment(String) 55 S1 S1 S4 S4 S4 S5 ISE
pi(String,String) 55 S1 S1 S4 S4 S4 S5 ISE
endDocument() 55 ISE ISE ISE S6 S6 S6 ISE

List of states as used in the table:

Since:
xmlenc 0.30
Version:
$Revision: 1.9 $ $Date: 2005/09/12 08:40:02 $

Field Summary
 
Fields inherited from interface org.znerd.xmlenc.XMLEventListenerStates
AFTER_ROOT_ELEMENT, BEFORE_DTD_DECLARATION, BEFORE_ROOT_ELEMENT, BEFORE_XML_DECLARATION, DOCUMENT_ENDED, ERROR_STATE, START_TAG_OPEN, UNINITIALIZED, WITHIN_ELEMENT
 
Method Summary
 void attribute(java.lang.String name, java.lang.String value)
          Adds an attribute to the current element.
 void cdata(java.lang.String text)
          Notification of a CDATA section.
 void comment(java.lang.String text)
          Notification of a comment.
 void declaration()
          Notification of an XML declaration.
 void dtd(java.lang.String name, java.lang.String publicID, java.lang.String systemID)
          Notification of a document type declaration.
 void endDocument()
          Notification of the end of the document.
 void endTag()
          Notification of an element end tag.
 XMLEventListenerState getState()
          Returns the current state of this outputter.
 void pcdata(char[] ch, int start, int length)
          Notification of a PCDATA section (as a char array).
 void pcdata(java.lang.String text)
          Notification of a PCDATA section (as a String).
 void pi(java.lang.String target, java.lang.String instruction)
          Notification of a processing instruction.
 void reset()
          Resets this XML event listener.
 void setState(XMLEventListenerState newState, java.lang.String[] newElementStack)
          Sets the state of this XML event listener.
 void startTag(java.lang.String type)
          Notification of an element start tag.
 void whitespace(char[] ch, int start, int length)
          Notification of ignorable whitespace (as a String).
 void whitespace(java.lang.String whitespace)
          Notification of ignorable whitespace (as a String).
 

Method Detail

reset

public void reset()
Resets this XML event listener. The state will be set to UNINITIALIZED 55 .


getState

public XMLEventListenerState getState()
                               throws java.lang.UnsupportedOperationException
Returns the current state of this outputter.


setState

public void setState(XMLEventListenerState newState,
                     java.lang.String[] newElementStack)
              throws java.lang.IllegalArgumentException
Sets the state of this XML event listener. Normally, it is not necessary to call this method and it should be used with great care.

Calling this method with UNINITIALIZED 55 as the state is equivalent to calling reset() 55 .


declaration

public void declaration()
                 throws java.lang.IllegalStateException,
                        java.io.IOException
Notification of an XML declaration. No encoding is explicitly specified.


dtd

public void dtd(java.lang.String name,
                java.lang.String publicID,
                java.lang.String systemID)
         throws java.lang.IllegalStateException,
                java.lang.IllegalArgumentException,
                InvalidXMLException,
                java.io.IOException
Notification of a document type declaration.

An external subset can be specified using either a system identifier (alone), or using both a public identifier and a system identifier. It can never be specified using a public identifier alone.

For example, for XHTML 1.0 the public identifier is:

-//W3C//DTD XHTML 1.0 Transitional//EN

while the system identifier is:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

The output is typically similar to this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
or alternatively, if only the system identifier is specified:
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


startTag

public void startTag(java.lang.String type)
              throws java.lang.IllegalStateException,
                     java.lang.IllegalArgumentException,
                     InvalidXMLException,
                     java.io.IOException
Notification of an element start tag.


attribute

public void attribute(java.lang.String name,
                      java.lang.String value)
               throws java.lang.IllegalStateException,
                      java.lang.IllegalArgumentException,
                      InvalidXMLException,
                      java.io.IOException
Adds an attribute to the current element. There must currently be an open element.

The attribute value is surrounded by single quotes.


endTag

public void endTag()
            throws java.lang.IllegalStateException,
                   java.io.IOException
Notification of an element end tag.


pcdata

public void pcdata(java.lang.String text)
            throws java.lang.IllegalStateException,
                   java.lang.IllegalArgumentException,
                   InvalidXMLException,
                   java.io.IOException
Notification of a PCDATA section (as a String).


pcdata

public void pcdata(char[] ch,
                   int start,
                   int length)
            throws java.lang.IllegalStateException,
                   java.lang.IllegalArgumentException,
                   java.lang.IndexOutOfBoundsException,
                   InvalidXMLException,
                   java.io.IOException
Notification of a PCDATA section (as a char array).


cdata

public void cdata(java.lang.String text)
           throws java.lang.IllegalStateException,
                  java.lang.IllegalArgumentException,
                  InvalidXMLException,
                  java.io.IOException
Notification of a CDATA section.

A CDATA section can contain any string, except "]]>". This will, however, not be checked by this method.

Left angle brackets and ampersands will be output in their literal form; they need not (and cannot) be escaped using "&lt;" and "&amp;".

If the specified string is empty (i.e. "".equals(text), then nothing will be output.

If the specified string contains characters that cannot be printed in this encoding, then the result is undefined.


whitespace

public void whitespace(java.lang.String whitespace)
                throws java.lang.IllegalStateException,
                       java.lang.IllegalArgumentException,
                       InvalidXMLException,
                       java.io.IOException
Notification of ignorable whitespace (as a String). Ignorable whitespace can be found anywhere in an XML document, except above the XML declaration.

This method does not check if the string actually contains whitespace.

If the state equals XMLEventListenerStates.BEFORE_XML_DECLARATION 55 , then it will be set to XMLEventListenerStates.BEFORE_DTD_DECLARATION 55 , otherwise if the state is XMLEventListenerStates.START_TAG_OPEN 55 then it will be set to XMLEventListenerStates.WITHIN_ELEMENT 55 , otherwise the state will not be changed.


whitespace

public void whitespace(char[] ch,
                       int start,
                       int length)
                throws java.lang.IllegalStateException,
                       java.lang.IllegalArgumentException,
                       java.lang.IndexOutOfBoundsException,
                       InvalidXMLException,
                       java.io.IOException
Notification of ignorable whitespace (as a String). Ignorable whitespace can be found anywhere in an XML document, except above the XML declaration.

This method does not check if the string actually contains whitespace.

If the state equals XMLEventListenerStates.BEFORE_XML_DECLARATION 55 , then it will be set to XMLEventListenerStates.BEFORE_DTD_DECLARATION 55 , otherwise if the state is XMLEventListenerStates.START_TAG_OPEN 55 then it will be set to XMLEventListenerStates.WITHIN_ELEMENT 55 , otherwise the state will not be changed.


comment

public void comment(java.lang.String text)
             throws java.lang.IllegalStateException,
                    java.lang.IllegalArgumentException,
                    InvalidXMLException,
                    java.io.IOException
Notification of a comment. The comment should not contain the string "--".

If the state equals XMLEventListenerStates.BEFORE_XML_DECLARATION 55 , then it will be set to XMLEventListenerStates.BEFORE_DTD_DECLARATION 55 , otherwise if the state is XMLEventListenerStates.START_TAG_OPEN 55 then it will be set to XMLEventListenerStates.WITHIN_ELEMENT 55 , otherwise the state will not be changed.


pi

public void pi(java.lang.String target,
               java.lang.String instruction)
        throws java.lang.IllegalStateException,
               java.lang.IllegalArgumentException,
               InvalidXMLException,
               java.io.IOException
Notification of a processing instruction. A target and an optional instruction should be specified.

A processing instruction can appear above and below the root element, and between elements. It cannot appear inside an element start or end tag, nor inside a comment. Processing instructions cannot be nested.

If the state equals XMLEventListenerStates.BEFORE_XML_DECLARATION 55 , then it will be set to XMLEventListenerStates.BEFORE_DTD_DECLARATION 55 , otherwise the state will not be changed.


endDocument

public void endDocument()
                 throws java.lang.IllegalStateException,
                        java.io.IOException
Notification of the end of the document. After calling this method, none of the other notification methods can be called until reset() 55 is called.