Coverage Report - net.sf.statcvs.pages.xml.LogXmlMaker
 
Classes in this File Line Coverage Branch Coverage Complexity
LogXmlMaker
0%
0/37
0%
0/16
1.5
 
 1  
 package net.sf.statcvs.pages.xml;
 2  
 
 3  
 /**
 4  
  * This is a mere copy of the LogXMLpagemaker class with few changes done
 5  
  * */
 6  
 import java.util.ArrayList;
 7  
 import java.util.Calendar;
 8  
 import java.util.Collection;
 9  
 import java.util.Collections;
 10  
 import java.util.Date;
 11  
 import java.util.GregorianCalendar;
 12  
 import java.util.Iterator;
 13  
 import java.util.List;
 14  
 
 15  
 import net.sf.statcvs.model.Commit;
 16  
 import net.sf.statcvs.model.SymbolicName;
 17  
 import net.sf.statcvs.output.ReportConfig;
 18  
 
 19  
 import org.jdom.Element;
 20  
 
 21  
 public class LogXmlMaker {
 22  0
     private final static String[] MONTH_TWO_CHARACTERS = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" };
 23  
 
 24  
     public static String getAnchor(final SymbolicName tag) {
 25  0
         return "tag-" + tag.getName();
 26  
     }
 27  
 
 28  
     public static String getURL(final Date date) {
 29  0
         final Calendar calendar = new GregorianCalendar();
 30  0
         calendar.setTime(date);
 31  0
         return getFileName(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)) + ".html";
 32  
     }
 33  
 
 34  
     private static String getFileName(final int year, final int month) {
 35  0
         return year + "-" + MONTH_TWO_CHARACTERS[month];
 36  
     }
 37  
 
 38  
     private final ReportConfig config;
 39  0
     private final List commits = new ArrayList();
 40  
 
 41  0
     /**
 42  
      * Creates a new LogPageMaker.
 43  
      * @param year The log page's year
 44  
      * @param month The log page's month (0 for January)
 45  
      * @param commits A list of commits; those not in the
 46  
      *                 right month will be ignored
 47  
      * @param outputFormat
 48  
      */
 49  0
     public LogXmlMaker(final ReportConfig config, final Collection commits) {
 50  0
         this.config = config;
 51  0
         final Iterator it = commits.iterator();
 52  0
         while (it.hasNext()) {
 53  0
             final Commit commit = (Commit) it.next();
 54  0
             this.commits.add(commit);
 55  0
         }
 56  0
     }
 57  0
 
 58  0
     public Element toFile() {
 59  0
         Element lg = null;
 60  0
         if (!this.commits.isEmpty()) {
 61  0
             lg = new CommitListXml(this.commits, getTags(), true).renderCommitList(this.commits);
 62  0
         }
 63  0
         return lg;
 64  
     }
 65  0
 
 66  
     private List getTags() {
 67  0
         final List tags = new ArrayList();
 68  0
         final Calendar calendar = new GregorianCalendar();
 69  0
         final Iterator it = this.config.getRepository().getSymbolicNames().iterator();
 70  0
         while (it.hasNext()) {
 71  0
             final SymbolicName tag = (SymbolicName) it.next();
 72  0
             calendar.setTime(tag.getDate());
 73  0
         }
 74  0
         Collections.reverse(tags);
 75  0
         return tags;
 76  0
     }
 77  
 }