1 2 package net.firstpartners.nounit.reader.bytecode; 3 4 27 28 import java.io.IOException ; 29 import java.util.HashSet ; 30 import java.util.Iterator ; 31 32 import net.firstpartners.nounit.reader.ISnippetFactory; 33 import net.firstpartners.nounit.snippet.ISnippet; 34 import net.firstpartners.nounit.snippet.SnippetPackage; 35 import net.firstpartners.nounit.snippet.Snippets; 36 import net.firstpartners.nounit.utility.DirectoryWalker; 37 import net.firstpartners.nounit.utility.NoUnitException; 38 39 43 public class ByteCodePackageSnippetFactory extends AbstractByteCodeSnippetFactory implements ISnippetFactory { 44 45 48 private String innerStartDirectory; 49 50 51 55 public ByteCodePackageSnippetFactory(String startDirectory){ 56 innerStartDirectory = startDirectory; 57 } 58 59 63 public Snippets getSnippets() 64 throws NoUnitException { 65 66 ISnippet thisPackageSnippet; 68 String thisFile; 69 Iterator loopList; 70 HashSet availableClasses; 71 Snippets tmpSnippets; 72 Snippets packageInfo ; 73 Snippets classInfo = new Snippets(); 74 ByteCodeClassSnippetFactory myClassFactory; 75 76 try { 77 availableClasses = DirectoryWalker.getFiles(innerStartDirectory, ".class"); 79 80 } catch (IOException ie) { 81 throw new NoUnitException(ie,"Could not read files from Package"); 82 } 83 84 loopList = availableClasses.iterator(); 86 87 while (loopList.hasNext()) { 88 89 thisFile = (String )loopList.next(); 90 myClassFactory = new ByteCodeClassSnippetFactory(thisFile); 91 tmpSnippets = myClassFactory.getSnippets(); 92 classInfo.add(tmpSnippets.getCollection()); 93 94 } 95 96 thisPackageSnippet = new SnippetPackage(innerStartDirectory,classInfo); 98 99 packageInfo = new Snippets(); 101 packageInfo.add(thisPackageSnippet); 102 103 return packageInfo ; 104 105 } 106 107 108 } 109 | Popular Tags |