Class ContentTypeUtils


  • public final class ContentTypeUtils
    extends java.lang.Object
    Utils for handling content type
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String fullExtension​(java.lang.String extension)  
      static java.util.Optional<java.lang.String> getContentTypeByExtension​(java.lang.String extension)
      Get the content type corresponding to an extension.
      static java.util.Optional<java.lang.String> getContentTypeByPath​(java.lang.String path)
      Get the content type corresponding to a path.
      static boolean isJsonContentType​(java.lang.String contentType)
      Check if a content type is json
      static java.lang.String removeExtension​(java.lang.String filename, java.lang.String extension)  
      static java.lang.String setExtension​(java.lang.String filename, java.lang.String extension)  
      static java.lang.String toJsonFilename​(java.lang.String filename)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CONTENT_TYPE_JSON

        public static final java.lang.String CONTENT_TYPE_JSON
      • CONTENT_TYPE_XML

        public static final java.lang.String CONTENT_TYPE_XML
      • CONTENT_TYPE_SVG

        public static final java.lang.String CONTENT_TYPE_SVG
        See Also:
        Constant Field Values
      • CONTENT_TYPE_ZIP

        public static final java.lang.String CONTENT_TYPE_ZIP
        See Also:
        Constant Field Values
      • CONTENT_TYPES

        public static final java.util.Map<java.lang.String,​java.lang.String> CONTENT_TYPES
    • Method Detail

      • getContentTypeByExtension

        public static java.util.Optional<java.lang.String> getContentTypeByExtension​(java.lang.String extension)
        Get the content type corresponding to an extension.
        Parameters:
        extension - the extension to search the content type for
        Returns:
        the content type
      • getContentTypeByPath

        public static java.util.Optional<java.lang.String> getContentTypeByPath​(java.lang.String path)
        Get the content type corresponding to a path.
        Parameters:
        path - the path to search the content type for
        Returns:
        the content type
      • isJsonContentType

        public static boolean isJsonContentType​(java.lang.String contentType)
        Check if a content type is json
        Parameters:
        contentType - the content type to check
        Returns:
        true if the the given content type is json
      • toJsonFilename

        public static java.lang.String toJsonFilename​(java.lang.String filename)
      • setExtension

        public static java.lang.String setExtension​(java.lang.String filename,
                                                    java.lang.String extension)
      • removeExtension

        public static java.lang.String removeExtension​(java.lang.String filename,
                                                       java.lang.String extension)
      • fullExtension

        public static java.lang.String fullExtension​(java.lang.String extension)