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
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new emptyMimeMappingsinstance.MimeMappings(Map<String, String> mappings) Create a newMimeMappingsfrom the specified mappings.MimeMappings(MimeMappings mappings) Create a newMimeMappingsinstance from the specified mappings. -
Method Summary
Modifier and TypeMethodDescriptionAdd a new mime mapping.booleanGet a mime mapping for the given extension.getAll()Returns all defined mappings.inthashCode()final Iterator<MimeMappings.Mapping>iterator()static MimeMappingslazyCopy(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 MimeMappingsunmodifiableMappings(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, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT
Default mime mapping commonly used.
-
-
Constructor Details
-
MimeMappings
public MimeMappings()Create a new emptyMimeMappingsinstance. -
MimeMappings
Create a newMimeMappingsinstance from the specified mappings.- Parameters:
mappings- the source mappings
-
MimeMappings
Create a newMimeMappingsfrom 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
nullif 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:
iteratorin 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 throwUnsupportedOperationExceptions.- 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
-