1 5 6 package org.w3c.tidy; 7 8 33 34 public class AttrCheckImpl { 35 36 public static class CheckUrl implements AttrCheck { 37 38 public void check( Lexer lexer, Node node, AttVal attval) 39 { 40 if (attval.value == null) 41 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE); 42 else if (lexer.configuration.FixBackslash) 43 { 44 attval.value = attval.value.replace('\\','/'); 45 } 46 } 47 48 }; 49 50 public static class CheckScript implements AttrCheck { 51 52 public void check( Lexer lexer, Node node, AttVal attval) 53 { 54 } 55 56 }; 57 58 public static class CheckAlign implements AttrCheck { 59 60 public void check( Lexer lexer, Node node, AttVal attval) 61 { 62 String value; 63 64 65 if (node.tag != null && ((node.tag.model & Dict.CM_IMG) != 0)) 66 { 67 getCheckValign().check(lexer, node, attval); 68 return; 69 } 70 71 value = attval.value; 72 73 if (value == null) 74 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE); 75 else if (! (Lexer.wstrcasecmp(value, "left") == 0 || 76 Lexer.wstrcasecmp(value, "center") == 0 || 77 Lexer.wstrcasecmp(value, "right") == 0 || 78 Lexer.wstrcasecmp(value, "justify") == 0)) 79 Report.attrError(lexer, node, attval.value, Report.BAD_ATTRIBUTE_VALUE); 80 } 81 82 }; 83 84 public static class CheckValign implements AttrCheck { 85 86 public void check( Lexer lexer, Node node, AttVal attval) 87 { 88 String value; 89 90 value = attval.value; 91 92 if (value == null) 93 Report.attrError(lexer, node, attval.attribute, Report.MISSING_ATTR_VALUE); 94 else if (Lexer.wstrcasecmp(value, "top") == 0 || 95 Lexer.wstrcasecmp(value, "middle") == 0 || 96 Lexer.wstrcasecmp(value, "bottom") == 0 || 97 Lexer.wstrcasecmp(value, "baseline") == 0) 98 { 99 100 } 101 else if (Lexer.wstrcasecmp(value, "left") == 0 || 102 Lexer.wstrcasecmp(value, "right") == 0) 103 { 104 if (!(node.tag != null && ((node.tag.model & Dict.CM_IMG) != 0))) 105 Report.attrError(lexer, node, value, Report.BAD_ATTRIBUTE_VALUE); 106 } 107 else if (Lexer.wstrcasecmp(value, "texttop") == 0 || 108 Lexer.wstrcasecmp(value, "absmiddle") == 0 || 109 Lexer.wstrcasecmp(value, "absbottom") == 0 || 110 Lexer.wstrcasecmp(value, "textbottom") == 0) 111 { 112 lexer.versions &= Dict.VERS_PROPRIETARY; 113 Report.attrError(lexer, node, value, Report.PROPRIETARY_ATTR_VALUE); 114 } 115 else 116 Report.attrError(lexer, node, value, Report.BAD_ATTRIBUTE_VALUE); 117 } 118 119 }; 120 121 public static class CheckBool implements AttrCheck { 122 123 public void check( Lexer lexer, Node node, AttVal attval) 124 { 125 } 126 127 }; 128 129 public static class CheckId implements AttrCheck { 130 131 public void check( Lexer lexer, Node node, AttVal attval) 132 { 133 } 134 135 }; 136 137 public static class CheckName implements AttrCheck { 138 139 public void check( Lexer lexer, Node node, AttVal attval) 140 { 141 } 142 143 }; 144 145 public static AttrCheck getCheckUrl() 146 { 147 return _checkUrl; 148 } 149 150 public static AttrCheck getCheckScript() 151 { 152 return _checkScript; 153 } 154 155 public static AttrCheck getCheckAlign() 156 { 157 return _checkAlign; 158 } 159 160 public static AttrCheck getCheckValign() 161 { 162 return _checkValign; 163 } 164 165 public static AttrCheck getCheckBool() 166 { 167 return _checkBool; 168 } 169 170 public static AttrCheck getCheckId() 171 { 172 return _checkId; 173 } 174 175 public static AttrCheck getCheckName() 176 { 177 return _checkName; 178 } 179 180 181 private static AttrCheck _checkUrl = new CheckUrl(); 182 private static AttrCheck _checkScript = new CheckScript(); 183 private static AttrCheck _checkAlign = new CheckAlign(); 184 private static AttrCheck _checkValign = new CheckValign(); 185 private static AttrCheck _checkBool = new CheckBool(); 186 private static AttrCheck _checkId = new CheckId(); 187 private static AttrCheck _checkName = new CheckName(); 188 189 } 190 | Popular Tags |