Class CSSDataURLHelper


  • @Immutable
    public final class CSSDataURLHelper
    extends Object
    Provides data URL handling sanity methods (RFC 2397).
    Author:
    Philip Helger
    • Field Detail

      • DEFAULT_CHARSET

        public static final Charset DEFAULT_CHARSET
        The default charset to be used for Data URLs: US-ASCII
      • DEFAULT_MIME_TYPE

        public static final com.helger.commons.mime.IMimeType DEFAULT_MIME_TYPE
        The default MIME type for Data URLs: text/plain;charset=US-ASCII
      • SEPARATOR_CONTENT

        public static final char SEPARATOR_CONTENT
        The separator that starts the content
        See Also:
        Constant Field Values
      • MIME_QUOTING

        public static final com.helger.commons.mime.EMimeQuoting MIME_QUOTING
        Data URLs should use the URL code to quote values!
    • Method Detail

      • isDataURL

        public static boolean isDataURL​(@Nullable
                                        String sURL)
        Check if the passed URL is a data URL. It is checked, whether the passed URL starts with "data:" (after trimming, case insensitive).
        Parameters:
        sURL - The URL to check. May be null.
        Returns:
        true if the passed URL is a data URL, false if not.
      • parseDataURL

        @Nullable
        public static CSSDataURL parseDataURL​(@Nullable
                                              String sDataURL)
        Parse a data URL into this type.
         Syntax
           dataurl    := "data:" [ mediatype ] [ ";base64" ] "," data
           mediatype  := [ type "/" subtype ] *( ";" parameter )
           data       := *urlchar
           parameter  := attribute "=" value
         
        Parameters:
        sDataURL - The data URL to be parsed. May be null.
        Returns:
        null if parsing failed