1 14 package org.wings.template; 15 16 import org.wings.io.Device; 17 import org.wings.template.parser.ParseContext; 18 import org.wings.template.parser.PositionReader; 19 import org.wings.template.parser.SGMLTag; 20 21 import java.io.IOException ; 22 import java.io.InputStream ; 23 24 30 public class RangeTagHandler extends TemplateTagHandler { 31 boolean close_is_missing = false; 32 33 41 public SGMLTag parseTag(ParseContext context, 42 PositionReader input, 43 long startPosition, 44 SGMLTag startTag) 45 throws IOException { 46 final String startTagName = startTag.getName(); 47 final String endTagName = "/" + startTagName; 48 49 55 startTag.parse(input); 56 57 63 startPos = startPosition + startTag.getOffset(); 64 65 68 properties = startTag.getAttributes(); 69 70 name = startTag.value("NAME", null); 71 if (name == null) 72 return null; 73 74 endPos = input.getPosition(); 76 while (!startTag.finished()) { 77 startTag = new SGMLTag(input, true); 78 if (startTag.isNamed(endTagName) || startTag.isNamed(startTagName)) 79 break; 80 } 81 82 if (startTag.finished() || startTag.isNamed(startTagName)) { 84 close_is_missing = true; 85 } else { 86 endPos = input.getPosition(); 88 } 89 90 properties.remove("NAME"); 92 properties.remove("TYPE"); 93 94 return startTag; 95 } 96 97 103 public void executeTag(ParseContext context, InputStream input) 104 throws Exception { 105 super.executeTag(context, input); 106 107 if (close_is_missing) { 109 TemplateParseContext tcontext = (TemplateParseContext) context; 110 Device sink = tcontext.getDevice(); 111 sink.print("<table bgcolor='#FFAA55'><tr><td>"); 112 sink.print(" <blink><b>"); 113 sink.print("closing tag missing"); 114 sink.print(" for '<em>" + name + "</em>'"); 115 sink.print("</b></blink> "); 116 sink.print("</td></tr></table>"); 117 } 118 } 119 } 120 121 122 | Popular Tags |