Class MimeMappings
java.lang.Object
org.springframework.boot.web.server.MimeMappings
- All Implemented Interfaces:
Iterable<MimeMappings.Mapping>
Simple server-independent abstraction for mime mappings. Roughly equivalent to the
<mime-mapping> element traditionally found in web.xml.
- Since:
- 2.0.0
- Author:
- Phillip Webb, Guirong Hu
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new emptyMimeMappings
instance.MimeMappings
(Map<String, String> mappings) Create a newMimeMappings
from the specified mappings.MimeMappings
(MimeMappings mappings) Create a newMimeMappings
instance from the specified mappings. -
Method Summary
Modifier and TypeMethodDescriptionAdd a new mime mapping.boolean
Get a mime mapping for the given extension.getAll()
Returns all defined mappings.int
hashCode()
final Iterator<MimeMappings.Mapping>
iterator()
static MimeMappings
lazyCopy
(MimeMappings mappings) Create a new lazy copy of the given mappings that will only copy entries if the mappings are mutated.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 Details
-
DEFAULT
Default mime mapping commonly used.
-
-
Constructor Details
-
MimeMappings
public MimeMappings()Create a new emptyMimeMappings
instance. -
MimeMappings
Create a newMimeMappings
instance from the specified mappings.- Parameters:
mappings
- the source mappings
-
MimeMappings
Create a newMimeMappings
from the specified mappings.- Parameters:
mappings
- the source mappings with extension as the key and mime-type as the value
-
-
Method Details
-
add
Add a new mime mapping.- Parameters:
extension
- the file extension (excluding '.')mimeType
- the mime type to map- Returns:
- any previous mapping or
null
-
remove
Remove an existing mapping.- Parameters:
extension
- the file extension (excluding '.')- Returns:
- the removed mime mapping or
null
if no item was removed
-
get
Get a mime mapping for the given extension.- Parameters:
extension
- the file extension (excluding '.')- Returns:
- a mime mapping or
null
-
getAll
Returns all defined mappings.- Returns:
- the mappings.
-
iterator
- Specified by:
iterator
in interfaceIterable<MimeMappings.Mapping>
-
equals
-
hashCode
public int hashCode() -
unmodifiableMappings
Create a new unmodifiable view of the specified mapping. Methods that attempt to modify the returned map will throwUnsupportedOperationException
s.- Parameters:
mappings
- the mappings- Returns:
- an unmodifiable view of the specified mappings.
-
lazyCopy
Create a new lazy copy of the given mappings that will only copy entries if the mappings are mutated.- Parameters:
mappings
- the source mappings- Returns:
- a new mappings instance
- Since:
- 3.0.0
-