| 1 |  |  | 
            
  
    | 2 |  |  | 
            
  
    | 3 |  |  | 
            
  
    | 4 |  |  | 
            
  
    | 5 |  |  | 
            
  
    | 6 |  |  | 
            
  
    | 7 |  |  | 
            
  
    | 8 |  |  | 
            
  
    | 9 |  |  | 
            
  
    | 10 |  |  | 
            
  
    | 11 |  |  | 
            
  
    | 12 |  |  | 
            
  
    | 13 |  |  | 
            
  
    | 14 |  |  | 
            
  
    | 15 |  |  | 
            
  
    | 16 |  | package org.kuali.student.contract.writer; | 
            
  
    | 17 |  |  | 
            
  
    | 18 |  | import java.io.ByteArrayOutputStream; | 
            
  
    | 19 |  | import java.io.File; | 
            
  
    | 20 |  | import java.io.FileNotFoundException; | 
            
  
    | 21 |  | import java.io.FileOutputStream; | 
            
  
    | 22 |  | import java.io.PrintStream; | 
            
  
    | 23 |  | import java.util.List; | 
            
  
    | 24 |  |  | 
            
  
    | 25 |  | import org.kuali.student.contract.exception.DictionaryExecutionException; | 
            
  
    | 26 |  |  | 
            
  
    | 27 |  |  | 
            
  
    | 28 |  |  | 
            
  
    | 29 |  | @author | 
            
  
    | 30 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 51 (51) | Complexity: 10 | Complexity Density: 0.25 |  | 
  
  
    | 31 |  | public class HtmlWriter extends XmlWriter { | 
            
  
    | 32 |  |  | 
            
  
    | 33 |  | private String directory; | 
            
  
    | 34 |  | private String fileName; | 
            
  
    | 35 |  | private String title; | 
            
  
    | 36 |  | private ByteArrayOutputStream body; | 
            
  
    | 37 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 7 (7) | Complexity: 1 | Complexity Density: 0.14 |  | 
  
  
    | 38 | 0 |  public HtmlWriter(String directory, String fileName, String title) {... | 
            
  
    | 39 | 0 | super(); | 
            
  
    | 40 | 0 | this.body = new ByteArrayOutputStream(1000); | 
            
  
    | 41 | 0 | this.setOut(new PrintStream(body)); | 
            
  
    | 42 | 0 | this.setIndent(0); | 
            
  
    | 43 | 0 | this.directory = directory; | 
            
  
    | 44 | 0 | this.fileName = fileName; | 
            
  
    | 45 | 0 | this.title = title; | 
            
  
    | 46 |  | } | 
            
  
    | 47 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 48 | 0 |  public ByteArrayOutputStream getBody() {... | 
            
  
    | 49 | 0 | return body; | 
            
  
    | 50 |  | } | 
            
  
    | 51 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 52 | 0 |  public String getDirectory() {... | 
            
  
    | 53 | 0 | return directory; | 
            
  
    | 54 |  | } | 
            
  
    | 55 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 1 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
  
    | 56 | 0 |  public String getFileName() {... | 
            
  
    | 57 | 0 | return fileName; | 
            
  
    | 58 |  | } | 
            
  
    | 59 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 5 (5) | Complexity: 1 | Complexity Density: 0.2 |  | 
  
  
    | 60 | 0 |  public void writeHeader() {... | 
            
  
    | 61 | 0 | indentPrintln("<html>"); | 
            
  
    | 62 | 0 | indentPrintln("<head>"); | 
            
  
    | 63 | 0 | this.writeTag("title", title); | 
            
  
    | 64 | 0 | indentPrintln("</head>"); | 
            
  
    | 65 | 0 | indentPrintln("<body bgcolor=\"#ffffff\" topmargin=0 marginheight=0>"); | 
            
  
    | 66 |  | } | 
            
  
    | 67 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 17 (17) | Complexity: 4 | Complexity Density: 0.31 |  | 
  
  
    | 68 | 0 |  public void writeHeaderBodyAndFooterOutToFile() {... | 
            
  
    | 69 |  |  | 
            
  
    | 70 | 0 | File dir = new File(this.directory); | 
            
  
    | 71 |  |  | 
            
  
    | 72 |  |  | 
            
  
    | 73 | 0 | if (!dir.exists()) { | 
            
  
    | 74 | 0 | if (!dir.mkdirs()) { | 
            
  
    | 75 | 0 | throw new DictionaryExecutionException("Could not create directory " | 
            
  
    | 76 |  | + this.directory); | 
            
  
    | 77 |  | } | 
            
  
    | 78 |  | } | 
            
  
    | 79 | 0 | try { | 
            
  
    | 80 | 0 | PrintStream out = new PrintStream(new FileOutputStream(this.directory + "/" + fileName, false)); | 
            
  
    | 81 | 0 | this.setOut(out); | 
            
  
    | 82 |  | } catch (FileNotFoundException ex) { | 
            
  
    | 83 | 0 | throw new DictionaryExecutionException(ex); | 
            
  
    | 84 |  | } | 
            
  
    | 85 | 0 | writeHeader(); | 
            
  
    | 86 | 0 | indentPrintln(body.toString()); | 
            
  
    | 87 | 0 | indentPrintln("</body>"); | 
            
  
    | 88 | 0 | decrementIndent(); | 
            
  
    | 89 | 0 | indentPrintln("</html>"); | 
            
  
    | 90 |  | } | 
            
  
    | 91 |  |  | 
               
        |  |  | 
           
           |  | 0% | Uncovered Elements: 12 (12) | Complexity: 1 | Complexity Density: 0.08 |  | 
  
  
    | 92 | 0 |  public void writeTable(List<String> headers, List<List<String>> rows) {... | 
            
  
    | 93 | 0 | this.indentPrintln("<table>"); | 
            
  
    | 94 | 0 | incrementIndent(); | 
            
  
    | 95 | 0 | this.indentPrintln("<tr>"); | 
            
  
    | 96 | 0 | for (String header : headers) { | 
            
  
    | 97 | 0 | this.writeTag("th", header); | 
            
  
    | 98 |  | } | 
            
  
    | 99 | 0 | this.indentPrintln("</tr>"); | 
            
  
    | 100 | 0 | for (List<String> row : rows) { | 
            
  
    | 101 | 0 | this.indentPrintln("<tr>"); | 
            
  
    | 102 | 0 | for (String cell : row) { | 
            
  
    | 103 | 0 | this.writeTag("td", cell); | 
            
  
    | 104 |  | } | 
            
  
    | 105 | 0 | this.indentPrintln("</tr>"); | 
            
  
    | 106 |  | } | 
            
  
    | 107 | 0 | this.indentPrintln("</table>"); | 
            
  
    | 108 |  | } | 
            
  
    | 109 |  | } |