package lq; import java.io.Writer; import java.io.PrintWriter; public class Printer { private final PrintWriter out; public Printer(Writer out) { this.out = new PrintWriter(out); } public void printQuote(Quote quote) { out.println("
"); out.println("" + "#" + quote.getId() + ""+ ", lagt til av " + Strings.escape(quote.getAuthor()) + "
"); String score = quote.getScore().toString(); String date = DateUtil.dateFormat.format(quote.getQuoteDate()); out.println("Dato: " + date + ", Score: "); out.println(""); out.println((score==null?"-":(score+ " (fra " + quote.getNumVotes() +")"))); out.println("
Vote: "); for(int nv=1; nv<=5; nv++) out.println(""+nv+" "); out.println("
"); out.println("

"); out.println(); String content = Strings.escape(quote.getContent()); out.println(content .replaceAll("(http://[^ \r\n]+)","$1") .replaceAll("\n","
\n")); out.println(""); out.println("
"); } }