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.SnippetProject; 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 ByteCodeProjectSnippetFactory 44 extends AbstractByteCodeSnippetFactory 45 implements ISnippetFactory 46 { 47 48 51 private String innerStartDirectory; 52 53 54 58 public ByteCodeProjectSnippetFactory(String startDirectory){ 59 innerStartDirectory = startDirectory; 60 } 61 62 66 public Snippets getSnippets() 67 throws NoUnitException { 68 69 ISnippet thisProjectSnippet; 71 String thisFile; 72 Iterator loopList; 73 HashSet availablePackages; 74 Snippets tmpSnippets; 75 Snippets projectInfo ; 76 Snippets packageInfo = new Snippets(); 77 ByteCodePackageSnippetFactory myPackageFactory; 78 79 try { 80 81 availablePackages = DirectoryWalker.getDirs(innerStartDirectory); 83 84 } catch (IOException ie) { 85 throw new NoUnitException(ie,"Could not read files from Package"); 86 } 87 88 loopList = availablePackages.iterator(); 90 91 while (loopList.hasNext()) { 92 thisFile = (String )loopList.next(); 93 myPackageFactory = new ByteCodePackageSnippetFactory(thisFile); 94 tmpSnippets = myPackageFactory.getSnippets(); 95 packageInfo.add(tmpSnippets.getCollection()); 96 } 97 98 thisProjectSnippet = new SnippetProject(packageInfo); 100 101 projectInfo = new Snippets(); 103 projectInfo.add(thisProjectSnippet); 104 105 return projectInfo ; 106 107 } 108 109 110 } 111 | Popular Tags |