1 21 package au.id.jericho.lib.html; 22 23 import java.util.*; 24 25 40 public class EndTagTypeGenericImplementation extends EndTagType { 41 private final String staticString; 42 43 55 protected EndTagTypeGenericImplementation(final String description, final String startDelimiter, final String closingDelimiter, final boolean isServerTag, final boolean isStatic) { 56 super(description,startDelimiter,closingDelimiter,isServerTag); 57 staticString=isStatic ? (startDelimiter+closingDelimiter) : null; 58 } 59 60 78 protected final boolean isStatic() { 79 return staticString!=null; 80 } 81 82 98 public String generateHTML(final String startTagName) { 99 return staticString!=null ? staticString : START_DELIMITER_PREFIX+startTagName+getClosingDelimiter(); 100 } 101 102 126 protected Tag constructTagAt(final Source source, final int pos) { 127 final ParseText parseText=source.getParseText(); 128 final int nameBegin=pos+START_DELIMITER_PREFIX.length(); 129 String name=null; 130 final int startDelimiterEnd=pos+getStartDelimiter().length(); 131 int end=-1; 132 if (isStatic()) { 133 name=getNamePrefix(); 134 if (!parseText.containsAt(getClosingDelimiter(),startDelimiterEnd)) { 135 if (source.isLoggingEnabled()) source.log(source.getRowColumnVector(pos).appendTo(new StringBuffer (200).append("EndTag of expected format ").append(staticString).append(" at ")).append(" not recognised as type '").append(getDescription()).append("' because it is missing the closing delimiter").toString()); 136 return null; 137 } 138 end=startDelimiterEnd+getClosingDelimiter().length(); 139 } else { 140 final int nameEnd=source.findNameEnd(startDelimiterEnd); 141 if (nameEnd==-1) return null; 142 name=parseText.substring(nameBegin,nameEnd); 143 if (!parseText.containsAt(getClosingDelimiter(),nameEnd)) { 144 if (source.isLoggingEnabled()) source.log(source.getRowColumnVector(pos).appendTo(new StringBuffer (200).append("EndTag ").append(name).append(" at ")).append(" not recognised as type '").append(getDescription()).append("' because its closing delimiter does not immediately follow its name").toString()); 145 return null; 146 } 147 end=nameEnd+getClosingDelimiter().length(); 148 } 149 return constructEndTag(source,pos,end,name); 150 } 151 } 152 | Popular Tags |