/** Augment the class names associated with a UCL. * @param cl the UCL that loads from url * @param classNamesMap the Map<cl, String[]> to update * @param url the URL to parse for class names * @param prevClassNames the set of pckage names already associated with cl * @return the updated list of class names * @throws Exception */ public static String[] updateClassNamesMap(Object cl, Map classNamesMap, URL url, String[] prevClassNames) throws Exception { ClassPathIterator cpi = new ClassPathIterator(url); HashSet classNameSet = null; if (prevClassNames == null) classNameSet = new HashSet(); else classNameSet = new HashSet(Arrays.asList(prevClassNames)); return updateClassNamesMap(cl, classNamesMap, cpi, classNameSet); }
static String[] updateClassNamesMap(Object cl, Map classNamesMap, ClassPathIterator cpi, HashSet classNameSet) throws Exception { boolean trace = log.isTraceEnabled(); ClassPathEntry entry; while( (entry = cpi.getNextEntry()) != null ) { String name = entry.getName(); // Skip empty directory entries if( entry.isDirectory() == true ) continue; // Skip non .class files if( name.endsWith(".class") == false ) continue; addClass(name, classNamesMap, cl, trace); classNameSet.add(name); } cpi.close(); // Return an array of the package names String[] classNames = new String[classNameSet.size()]; classNameSet.toArray(classNames); return classNames; }
/** Read the JDK 1.3+ META-INF/INDEX.LIST entry to obtain the package names without having to iterate through all entries in the jar. */ private static void readJarIndex(ClassPathIterator cpi, PkgNameListener listener) throws Exception { boolean trace = log.isTraceEnabled(); InputStream zis = cpi.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(zis)); String line; // Skip the jar index header while( (line = br.readLine()) != null ) { if( line.length() == 0 ) break; } // Read the main jar section String jarName = br.readLine(); if( trace ) log.trace("Reading INDEX.LIST for jar: "+jarName); while( (line = br.readLine()) != null ) { if( line.length() == 0 ) break; String pkgName = line.replace('/', '.'); listener.addPackage(pkgName); } br.close(); }
/** Read the JDK 1.3+ META-INF/INDEX.LIST entry to obtain the package names without having to iterate through all entries in the jar. */ private static void readJarIndex(ClassPathIterator cpi, PkgNameListener listener) throws Exception { boolean trace = log.isTraceEnabled(); InputStream zis = cpi.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(zis)); String line; // Skip the jar index header while( (line = br.readLine()) != null ) { if( line.length() == 0 ) break; } // Read the main jar section String jarName = br.readLine(); if( trace ) log.trace("Reading INDEX.LIST for jar: "+jarName); while( (line = br.readLine()) != null ) { if( line.length() == 0 ) break; String pkgName = line.replace('/', '.'); listener.addPackage(pkgName); } br.close(); }
static void updatePackageMap(ClassPathIterator cpi, PkgNameListener listener) throws Exception { ClassPathEntry entry; while( (entry = cpi.getNextEntry()) != null ) { String name = entry.getName(); // First look for a META-INF/INDEX.LIST entry if( name.equals("META-INF/INDEX.LIST") ) { readJarIndex(cpi, listener); // We are done break; } // Skip empty directory entries if( entry.isDirectory() == true ) continue; String pkgName = entry.toPackageName(); listener.addPackage(pkgName); } cpi.close(); }
static void updatePackageMap(ClassPathIterator cpi, PkgNameListener listener) throws Exception { ClassPathEntry entry; while( (entry = cpi.getNextEntry()) != null ) { String name = entry.getName(); // First look for a META-INF/INDEX.LIST entry if( name.equals("META-INF/INDEX.LIST") ) { readJarIndex(cpi, listener); // We are done break; } // Skip empty directory entries if( entry.isDirectory() == true ) continue; String pkgName = entry.toPackageName(); listener.addPackage(pkgName); } cpi.close(); }
/** Augment the class names associated with a UCL. * @param cl the UCL that loads from url * @param classNamesMap the Map<cl, String[]> to update * @param url the URL to parse for class names * @param prevClassNames the set of pckage names already associated with cl * @return the updated list of class names * @throws Exception */ public static String[] updateClassNamesMap(Object cl, Map classNamesMap, URL url, String[] prevClassNames) throws Exception { ClassPathIterator cpi = new ClassPathIterator(url); HashSet classNameSet = null; if (prevClassNames == null) classNameSet = new HashSet(); else classNameSet = new HashSet(Arrays.asList(prevClassNames)); return updateClassNamesMap(cl, classNamesMap, cpi, classNameSet); }
static String[] updateClassNamesMap(Object cl, Map classNamesMap, ClassPathIterator cpi, HashSet classNameSet) throws Exception { boolean trace = log.isTraceEnabled(); ClassPathEntry entry; while( (entry = cpi.getNextEntry()) != null ) { String name = entry.getName(); // Skip empty directory entries if( entry.isDirectory() == true ) continue; // Skip non .class files if( name.endsWith(".class") == false ) continue; addClass(name, classNamesMap, cl, trace); classNameSet.add(name); } cpi.close(); // Return an array of the package names String[] classNames = new String[classNameSet.size()]; classNameSet.toArray(classNames); return classNames; }
/** Augment the package name associated with a UCL. * @param cl the UCL that loads from url * @param packagesMap the Map<cl, String[]> to update * @param url the URL to parse for package names * @param prevPkgNames the set of pckage names already associated with cl * @return the updated unique set of package names * @throws Exception */ public static void updatePackageMap(URL url, PkgNameListener listener) throws Exception { ClassPathIterator cpi = new ClassPathIterator(url); updatePackageMap(cpi, listener); }
/** Augment the package name associated with a UCL. * @param url the URL to parse for package names * @param listener the listener * @throws Exception */ public static void updatePackageMap(URL url, PkgNameListener listener) throws Exception { ClassPathIterator cpi = new ClassPathIterator(url); updatePackageMap(cpi, listener); }