public static CrawlableDataset createCrawlableDataset ( String path , String className , Object configObj ) throws IOException , ClassNotFoundException , NoSuchMethodException , IllegalAccessException , InvocationTargetException , InstantiationException , IllegalArgumentException , NullPointerException // throws CrDsException, IllegalArgumentException { if ( path == null ) throw new NullPointerException ( "Given path must not be null." ) ; String tmpClassName = ( className == null ? defaultClassName : className ) ; // @todo Remove alias until sure how to handle things like ".scour*" being a regular file. // if ( CrawlableDatasetAlias.isAlias( tmpPath) ) // return new CrawlableDatasetAlias( tmpPath, tmpClassName, configObj ); // Get the Class instance for desired CrawlableDataset implementation. Class crDsClass = Class . forName ( tmpClassName ) ; // Check that the Class is a CrawlableDataset. if ( ! CrawlableDataset . class . isAssignableFrom ( crDsClass ) ) { throw new IllegalArgumentException ( "Requested class <" + className + "> not an implementation of thredds.crawlabledataset.CrawlableDataset." ) ; } // Instantiate the desired CrawlableDataset. Class [ ] argTypes = { String . class , Object . class } ; Object [ ] args = { path , configObj } ; Constructor constructor = crDsClass . getDeclaredConstructor ( argTypes ) ; try { return ( CrawlableDataset ) constructor . newInstance ( args ) ; } catch ( InvocationTargetException e ) { if ( IOException . class . isAssignableFrom ( e . getCause ( ) . getClass ( ) ) ) throw ( IOException ) e . getCause ( ) ; else throw e ; } }
Construct a CrawlableDataset for the given path using the CrawlableDataset implementation indicated by the given class name .