org.kxml.parser
Class ParseEvent

java.lang.Object
  extended byorg.kxml.parser.ParseEvent
Direct Known Subclasses:
Tag, WapExtensionEvent

public class ParseEvent
extends java.lang.Object

Abstract superclass for all pull parser events. In order to avoid some typecasts, this class already provides most of the content access methods filled in the specialized subclasses.


Constructor Summary
ParseEvent(int type, java.lang.String text)
           
 
Method Summary
 Attribute getAttribute(int index)
          In the event type is START_TAG, this method returns the attribute at the given index position.
 Attribute getAttribute(java.lang.String name)
          returns the local attribute with the given name.
 Attribute getAttribute(java.lang.String namespace, java.lang.String name)
          returns the local attribute with the given qualified name.
 int getAttributeCount()
          If the event type is START_TAG, the number of attributes is returned.
 java.util.Vector getAttributes()
          If the event type is START_TAG, the attribute Vector (null if no attributes) is returned.
 int getLineNumber()
          returns the line number of the event
 java.lang.String getName()
          returns the (local) name of the element started if instance of StartTag, null otherwise.
 java.lang.String getNamespace()
          returns namespace if instance of StartTag, null otherwise.
 java.lang.String getText()
          If the event type is TEXT, PROCESSING_INSTRUCTION, or DOCTYPE, the corresponding string is returned.
 int getType()
          returns the event type integer constant assigned to this event.
 java.lang.String getValue(java.lang.String attrName)
          Returns the value of the attribute with the given name.
 java.lang.String getValueDefault(java.lang.String attrName, java.lang.String deflt)
          Returns the given attribute value, or the given default value if the attribute is not existing.
 void setLineNumber(int lineNumber)
          sets the line number of the event.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParseEvent

public ParseEvent(int type,
                  java.lang.String text)
Method Detail

getLineNumber

public int getLineNumber()
returns the line number of the event


getType

public int getType()
returns the event type integer constant assigned to this event. Possible event types are Xml.START_TAG, Xml.END_TAG, Xml.TEXT, Xml.PROCESSING_INSTRUCTION, Xml.COMMENT, Xml.DOCTYPE, and Xml.END_DOCUMENT


setLineNumber

public void setLineNumber(int lineNumber)
sets the line number of the event. Used by the parser only.


getAttribute

public Attribute getAttribute(int index)
In the event type is START_TAG, this method returns the attribute at the given index position. For all other event types, or if the index is out of range, an exception is thrown.


getAttribute

public Attribute getAttribute(java.lang.String name)
returns the local attribute with the given name. convenience method for getAttribute (Xml.NO_NAMESPACE, name);


getAttribute

public Attribute getAttribute(java.lang.String namespace,
                              java.lang.String name)
returns the local attribute with the given qualified name. Please use null as placeholder for any namespace or Xml.NO_NAMESPACE for no namespace.


getAttributeCount

public int getAttributeCount()
If the event type is START_TAG, the number of attributes is returned. For all other event types, an exception is thrown.


getAttributes

public java.util.Vector getAttributes()
If the event type is START_TAG, the attribute Vector (null if no attributes) is returned. For all other event types, an exception is thrown.


getName

public java.lang.String getName()
returns the (local) name of the element started if instance of StartTag, null otherwise.


getNamespace

public java.lang.String getNamespace()
returns namespace if instance of StartTag, null otherwise.


getValue

public java.lang.String getValue(java.lang.String attrName)
Returns the value of the attribute with the given name. Throws an exception if not instanceof StartTag or if not existing. In order to get a null value for not existing attributes, please call getValueDefault (attrName, null) instead.


getValueDefault

public java.lang.String getValueDefault(java.lang.String attrName,
                                        java.lang.String deflt)
Returns the given attribute value, or the given default value if the attribute is not existing.


getText

public java.lang.String getText()
If the event type is TEXT, PROCESSING_INSTRUCTION, or DOCTYPE, the corresponding string is returned. For all othe event types, null is returned.


toString

public java.lang.String toString()