public class ModelMap
extends java.util.LinkedHashMap<java.lang.String,java.lang.Object>
This class serves as generic model holder for both Servlet and Portlet MVC,
but is not tied to either of those. Check out the Model
interface for
a Java-5-based interface variant that serves the same purpose.
Conventions.getVariableName(java.lang.Object)
,
ModelAndView
,
ModelAndView
,
Serialized FormConstructor and Description |
---|
ModelMap()
Construct a new, empty
ModelMap . |
ModelMap(java.lang.Object attributeValue)
Construct a new
ModelMap containing the supplied attribute. |
ModelMap(java.lang.String attributeName,
java.lang.Object attributeValue)
Construct a new
ModelMap containing the supplied attribute
under the supplied name. |
Modifier and Type | Method and Description |
---|---|
ModelMap |
addAllAttributes(java.util.Collection<?> attributeValues)
Copy all attributes in the supplied
Collection into this
Map , using attribute name generation for each element. |
ModelMap |
addAllAttributes(java.util.Map<java.lang.String,?> attributes)
Copy all attributes in the supplied
Map into this Map . |
ModelMap |
addAttribute(java.lang.Object attributeValue)
Add the supplied attribute to this
Map using a
generated name . |
ModelMap |
addAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Add the supplied attribute under the supplied name.
|
boolean |
containsAttribute(java.lang.String attributeName)
Does this model contain an attribute of the given name?
|
ModelMap |
mergeAttributes(java.util.Map<java.lang.String,?> attributes)
Copy all attributes in the supplied
Map into this Map ,
with existing objects of the same name taking precedence (i.e. |
clear, containsValue, forEach, get, removeEldestEntry, replaceAll
clone, compute, computeIfAbsent, computeIfPresent, containsKey, entrySet, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values
public ModelMap()
ModelMap
.public ModelMap(java.lang.String attributeName, java.lang.Object attributeValue)
ModelMap
containing the supplied attribute
under the supplied name.addAttribute(String, Object)
public ModelMap(java.lang.Object attributeValue)
ModelMap
containing the supplied attribute.
Uses attribute name generation to generate the key for the supplied model
object.addAttribute(Object)
public ModelMap addAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
attributeName
- the name of the model attribute (never null
)attributeValue
- the model attribute value (can be null
)public ModelMap addAttribute(java.lang.Object attributeValue)
Map
using a
generated name
.
null
rather
than for empty collections as is already done by JSTL tags.
attributeValue
- the model attribute value (never null
)public ModelMap addAllAttributes(java.util.Collection<?> attributeValues)
Collection
into this
Map
, using attribute name generation for each element.addAttribute(Object)
public ModelMap addAllAttributes(java.util.Map<java.lang.String,?> attributes)
Map
into this Map
.addAttribute(String, Object)
public ModelMap mergeAttributes(java.util.Map<java.lang.String,?> attributes)
Map
into this Map
,
with existing objects of the same name taking precedence (i.e. not getting
replaced).public boolean containsAttribute(java.lang.String attributeName)
attributeName
- the name of the model attribute (never null
)