1 15 package org.apache.tapestry.html; 16 17 import org.apache.tapestry.IMarkupWriter; 18 19 24 25 public abstract class InsertTextMode 26 { 27 30 31 public static final InsertTextMode BREAK = new BreakMode(); 32 33 36 37 public static final InsertTextMode PARAGRAPH = new ParagraphMode(); 38 39 private final String _name; 40 41 protected InsertTextMode(String name) 42 { 43 _name = name; 44 } 45 46 public String toString() 47 { 48 return "InsertTextMode[" + _name + "]"; 49 } 50 51 63 64 public abstract void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw); 65 66 private static class BreakMode extends InsertTextMode 67 { 68 private BreakMode() 69 { 70 super("BREAK"); 71 } 72 73 public void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw) 74 { 75 if (lineNumber > 0) 76 writer.beginEmpty("br"); 77 78 writer.print(line, raw); 79 } 80 } 81 82 private static class ParagraphMode extends InsertTextMode 83 { 84 private ParagraphMode() 85 { 86 super("PARAGRAPH"); 87 } 88 89 public void writeLine(int lineNumber, String line, IMarkupWriter writer, boolean raw) 90 { 91 writer.begin("p"); 92 93 writer.print(line, raw); 94 95 writer.end(); 96 } 97 } 98 99 } | Popular Tags |