public static NetworkProcessor getNetworkProcessor() { if (networkProcessor == null) { networkProcessor = new DefaultNetworkProcessor(); } return networkProcessor; }
@Override public InputStream fetch(URL url) throws IOException { try { if (url != null) { Source resolved = resolver.resolve(url.toString(), ""); if (resolved != null) { if (resolved instanceof StreamSource) return ((StreamSource)resolved).getInputStream(); else url = new URL(resolved.getSystemId()); } } } catch (TransformerException e) { } catch (MalformedURLException e) { } return super.fetch(url); } };
url = new URL(resolved.getSystemId()); logger.debug("Resolved to :" + url); } is = super.fetch(url); }}
public static NetworkProcessor getNetworkProcessor() { if (networkProcessor == null) { networkProcessor = new DefaultNetworkProcessor(); } return networkProcessor; }
/** * Parses text into a StyleSheet * * @param css * Text with CSS declarations * @param base * The URL to be used as a base for loading external resources. Base URL may * be {@code null} if there are no external resources in the CSS string * referenced by relative URLs. * @return Parsed StyleSheet * @throws IOException * When exception during read occurs * @throws CSSException * When exception during parse occurs */ public static final StyleSheet parseString(String css, URL base) throws IOException, CSSException { return parseString(css, base, new DefaultNetworkProcessor()); }
/** * This is the same as {@link CSSFactory#getUsedStyles(Document, String, URL, MediaSpec)} with * the possibility of specifying a custom network processor. * * @param doc * DOM tree * @param encoding * The default encoding used for the referenced style sheets * @param base * Base URL against which all files are searched * @param media * Selected media for style sheet * @param network * The network processor used for accessing the URL resources * @return the rules of all the style sheets used in the document including the inline styles */ public static final StyleSheet getUsedStyles(Document doc, String encoding, URL base, MediaSpec media) { return getUsedStyles(doc, encoding, base, media, new DefaultNetworkProcessor()); }
URL base, MediaSpec media, boolean useInheritance, final MatchCondition matchCond) { return assignDOM(doc, encoding, new DefaultNetworkProcessor(), base, media, useInheritance, matchCond);
/** * Parses text into StyleSheet * * @param css * Text with CSS declarations * @return Parsed StyleSheet * @throws IOException * When exception during read occurs * @throws CSSException * When exception during parse occurs * @deprecated * This function does not specify the base URL. {@link #parseString(String, URL)} * should be used instead. */ @Deprecated public static final StyleSheet parse(String css) throws IOException, CSSException { URL base = new URL("file:///base/url/is/not/specified"); //Cannot determine the base URI in this method but we need some base URI for relative URLs return getCSSParserFactory().parse(css, new DefaultNetworkProcessor(), null, SourceType.EMBEDDED, base); }
/** * Parses URL into StyleSheet * * @param url * URL of file to be parsed * @param encoding * Encoding of file * @return Parsed StyleSheet * @throws CSSException * When exception during parse occurs * @throws IOException * When file not found */ public static final StyleSheet parse(URL url, String encoding) throws CSSException, IOException { return getCSSParserFactory().parse((Object) url, new DefaultNetworkProcessor(), encoding, SourceType.URL, url); }
/** * This is the same as {@link CSSFactory#getUsedStyles(Document, String, URL, MediaSpec)} but only the * media type is provided instead of the complete media specification. * * @param doc * DOM tree * @param encoding * The default encoding used for the referenced style sheets * @param base * Base URL against which all files are searched * @param media * Selected media for style sheet * @return the rules of all the style sheets used in the document including the inline styles */ public static final StyleSheet getUsedStyles(Document doc, String encoding, URL base, String media) { return getUsedStyles(doc, encoding, base, new MediaSpec(media), new DefaultNetworkProcessor()); }