public DataManagerManager() { this.data = new DataManager(); this.modMan = data.getUMLModifierManager(); this.outStrat = new GUIUMLOutputStrategy(); this.outStrat.setDataManager(this.data); // Add all of the output visitors for that output strategy outStrat.addOutputVisitor(new ClassOutputVisitor(), modMan, null); outStrat.addOutputVisitor(new ExtendOutputVisitor(), modMan, null); outStrat.addOutputVisitor(new ImplementOutputVisitor(), modMan, null); outStrat.addOutputVisitor(new AssocOutputVisitor(), modMan, null); outStrat.addOutputVisitor(new UsesOutputVisitor(), modMan, null); this.data.setOutputStrategy(this.outStrat); this.data.setAddStrategy(new UMLAddStrategy()); }
public void analyze() { String[] phases = this.config.getPhases(); // load each phase for (int ip = 0; ip < phases.length; ip++) { String p = phases[ip]; PhaseData pData = this.config.getPhaseData(p); // load the classes if (pData.getName().equals("Loader")) { List<Map<String, File>> dirMapList = new ArrayList<Map<String, File>>(); String[] toLoad = this.config.getInputFolderPath(); int totalClassesToLoad = 0; for (int i = 0; i < toLoad.length; ++i) { this.progressText = "Parsing directory " + toLoad[i]; Map<String, File> dirMap = this.getAllClasses(toLoad[i]); dirMapList.add(dirMap); totalClassesToLoad += dirMap.size(); } toLoad = this.config.getToLoad(); totalClassesToLoad += toLoad.length; int classesLoaded = 0; for (int il = 0; il < toLoad.length; il++) { String s = toLoad[il]; try { data.add(new String[] {s}); } catch (IOException e) { e.printStackTrace(); } this.progressInt = (int) (100.0 * (++classesLoaded) / (totalClassesToLoad * phases.length)); this.progressText = "Loading class " + pData.getName(); } for (Map<String, File> dirMap : dirMapList) { for (Entry<String, File> e : dirMap.entrySet()) { try { data.addClass(e.getKey(), new FileInputStream(e.getValue())); this.progressInt = (int) (100.0 * (++classesLoaded) / (totalClassesToLoad * phases.length)); this.progressText = "Loading class " + e.getKey(); // Thread.sleep(100); } catch (Exception e1) { e1.printStackTrace(); } } } } else { // set the phase data String className = pData.getName(); try { Class c = Class.forName(className); Constructor cons; IPatternFinder pf; if (pData.getArgs() != null && pData.getArgs().length > 0) { cons = c.getConstructor(new Class[] {pData.getArgs().getClass()}); pf = (IPatternFinder) cons.newInstance(pData.getArgs()); } else { cons = c.getConstructor(new Class[] {}); pf = (IPatternFinder) cons.newInstance(); } this.data.addPatternFinderPhase(p, pf); } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } // run all the other phases this.data.runPhase(p); this.progressInt = (int) (100.0 * (ip + 1) / phases.length); this.progressText = "Running phase " + pData.getName(); } } }