Class DataUri


  • final class DataUri
    extends java.lang.Object
    Copyright (c) 2013 ooxi ...

    This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

    Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

    1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

    2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

    3. This notice may not be removed or altered from any source distribution.

    Note: This file has been modified for usage in the JSVG project.

    • Constructor Summary

      Constructors 
      Constructor Description
      DataUri​(@NotNull java.lang.String mime, @Nullable java.nio.charset.Charset charset, @Nullable java.lang.String filename, @Nullable java.lang.String contentDisposition, byte @NotNull [] data)  
      DataUri​(java.lang.String mime, java.nio.charset.Charset charset, byte[] data)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable java.nio.charset.Charset charset()  
      @Nullable java.lang.String contentDisposition()  
      byte @NotNull [] data()  
      boolean equals​(java.lang.Object o)  
      @Nullable java.lang.String filename()  
      int hashCode()  
      @NotNull java.lang.String mime()  
      static DataUri parse​(@NotNull java.lang.String uri, java.nio.charset.Charset charset)
      Tries to parse a data URI described in RFC2397
      private static java.lang.String percentDecode​(java.lang.String s, java.nio.charset.Charset cs)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • CHARSET_OPTION_NAME

        private static final java.lang.String CHARSET_OPTION_NAME
        See Also:
        Constant Field Values
      • FILENAME_OPTION_NAME

        private static final java.lang.String FILENAME_OPTION_NAME
        See Also:
        Constant Field Values
      • CONTENT_DISPOSITION_OPTION_NAME

        private static final java.lang.String CONTENT_DISPOSITION_OPTION_NAME
        See Also:
        Constant Field Values
      • mime

        @NotNull
        private final @NotNull java.lang.String mime
      • charset

        @Nullable
        private final @Nullable java.nio.charset.Charset charset
      • filename

        @Nullable
        private final @Nullable java.lang.String filename
      • contentDisposition

        @Nullable
        private final @Nullable java.lang.String contentDisposition
      • data

        private final byte @NotNull [] data
      • PLUS

        private static final java.util.regex.Pattern PLUS
    • Constructor Detail

      • DataUri

        public DataUri​(java.lang.String mime,
                       java.nio.charset.Charset charset,
                       byte[] data)
      • DataUri

        public DataUri​(@NotNull
                       @NotNull java.lang.String mime,
                       @Nullable
                       @Nullable java.nio.charset.Charset charset,
                       @Nullable
                       @Nullable java.lang.String filename,
                       @Nullable
                       @Nullable java.lang.String contentDisposition,
                       byte @NotNull [] data)
    • Method Detail

      • mime

        @NotNull
        public @NotNull java.lang.String mime()
      • data

        public byte @NotNull [] data()
      • charset

        @Nullable
        public @Nullable java.nio.charset.Charset charset()
      • contentDisposition

        @Nullable
        public @Nullable java.lang.String contentDisposition()
      • filename

        @Nullable
        public @Nullable java.lang.String filename()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parse

        public static DataUri parse​(@NotNull
                                    @NotNull java.lang.String uri,
                                    java.nio.charset.Charset charset)
                             throws DataUri.MalformedDataUriException
        Tries to parse a data URI described in RFC2397
        Parameters:
        uri - A string representing the data URI
        charset - Charset to use when decoding percent encoded options like filename
        Returns:
        Parsed data URI
        Throws:
        java.lang.IllegalArgumentException - iff an error occurred during parse process
        DataUri.MalformedDataUriException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • percentDecode

        private static java.lang.String percentDecode​(java.lang.String s,
                                                      java.nio.charset.Charset cs)