// Double-check that it's actually the right kind of class
// before attempting instantiation.
if ( ! XPathReader.class.isAssignableFrom( readerClass ) )
{
throw new SAXPathException( "Class [" + className + "] does not implement the org.saxpath.XPathReader interface." );
}
}
catch (ClassNotFoundException e)
{
throw new SAXPathException( e.getMessage() );
}
try
{
reader = (XPathReader) readerClass.newInstance();
}
catch (IllegalAccessException e)
{
throw new SAXPathException( e.getMessage() );
}
catch (InstantiationException e)
{
throw new SAXPathException( e.getMessage() );
}
if ( reader == null )
{
throw new SAXPathException( "Unable to create XPathReader" );
}
return reader;
}