1 4 package org.oddjob.doclet; 5 6 import java.util.ArrayList ; 7 import java.util.HashMap ; 8 import java.util.List ; 9 import java.util.Map ; 10 11 import com.sun.javadoc.ClassDoc; 12 13 19 public class Archiver { 20 21 private final JobsAndTypes jats; 22 23 private Map jobData = new HashMap (); 24 private Map typeData = new HashMap (); 25 private Map otherData = new HashMap (); 26 27 public Archiver(JobsAndTypes jats) { 28 this.jats = jats; 29 } 30 31 public void archive(ClassDoc classDoc) { 32 33 String fqcn = Processor.fqcnFor(classDoc); 34 if (!jats.contains(fqcn)) { 35 return; 36 } 37 38 Processor processor = new Processor(jats, classDoc); 39 PageData pageData = processor.process(); 40 41 if (jats.isJob(fqcn)) { 42 jobData.put(pageData.getName(), pageData); 43 } 44 else if (jats.isType(fqcn)) { 45 typeData.put(pageData.getName(), pageData); 46 } 47 else { 48 otherData.put(pageData.getName(), pageData); 49 } 50 51 } 52 53 58 public PageData[] getJobData() { 59 List results = new ArrayList (); 60 String [] jobs = jats.jobs(); 61 for (int i = 0; i < jobs.length; ++i) { 62 PageData pageData = (PageData) jobData.get(jobs[i]); 63 if (pageData != null) { 64 results.add(pageData); 65 } 66 } 67 68 return (PageData[]) results.toArray(new PageData[0]); 69 } 70 71 76 public PageData[] getTypeData() { 77 List results = new ArrayList (); 78 String [] types = jats.types(); 79 for (int i = 0; i < types.length; ++i) { 80 PageData pageData = (PageData) typeData.get(types[i]); 81 if (pageData != null) { 82 results.add(pageData); 83 } 84 } 85 86 return (PageData[]) results.toArray(new PageData[0]); 87 } 88 89 public List getAll() { 90 List all = new ArrayList (); 91 all.addAll(jobData.values()); 92 all.addAll(typeData.values()); 93 all.addAll(otherData.values()); 94 return all; 95 } 96 97 98 } 99 | Popular Tags |