net.sf.joost.stx
Class SAXEvent

java.lang.Object
  extended by net.sf.joost.stx.SAXEvent

public final class SAXEvent
extends Object

SAXEvent stores all information attached to an incoming SAX event, it is the representation of a node in STX.

Version:
$Revision: 1.20 $ $Date: 2007/11/25 14:18:01 $
Author:
Oliver Becker

Nested Class Summary
private  class SAXEvent.Counter
          This class replaces java.lang.Long for counting because I need to change the wrapped value and want to avoid the creation of a new object in each increment.
private static class SAXEvent.DoubleString
          This class acts as a wrapper for a pair of String objects.
 
Field Summary
static int ATTRIBUTE
           
 MutableAttributes attrs
           
static int CDATA
           
static int COMMENT
           
static int ELEMENT
           
static int ELEMENT_END
           
private static SAXEvent.DoubleString GENERIC_ELEMENT
           
private static SAXEvent.DoubleString GENERIC_PI
           
 boolean hasChildNodes
           
 String lName
           
static int MAPPING
           
static int MAPPING_END
           
 Hashtable namespaces
           
static int PI
           
private  HashMap posHash
          contains the position counters
 String qName
           
static int ROOT
           
static int TEXT
           
 int type
           
 String uri
           
 String value
           
 
Constructor Summary
private SAXEvent()
           
 
Method Summary
private  void _countPosition(Object[] keys)
          Performs the real counting.
 Object clone()
           
 void countCDATA()
          Increments the associated counters for a text CDATA node.
 void countComment()
          Increments the associated counters for a comment node.
 void countElement(String uri, String lName)
          Increments the associated counters for an element.
 void countPI(String target)
          Increment the associated counters for a processing instruction node.
 void countText()
          Increments the associated counters for a text node.
 void enableChildNodes(boolean hasChildNodes)
          Enables the counting of child nodes.
 long getPositionOf(String uri, String lName)
           
 long getPositionOfCDATA()
           
 long getPositionOfComment()
           
 long getPositionOfNode()
           
 long getPositionOfPI(String target)
           
 long getPositionOfText()
           
static SAXEvent newAttribute(Attributes attrs, int index)
          Create a new attribute node
static SAXEvent newAttribute(String uri, String lname, String qName, String value)
          Create a new attribute node
static SAXEvent newCDATA(String value)
          Create a new CDATA node
static SAXEvent newComment(String value)
          Create a new comment node
static SAXEvent newElement(String uri, String lName, String qName, Attributes attrs, boolean mutable, Hashtable inScopeNamespaces)
          Create a new element node
static SAXEvent newMapping(String prefix, String uri)
          Create a new representation for a namespace mapping
static SAXEvent newPI(String target, String data)
          Create a new processing instruction node
static SAXEvent newRoot()
          Create a root node
static SAXEvent newText(String value)
          Create a new text node
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT

public static final int ROOT
See Also:
Constant Field Values

ELEMENT

public static final int ELEMENT
See Also:
Constant Field Values

TEXT

public static final int TEXT
See Also:
Constant Field Values

CDATA

public static final int CDATA
See Also:
Constant Field Values

PI

public static final int PI
See Also:
Constant Field Values

COMMENT

public static final int COMMENT
See Also:
Constant Field Values

ATTRIBUTE

public static final int ATTRIBUTE
See Also:
Constant Field Values

ELEMENT_END

public static final int ELEMENT_END
See Also:
Constant Field Values

MAPPING

public static final int MAPPING
See Also:
Constant Field Values

MAPPING_END

public static final int MAPPING_END
See Also:
Constant Field Values

type

public int type

uri

public String uri

lName

public String lName

qName

public String qName

attrs

public MutableAttributes attrs

namespaces

public Hashtable namespaces

value

public String value

hasChildNodes

public boolean hasChildNodes

posHash

private HashMap posHash
contains the position counters


GENERIC_ELEMENT

private static final SAXEvent.DoubleString GENERIC_ELEMENT

GENERIC_PI

private static final SAXEvent.DoubleString GENERIC_PI
Constructor Detail

SAXEvent

private SAXEvent()
Method Detail

newElement

public static SAXEvent newElement(String uri,
                                  String lName,
                                  String qName,
                                  Attributes attrs,
                                  boolean mutable,
                                  Hashtable inScopeNamespaces)
Create a new element node


newText

public static SAXEvent newText(String value)
Create a new text node


newCDATA

public static SAXEvent newCDATA(String value)
Create a new CDATA node


newRoot

public static SAXEvent newRoot()
Create a root node


newComment

public static SAXEvent newComment(String value)
Create a new comment node


newPI

public static SAXEvent newPI(String target,
                             String data)
Create a new processing instruction node


newAttribute

public static SAXEvent newAttribute(String uri,
                                    String lname,
                                    String qName,
                                    String value)
Create a new attribute node


newAttribute

public static SAXEvent newAttribute(Attributes attrs,
                                    int index)
Create a new attribute node


newMapping

public static SAXEvent newMapping(String prefix,
                                  String uri)
Create a new representation for a namespace mapping


enableChildNodes

public void enableChildNodes(boolean hasChildNodes)
Enables the counting of child nodes.

Parameters:
hasChildNodes - true, if there are really child nodes; false, if only the counting has to be supported (e.g. in stx:process-buffer)

countElement

public void countElement(String uri,
                         String lName)
Increments the associated counters for an element.


countText

public void countText()
Increments the associated counters for a text node.


countCDATA

public void countCDATA()
Increments the associated counters for a text CDATA node.


countComment

public void countComment()
Increments the associated counters for a comment node.


countPI

public void countPI(String target)
Increment the associated counters for a processing instruction node.


_countPosition

private void _countPosition(Object[] keys)
Performs the real counting. Will be used by the count* functions.


getPositionOf

public long getPositionOf(String uri,
                          String lName)

getPositionOfNode

public long getPositionOfNode()

getPositionOfText

public long getPositionOfText()

getPositionOfCDATA

public long getPositionOfCDATA()

getPositionOfComment

public long getPositionOfComment()

getPositionOfPI

public long getPositionOfPI(String target)

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object