org.springframework.boot.web.server

Class MimeMappings

  • java.lang.Object
    • org.springframework.boot.web.server.MimeMappings
  • All Implemented Interfaces:
    java.lang.Iterable<MimeMappings.Mapping>


    public final class MimeMappings
    extends java.lang.Object
    implements java.lang.Iterable<MimeMappings.Mapping>
    Simple server-independent abstraction for mime mappings. Roughly equivalent to the &lt;mime-mapping&gt; element traditionally found in web.xml.
    Since:
    2.0.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  MimeMappings.Mapping
      A single mime mapping.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static MimeMappings DEFAULT
      Default mime mapping commonly used.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String add(java.lang.String extension, java.lang.String mimeType)
      Add a new mime mapping.
      boolean equals(java.lang.Object obj) 
      java.lang.String get(java.lang.String extension)
      Get a mime mapping for the given extension.
      java.util.Collection<MimeMappings.Mapping> getAll()
      Returns all defined mappings.
      int hashCode() 
      java.util.Iterator<MimeMappings.Mapping> iterator() 
      java.lang.String remove(java.lang.String extension)
      Remove an existing mapping.
      static MimeMappings unmodifiableMappings(MimeMappings mappings)
      Create a new unmodifiable view of the specified mapping.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • DEFAULT

        public static final MimeMappings DEFAULT
        Default mime mapping commonly used.
    • Constructor Detail

      • MimeMappings

        public MimeMappings()
        Create a new empty MimeMappings instance.
      • MimeMappings

        public MimeMappings(MimeMappings mappings)
        Create a new MimeMappings instance from the specified mappings.
        Parameters:
        mappings - the source mappings
      • MimeMappings

        public MimeMappings(java.util.Map<java.lang.String,java.lang.String> mappings)
        Create a new MimeMappings from the specified mappings.
        Parameters:
        mappings - the source mappings with extension as the key and mime-type as the value
    • Method Detail

      • getAll

        public java.util.Collection<MimeMappings.Mapping> getAll()
        Returns all defined mappings.
        Returns:
        the mappings.
      • add

        public java.lang.String add(java.lang.String extension,
                                    java.lang.String mimeType)
        Add a new mime mapping.
        Parameters:
        extension - the file extension (excluding '.')
        mimeType - the mime type to map
        Returns:
        any previous mapping or null
      • get

        public java.lang.String get(java.lang.String extension)
        Get a mime mapping for the given extension.
        Parameters:
        extension - the file extension (excluding '.')
        Returns:
        a mime mapping or null
      • remove

        public java.lang.String remove(java.lang.String extension)
        Remove an existing mapping.
        Parameters:
        extension - the file extension (excluding '.')
        Returns:
        the removed mime mapping or null if no item was removed
      • equals

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

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

        public static MimeMappings unmodifiableMappings(MimeMappings mappings)
        Create a new unmodifiable view of the specified mapping. Methods that attempt to modify the returned map will throw UnsupportedOperationExceptions.
        Parameters:
        mappings - the mappings
        Returns:
        an unmodifiable view of the specified mappings.