Coverage Report - net.sf.jolene.html.HTMLString
 
Classes in this File Line Coverage Branch Coverage Complexity
HTMLString
74%
20/27
50%
5/10
1.538
 
 1  
 /*
 2  
  * Created on Jan 1, 2004
 3  
 */
 4  
 package net.sf.jolene.html;
 5  
 
 6  
 import net.sf.jolene.constants.Prefs;
 7  
 
 8  
 /**
 9  
  * Some html utilites.
 10  
  *
 11  
  * @author Dan Howard
 12  
  */
 13  
 public class HTMLString {
 14  
 
 15  0
     private HTMLString() {
 16  0
     }
 17  
 
 18  
     public static String head(int n, String s) {
 19  1
         return "<h" + n + '>' + s + "</h" + n + '>';
 20  
     }
 21  
 
 22  
     public static String linebreak() {
 23  1
         if (Boolean.parseBoolean(Prefs.XHTMLStrict.getValue())) {
 24  0
             return "<br />";
 25  
         } else {
 26  1
             return "<br>";
 27  
         }
 28  
     }
 29  
 
 30  
     public static String paragraph(String s) {
 31  1
         return "<p>" + s + "</p>";
 32  
     }
 33  
 
 34  
     public static String preformat(String s) {
 35  1
         return "<pre>" + s + "</pre>";
 36  
     }
 37  
 
 38  
     public static String hr() {
 39  1
         if (Boolean.parseBoolean(Prefs.XHTMLStrict.getValue())) {
 40  0
             return "<hr />";
 41  
         } else {
 42  1
             return "<hr>";
 43  
         }
 44  
     }
 45  
 
 46  
     public static String image(String image, String alt, String align) {
 47  
         String end;
 48  1
         if (Boolean.parseBoolean(Prefs.XHTMLStrict.getValue())) {
 49  0
             end = "' />";
 50  
         } else {
 51  1
             end = "'>";
 52  
         }
 53  1
         return "<img align='" + align + "' src='" + image + "' alt='" + alt + end;
 54  
     }
 55  
 
 56  
     public static String image(String image, String alt) {
 57  
         String end;
 58  1
         if (Boolean.parseBoolean(Prefs.XHTMLStrict.getValue())) {
 59  0
             end = "' />";
 60  
         } else {
 61  1
             end = "'>";
 62  
         }
 63  1
         return "<img src='" + image + "' alt='" + alt + end;
 64  
     }
 65  
 
 66  
     public static String image(String image) {
 67  
         String end;
 68  1
         if (Boolean.parseBoolean(Prefs.XHTMLStrict.getValue())) {
 69  0
             end = "' />";
 70  
         } else {
 71  1
             end = "'>";
 72  
         }
 73  1
         return "<img src='" + image + end;
 74  
     }
 75  
 
 76  
 
 77  
     public static String link(String url, String text) {
 78  1
         return "<a href='" + url + "'>" + text + "</a>";
 79  
     }
 80  
 
 81  
     public static String link(String url, String text, String image) {
 82  1
         return "<a href='" + url + "'>" + text + "<img src='" + image + "'></a>";
 83  
     }
 84  
 
 85  
 // TODO the List method should use recursion....
 86  
 //        public String List(String[] aList, boolean ordered) {
 87  
 //                String s = "";
 88  
 //                String ls = System.getProperty("line.separator");
 89  
 //                
 90  
 //                if (ordered) {
 91  
 //                        s = "<OL>" + ls;
 92  
 //                }
 93  
 //                else {
 94  
 //                        s = "<UL>" + ls;
 95  
 //                }
 96  
 //                
 97  
 //                for (int j=0; j < aList.length; j++) {
 98  
 //                        
 99  
 //                }
 100  
 //                return s;
 101  
 //        }
 102  
 
 103  
     public static String bold(String s) {
 104  1
         return "<b>" + s + "</b>";
 105  
     }
 106  
 
 107  
     public static String italics(String s) {
 108  1
         return "<i>" + s + "</i>";
 109  
     }
 110  
 
 111  
 }