org.springframework.boot.context.embedded
Class MimeMappings

java.lang.Object
  extended by org.springframework.boot.context.embedded.MimeMappings
All Implemented Interfaces:
Iterable<MimeMappings.Mapping>

public final class MimeMappings
extends Object
implements Iterable<MimeMappings.Mapping>

Simple container-independent abstraction for servlet mime mappings. Roughly equivalent to the &lt;mime-mapping&gt; element traditionally found in web.xml.

Author:
Phillip Webb

Nested Class Summary
static class MimeMappings.Mapping
          A single mime mapping.
 
Field Summary
static MimeMappings DEFAULT
          Default mime mapping commonly used.
 
Constructor Summary
MimeMappings()
          Create a new empty MimeMappings instance.
MimeMappings(Map<String,String> mappings)
          Create a new MimeMappings from the specified mappings.
MimeMappings(MimeMappings mappings)
          Create a new MimeMappings instance from the specified mappings.
 
Method Summary
 String add(String extension, String mimeType)
          Add a new mime mapping.
 boolean equals(Object obj)
           
 String get(String extension)
          Get a mime mapping for the given extension.
 Collection<MimeMappings.Mapping> getAll()
          Returns all defined mappings.
 int hashCode()
           
 Iterator<MimeMappings.Mapping> iterator()
           
 String remove(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
 

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(Map<String,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

iterator

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

getAll

public Collection<MimeMappings.Mapping> getAll()
Returns all defined mappings.

Returns:
the mappings.

add

public String add(String extension,
                  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 String get(String extension)
Get a mime mapping for the given extension.

Parameters:
extension - the file extension (excluding '.')
Returns:
a mime mapping or null

remove

public String remove(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(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class 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.


Copyright © 2013. All Rights Reserved.