@Nonnull public CSSReaderSettings getClone () { return new CSSReaderSettings (this); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Read the CSS from the passed String using a character stream. An eventually * contained <code>@charset</code> rule is ignored. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. * @since 3.7.3 */ @Nullable public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion) { return readFromStringReader (sCSS, new CSSReaderSettings ().setCSSVersion (eVersion)); }
/** * Read the CSS from the passed File. * * @param aFile * The file containing the CSS to be parsed. May not be * <code>null</code>. * @param aFallbackCharset * The charset to be used in case neither a <code>@charset</code> rule * nor a BOM is present. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CascadingStyleSheet readFromFile (@Nonnull final File aFile, @Nonnull final Charset aFallbackCharset, @Nonnull final ECSSVersion eVersion) { return readFromFile (aFile, new CSSReaderSettings ().setFallbackCharset (aFallbackCharset).setCSSVersion (eVersion)); }
/** * Read the CSS from the passed String using a byte stream. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param aFallbackCharset * The charset to be used in case neither a <code>@charset</code> rule * nor a BOM is present. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final Charset aFallbackCharset, @Nonnull final ECSSVersion eVersion) { return readFromStringStream (sCSS, new CSSReaderSettings ().setFallbackCharset (aFallbackCharset) .setCSSVersion (eVersion)); }
/** * Read the CSS from the passed String using a character stream. An eventually * contained <code>@charset</code> rule is ignored. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomExceptionHandler * An optional custom exception handler that can be used to collect the * unrecoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. * @since 3.7.3 */ @Nullable public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromStringReader (sCSS, new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Read the CSS from the passed {@link IHasInputStream}. If the CSS contains * an explicit charset, the whole CSS is parsed again, with the charset found * inside the file, so the passed {@link IHasInputStream} must be able to * create a new input stream on second invocation! * * @param aISP * The input stream provider to use. Must be able to create new input * streams on every invocation, in case an explicit charset node was * found. May not be <code>null</code>. * @param aFallbackCharset * The charset to be used in case neither a <code>@charset</code> rule * nor a BOM is present. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CascadingStyleSheet readFromStream (@Nonnull final IHasInputStream aISP, @Nonnull final Charset aFallbackCharset, @Nonnull final ECSSVersion eVersion) { return readFromStream (aISP, new CSSReaderSettings ().setFallbackCharset (aFallbackCharset).setCSSVersion (eVersion)); }
/** * Read the CSS from the passed String using a character stream. An eventually * contained <code>@charset</code> rule is ignored. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomErrorHandler * An optional custom error handler that can be used to collect the * recoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. * @since 3.7.3 */ @Nullable public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromStringReader (sCSS, new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion)); }
private void parseCSS(String css, URL baseUrl, Set<URL> resourceUrls) { logger.verbose("enter"); final CascadingStyleSheet cascadingStyleSheet = CSSReader.readFromString(css, ECSSVersion.CSS30); if (cascadingStyleSheet == null) { logger.verbose("exit - failed to read CSS string"); return; } collectAllImportUris(cascadingStyleSheet, resourceUrls, baseUrl); collectAllFontFaceUris(cascadingStyleSheet, resourceUrls, baseUrl); collectAllBackgroundImageUris(cascadingStyleSheet, resourceUrls, baseUrl); logger.verbose("exit"); }
/** * Read the CSS from the passed String using a byte stream. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param aSettings * The settings to be used for reading the CSS. May not be * <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. * @since 3.8.2 */ @Nullable public static CascadingStyleSheet readFromStringStream (@Nonnull final String sCSS, @Nonnull final CSSReaderSettings aSettings) { return readFromStream (new StringInputStreamProvider (sCSS, aSettings.getFallbackCharset ()), aSettings); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler) .setCustomExceptionHandler (aCustomExceptionHandler)); }
/** * Read the CSS from the passed File. * * @param aFile * The file containing the CSS to be parsed. May not be * <code>null</code>. * @param aFallbackCharset * The charset to be used in case neither a <code>@charset</code> rule * nor a BOM is present. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomErrorHandler * An optional custom error handler that can be used to collect the * recoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CascadingStyleSheet readFromFile (@Nonnull final File aFile, @Nonnull final Charset aFallbackCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromFile (aFile, new CSSReaderSettings ().setFallbackCharset (aFallbackCharset) .setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }
/** * Read the CSS from the passed String using a byte stream. * * @param sCSS * The source string containing the CSS to be parsed. May not be * <code>null</code>. * @param aFallbackCharset * The charset to be used in case neither a <code>@charset</code> rule * nor a BOM is present. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @param aCustomExceptionHandler * An optional custom exception handler that can be used to collect the * unrecoverable parsing errors. May be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CascadingStyleSheet readFromString (@Nonnull final String sCSS, @Nonnull final Charset aFallbackCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromStringStream (sCSS, new CSSReaderSettings ().setFallbackCharset (aFallbackCharset) .setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion)); }
@Nullable public static CSSDeclarationList readFromString (@Nonnull final String sCSS, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromReader (new NonBlockingStringReader (sCSS), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }
/** * Read the CSS from the passed {@link Reader}. * * @param aReader * The reader to use. Will be closed automatically after reading - * independent of success or error. May not be <code>null</code>. * @param eVersion * The CSS version to use. May not be <code>null</code>. * @return <code>null</code> if reading failed, the CSS declarations * otherwise. */ @Nullable public static CSSDeclarationList readFromReader (@Nonnull @WillClose final Reader aReader, @Nonnull final ECSSVersion eVersion) { return readFromReader (aReader, new CSSReaderSettings ().setCSSVersion (eVersion)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler) .setCustomExceptionHandler (aCustomExceptionHandler)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseExceptionCallback aCustomExceptionHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomExceptionHandler (aCustomExceptionHandler)); }
@Nullable public static CSSDeclarationList readFromFile (@Nonnull final File aFile, @Nonnull final Charset aCharset, @Nonnull final ECSSVersion eVersion, @Nullable final ICSSParseErrorHandler aCustomErrorHandler) { return readFromReader (new FileSystemResource (aFile).getReader (aCharset), new CSSReaderSettings ().setCSSVersion (eVersion) .setCustomErrorHandler (aCustomErrorHandler)); }