Class MimeMappings

java.lang.Object
com.jk.web.embedded.spring.MimeMappings
All Implemented Interfaces:
Iterable<MimeMappings.Mapping>

public final class MimeMappings extends Object implements Iterable<MimeMappings.Mapping>
This class represents a mapping of file extensions to MIME types.

It provides methods to add, retrieve, and remove mappings.

Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Field Details

    • DEFAULT

      public static final MimeMappings DEFAULT
      Represents the default mime-mapping.
  • Constructor Details

    • MimeMappings

      public MimeMappings()
      This method constructs a new MimeMappings which is empty.
    • MimeMappings

      public MimeMappings(MimeMappings mappings)
      This method constructs a new MimeMappings which is mutable by default.
      Parameters:
      mappings - Specifies the mappings to be added to this instance.
    • MimeMappings

      public MimeMappings(Map<String,String> mappings)
      This method constructs a new MimeMappings.
      Parameters:
      mappings - Specifies the mappings to be added to this instance.
  • Method Details

    • iterator

      public Iterator<MimeMappings.Mapping> iterator()
      Specified by:
      iterator in interface Iterable<MimeMappings.Mapping>
    • getAll

      public Collection<MimeMappings.Mapping> getAll()
      This method gets all the MIME types, in the mime-mapping.
      Returns:
      the MIME types, in the mime-mapping.
    • add

      public String add(String extension, String mimeType)
      This method adds a mapping entry with the provided extension and MIME type.
      Parameters:
      extension - Specifies the file extension.
      mimeType - Specifies the MIME type associated with the extension.
      Returns:
      the Mapping of the new MIME type.
    • get

      public String get(String extension)
      This method retrieves the MIME type associated with the specified file extension.
      Parameters:
      extension - Specifies the file extension.
      Returns:
      the MIME type associated with the extension, or null if no mapping was found.
    • remove

      public String remove(String extension)
      This method removes a mapping for the specified file extension.
      Parameters:
      extension - Specifies the file extension to remove the mapping for.
      Returns:
      the MIME type that was previously associated with the extension, or null if no mapping was found.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • unmodifiableMappings

      public static MimeMappings unmodifiableMappings(MimeMappings mappings)
      This method constructs a new with the provided mime-mappings that cannot be changed.
      Parameters:
      mappings - Specifies the mime-mappings in the new instance.
      Returns:
      the instance of MimeMappings that contains the provided mime-mappings.