org.testng.xml
Class TestNGContentHandler

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

public class TestNGContentHandler
extends DefaultHandler

Suite definition parser utility.

Author:
Cedric Beust, Alexandru Popescu

Constructor Summary
TestNGContentHandler(String fileName, boolean loadClasses)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(String uri, String localName, String qName)
           
 void error(SAXParseException e)
           
 XmlSuite getSuite()
           
 InputSource resolveEntity(String systemId, String publicId)
           
 void startElement(String uri, String localName, String qName, Attributes attributes)
          NOTE: I only invoke xml*methods (e.g.
 void xmlClasses(boolean start, Attributes attributes)
          Parse
 void xmlListener(boolean start, Attributes attributes)
          Parse
 void xmlListeners(boolean start, Attributes attributes)
          Parse
 void xmlMethodSelector(boolean start, Attributes attributes)
          Parse
 void xmlMethodSelectors(boolean start, Attributes attributes)
          Parse
 void xmlPackages(boolean start, Attributes attributes)
          Parse
 void xmlRun(boolean start, Attributes attributes)
          Parse
 void xmlSelectorClass(boolean start, Attributes attributes)
          Parse
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestNGContentHandler

public TestNGContentHandler(String fileName,
                            boolean loadClasses)
Method Detail

resolveEntity

public InputSource resolveEntity(String systemId,
                                 String publicId)
                          throws IOException,
                                 SAXException
Specified by:
resolveEntity in interface EntityResolver
Overrides:
resolveEntity in class DefaultHandler
Throws:
IOException
SAXException

xmlClasses

public void xmlClasses(boolean start,
                       Attributes attributes)
Parse


xmlListeners

public void xmlListeners(boolean start,
                         Attributes attributes)
Parse


xmlListener

public void xmlListener(boolean start,
                        Attributes attributes)
Parse


xmlPackages

public void xmlPackages(boolean start,
                        Attributes attributes)
Parse


xmlMethodSelectors

public void xmlMethodSelectors(boolean start,
                               Attributes attributes)
Parse


xmlSelectorClass

public void xmlSelectorClass(boolean start,
                             Attributes attributes)
Parse


xmlMethodSelector

public void xmlMethodSelector(boolean start,
                              Attributes attributes)
Parse


xmlRun

public void xmlRun(boolean start,
                   Attributes attributes)
            throws SAXException
Parse

Throws:
SAXException

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
NOTE: I only invoke xml*methods (e.g. xmlSuite()) if I am acting on both the start and the end of the tag. This way I can keep the treatment of this tag in one place. If I am only doing something when the tag opens, the code is inlined below in the startElement() method.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

error

public void error(SAXParseException e)
           throws SAXException
Specified by:
error in interface ErrorHandler
Overrides:
error in class DefaultHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler

getSuite

public XmlSuite getSuite()


Copyright © 2012. All Rights Reserved.