Package org.simpleframework.xml.core
Class ModelMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.String,ModelList>
-
- org.simpleframework.xml.core.ModelMap
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<ModelList>
,java.util.Map<java.lang.String,ModelList>
class ModelMap extends java.util.LinkedHashMap<java.lang.String,ModelList> implements java.lang.Iterable<ModelList>
TheModelMap
object represents a map that contains string model mappings. This is used for convenience as a typedef like construct to avoid having declare the generic type whenever it is referenced. Also this allowsModelList
values from the map to be iterated within for each loops.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelMap
getModels()
This method is used to clone the model map such that mappings can be maintained in the original even if they are modified in the clone.java.util.Iterator<ModelList>
iterator()
This allows theModelList
objects within the model map to be iterated within for each loops.Model
lookup(java.lang.String name, int index)
This method is used to look for aModel
that matches the specified element name.void
register(java.lang.String name, Model model)
This is used to register aModel
within this map.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Field Detail
-
detail
private final Detail detail
This is the detail associated with this model map instance.
-
-
Constructor Detail
-
ModelMap
public ModelMap(Detail detail)
Constructor for theModelMap
object is used to create an empty map. This is used for convenience as a typedef like construct which avoids having to use the generic type.- Parameters:
detail
- this is the detail associated with the map
-
-
Method Detail
-
getModels
public ModelMap getModels() throws java.lang.Exception
This method is used to clone the model map such that mappings can be maintained in the original even if they are modified in the clone. This is used to that theSchema
can remove mappings from the model map as they are visited.- Returns:
- this returns a cloned representation of this map
- Throws:
java.lang.Exception
-
lookup
public Model lookup(java.lang.String name, int index)
This method is used to look for aModel
that matches the specified element name. If no such model exists then this will return null. This is as a convenient way to find a model within the tree of models being built.- Parameters:
name
- this is the name of the model to be acquiredindex
- this is the index used to order the model- Returns:
- this returns the model located by the expression
-
register
public void register(java.lang.String name, Model model)
This is used to register aModel
within this map. Registration of a model creates a tree of models that can be used to represent an XML structure. Each model can contain elements and attributes associated with a type.- Parameters:
name
- this is the name of the model to be registeredmodel
- this is the model that is to be registered
-
iterator
public java.util.Iterator<ModelList> iterator()
This allows theModelList
objects within the model map to be iterated within for each loops. This will provide all remaining model objects within the map. The iteration order is not maintained so model objects may be given in any sequence.- Specified by:
iterator
in interfacejava.lang.Iterable<ModelList>
- Returns:
- this returns an iterator for existing model objects
-
-