org.extex.util.xml
Class XmlHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.extex.util.xml.XmlHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XmlHandler
extends org.xml.sax.helpers.DefaultHandler

Generic Handler.

Version:
$Revision: 5837 $
Author:
Michael Niedermair

Field Summary
protected  XMLStreamWriter writer
          The XMLStreamWriter for the output.
 
Constructor Summary
XmlHandler()
          Creates a new object.
XmlHandler(XMLStreamWriter writer)
          Creates a new object.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
           
 java.lang.String getCurrentElementName()
          Returns the name of the current element.
 java.lang.String getCurrentTextValue()
          Returns the text of the current element.
 java.lang.String getFullName()
          Returns the full name of the current element.
 int getLevel()
          Getter for level.
 boolean hasParentElement(java.lang.String name)
          Check, if the element is parent of the current entry.
 boolean isInElement(java.lang.String name)
          Check, if the parser is in the element.
 boolean isUseWriter()
          Getter for useWriter.
 void setUseWriter(boolean useWriter)
          Setter for useWriter.
 void setWriter(XMLStreamWriter writer)
          Setter for writer.
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
protected  void writeAttr(org.xml.sax.Attributes attributes)
          Write the attributes.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected XMLStreamWriter writer
The XMLStreamWriter for the output.

Constructor Detail

XmlHandler

public XmlHandler()
Creates a new object.


XmlHandler

public XmlHandler(XMLStreamWriter writer)
Creates a new object.

Parameters:
writer - The XMLStreamWriter for the output.
Method Detail

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.characters(char[], int, int)

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.endDocument()

endElement

public void endElement(java.lang.String arg0,
                       java.lang.String arg1,
                       java.lang.String arg2)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

getCurrentElementName

public java.lang.String getCurrentElementName()
Returns the name of the current element. If no name in the list, a empty string is returned.

Returns:
Returns the name of the current element.

getCurrentTextValue

public java.lang.String getCurrentTextValue()
Returns the text of the current element. If no text in the list, a empty string is returned.

Returns:
Returns the name of the current element.

getFullName

public java.lang.String getFullName()
Returns the full name of the current element.

Returns:
Returns the full name of the current element.

getLevel

public int getLevel()
Getter for level.

Returns:
the level

hasParentElement

public boolean hasParentElement(java.lang.String name)
Check, if the element is parent of the current entry.

Parameters:
name - The name of the parent.
Returns:
Returns true, if the element is parent of the current element, otherwise false.

isInElement

public boolean isInElement(java.lang.String name)
Check, if the parser is in the element.

Parameters:
name - The name of the element.
Returns:
Returns true, if the parser parse the named element.

isUseWriter

public boolean isUseWriter()
Getter for useWriter.

Returns:
the useWriter

setUseWriter

public void setUseWriter(boolean useWriter)
Setter for useWriter.

Parameters:
useWriter - the useWriter to set

setWriter

public void setWriter(XMLStreamWriter writer)
Setter for writer.

Parameters:
writer - the writer to set

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.startDocument()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

writeAttr

protected void writeAttr(org.xml.sax.Attributes attributes)
                  throws java.io.IOException
Write the attributes.

Parameters:
attributes - The attributes.
Throws:
java.io.IOException - if a io-error occurred.