1 18 package org.apache.batik.css.parser; 19 20 import java.io.IOException ; 21 import java.io.StringReader ; 22 import java.util.Locale ; 23 import java.util.StringTokenizer ; 24 25 import org.w3c.css.sac.CSSException; 26 import org.w3c.css.sac.ConditionFactory; 27 import org.w3c.css.sac.DocumentHandler; 28 import org.w3c.css.sac.ErrorHandler; 29 import org.w3c.css.sac.InputSource; 30 import org.w3c.css.sac.LexicalUnit; 31 import org.w3c.css.sac.Parser; 32 import org.w3c.css.sac.SACMediaList; 33 import org.w3c.css.sac.SelectorFactory; 34 import org.w3c.css.sac.SelectorList; 35 36 43 public class ExtendedParserWrapper implements ExtendedParser { 44 45 53 public static ExtendedParser wrap(Parser p) { 54 if (p instanceof ExtendedParser) 55 return (ExtendedParser)p; 56 57 return new ExtendedParserWrapper(p); 58 } 59 60 61 public Parser parser; 62 63 public ExtendedParserWrapper(Parser parser) { 64 this.parser = parser; 65 } 66 67 70 public String getParserVersion() { 71 return parser.getParserVersion(); 72 } 73 74 77 public void setLocale(Locale locale) throws CSSException { 78 parser.setLocale(locale); 79 } 80 81 85 public void setDocumentHandler(DocumentHandler handler) { 86 parser.setDocumentHandler(handler); 87 } 88 89 93 public void setSelectorFactory(SelectorFactory selectorFactory) { 94 parser.setSelectorFactory(selectorFactory); 95 } 96 97 101 public void setConditionFactory(ConditionFactory conditionFactory) { 102 parser.setConditionFactory(conditionFactory); 103 } 104 105 109 public void setErrorHandler(ErrorHandler handler) { 110 parser.setErrorHandler(handler); 111 } 112 113 117 public void parseStyleSheet(InputSource source) 118 throws CSSException, IOException { 119 parser.parseStyleSheet(source); 120 } 121 122 143 public void parseStyleSheet(String uri) throws CSSException, IOException { 144 parser.parseStyleSheet(uri); 145 } 146 147 151 public void parseStyleDeclaration(InputSource source) 152 throws CSSException, IOException { 153 parser.parseStyleDeclaration(source); 154 } 155 156 166 public void parseStyleDeclaration(String source) 167 throws CSSException, IOException { 168 parser.parseStyleDeclaration 169 (new InputSource(new StringReader (source))); 170 } 171 172 173 176 public void parseRule(InputSource source) 177 throws CSSException, IOException { 178 parser.parseRule(source); 179 } 180 181 190 public void parseRule(String source) throws CSSException, IOException { 191 parser.parseRule(new InputSource(new StringReader (source))); 192 } 193 194 197 public SelectorList parseSelectors(InputSource source) 198 throws CSSException, IOException { 199 return parser.parseSelectors(source); 200 } 201 202 212 public SelectorList parseSelectors(String source) 213 throws CSSException, IOException { 214 return parser.parseSelectors 215 (new InputSource(new StringReader (source))); 216 } 217 218 219 223 public LexicalUnit parsePropertyValue(InputSource source) 224 throws CSSException, IOException { 225 return parser.parsePropertyValue(source); 226 } 227 228 238 public LexicalUnit parsePropertyValue(String source) 239 throws CSSException, IOException { 240 return parser.parsePropertyValue 241 (new InputSource(new StringReader (source))); 242 } 243 244 245 249 public boolean parsePriority(InputSource source) 250 throws CSSException, IOException { 251 return parser.parsePriority(source); 252 } 253 254 257 public SACMediaList parseMedia(String mediaText) 258 throws CSSException, IOException { 259 CSSSACMediaList result = new CSSSACMediaList(); 260 if (!"all".equalsIgnoreCase(mediaText)) { 261 StringTokenizer st = new StringTokenizer (mediaText, " ,"); 262 while (st.hasMoreTokens()) { 263 result.append(st.nextToken()); 264 } 265 } 266 return result; 267 } 268 269 279 public boolean parsePriority(String source) 280 throws CSSException, IOException { 281 return parser.parsePriority(new InputSource(new StringReader (source))); 282 } 283 } 284 | Popular Tags |