1 25 package org.snipsnap.render.macro.list; 26 27 import java.io.IOException ; 28 import java.io.Writer ; 29 import java.util.Collection ; 30 import java.util.Iterator ; 31 32 38 public class SimpleList implements ListFormatter { 39 public String getName() { 40 return "simple"; 41 } 42 43 44 public void format(Writer writer, Linkable current, String listComment, Collection c, String emptyText, boolean showSize) 45 throws IOException { 46 writer.write("<div class=\"list\"><div class=\"list-title\">"); 47 writer.write(listComment); 48 if (showSize) { 49 writer.write(" ("); 50 writer.write("" + c.size()); 51 writer.write(")"); 52 } 53 writer.write("</div>"); 54 if (c.size() > 0) { 55 writer.write("<blockquote>"); 56 Iterator nameIterator = c.iterator(); 57 while (nameIterator.hasNext()) { 58 Object object = nameIterator.next(); 59 if (object instanceof Linkable) { 60 writer.write(((Linkable) object).getLink()); 61 } else if (object instanceof Nameable) { 62 writer.write(((Nameable) object).getName()); 63 } else { 64 writer.write(object.toString()); 65 } 66 67 if (nameIterator.hasNext()) { 68 writer.write(", "); 69 } 70 } 71 writer.write("</blockquote>"); 72 } else { 73 writer.write(emptyText); 74 } 75 writer.write("</div>"); 76 } 77 } 78 | Popular Tags |