1 23 package com.sun.enterprise.diagnostics.report.html; 24 25 import java.io.File ; 26 import java.io.FileWriter ; 27 import java.io.IOException ; 28 import java.io.Writer ; 29 30 33 public class HTMLComment implements Text { 34 35 36 39 private String text = null; 40 41 private static String COMMENT_BEGIN = "<!-- "; 42 private static String COMMENT_END = "-->"; 43 44 48 public HTMLComment(String text) { 49 setValue(text); 50 } 51 52 53 55 public String getValue() { 56 return text; 57 } 58 59 60 62 public void setValue(String text) { 63 if (text == null) { 64 throw new NullPointerException ("Comment text is null."); 65 } 66 this.text = text; 67 } 68 69 70 73 public String toString() { 74 StringBuffer buf = new StringBuffer (); 75 buf.append(COMMENT_BEGIN) 76 .append(Escape.getInstance().encodeEntities(text, "")) 77 .append(COMMENT_END); 78 return buf.toString(); 79 } 80 81 82 84 public void write(Writer output) throws IOException { 85 output.append(toString()); 86 output.flush(); 87 } 88 89 90 93 public void write(File file) throws IOException { 94 FileWriter fw = new FileWriter (file); 95 write(fw); 96 fw.close(); 97 } 98 99 } | Popular Tags |