public CssTree.StyleSheet parseDom(String content, Uri source) throws GadgetException { CssTree.StyleSheet parsedCss = null; boolean shouldCache = shouldCache(); String key = null; if (shouldCache) { // TODO - Consider using the source if its under a certain size key = HashUtil.checksum(content.getBytes()); parsedCss = parsedCssCache.getElement(key); } if (parsedCss == null) { try { parsedCss = parseImpl(content, source); if (shouldCache) { parsedCssCache.addElement(key, parsedCss); } } catch (ParseException pe) { // Bad input; not server's fault. throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe, HttpResponse.SC_BAD_REQUEST); } } if (shouldCache) { return (CssTree.StyleSheet)parsedCss.clone(); } return parsedCss; }
public CssTree.StyleSheet parseDom(String content, Uri source) throws GadgetException { CssTree.StyleSheet parsedCss = null; boolean shouldCache = shouldCache(); String key = null; if (shouldCache) { // TODO - Consider using the source if its under a certain size key = HashUtil.checksum(content.getBytes()); parsedCss = parsedCssCache.getElement(key); } if (parsedCss == null) { try { parsedCss = parseImpl(content, source); if (shouldCache) { parsedCssCache.addElement(key, parsedCss); } } catch (ParseException pe) { // Bad input; not server's fault. throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe, HttpResponse.SC_BAD_REQUEST); } } if (shouldCache) { return (CssTree.StyleSheet)parsedCss.clone(); } return parsedCss; }
public CssTree.StyleSheet parseDom(String content, Uri source) throws GadgetException { CssTree.StyleSheet parsedCss = null; boolean shouldCache = shouldCache(); String key = null; if (shouldCache) { // TODO - Consider using the source if its under a certain size key = HashUtil.checksum(content.getBytes()); parsedCss = parsedCssCache.getElement(key); } if (parsedCss == null) { try { parsedCss = parseImpl(content, source); if (shouldCache) { parsedCssCache.addElement(key, parsedCss); } } catch (ParseException pe) { // Bad input; not server's fault. throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe, HttpResponse.SC_BAD_REQUEST); } } if (shouldCache) { return (CssTree.StyleSheet)parsedCss.clone(); } return parsedCss; }