The moose likes XML and Related Technologies and the fly likes help on newInstance() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "help on newInstance() method" Watch "help on newInstance() method" New topic
Author

help on newInstance() method

tom gong
Ranch Hand

Joined: Jul 15, 2000
Posts: 36
Hi:
The following two line code was from xml4j-3-2-0/samples/sax/sax2count.java (from IBM site)
String parserName="org.apache.xerces.parsers.SAXParser"
XMLReader parser = (XMLReader)Class.forName(parserName).newInstance();///??
Class.forName(parserName) return object of org.apache.xerces.parsers.SAXParser
I do not see any newInstance() method belong to org.apache.xerces.parsers.SAXParser ot XMLReader///!!
the only two newInstance() methods can be found at following:
newInstance() - Static method in class javax.xml.parsers.SAXParserFactory
Obtain a new instance of a SAXParserFactory.
newSAXParser() - Method in class javax.xml.parsers.SAXParserFactory
Creates a new instance of a SAXParser using the currently configured factory parameters.
class javax.xml.parsers.SAXParserFactory was directly extended from java.lang.Object
Somebody please help me, how could newInstance() be called in statement of XMLReader parser = (XMLReader)Class.forName(parserName).newInstance()
Thank you for help!
Tom Gong
 
 
subject: help on newInstance() method
 
Threads others viewed
Class.forName
xml/sax
XMLReader versus SAXParser
XML document is not getting parsed properly.
problem with SAXParserFactory!
developer file tools