Package org.simpleframework.xml.core
Class ModelList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<Model>
-
- org.simpleframework.xml.core.ModelList
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<Model>
,java.util.Collection<Model>
,java.util.List<Model>
,java.util.RandomAccess
class ModelList extends java.util.ArrayList<Model>
TheModelList
object is used to maintain an ordered list of models. Models are maintained within the list in an sequenced manner, ordered by the index of the model. During the building process models can be registered in any order, however once building has finished the list must contain a complete sequence of models, ordered by index.
-
-
Constructor Summary
Constructors Constructor Description ModelList()
Constructor for theModelList
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelList
build()
This is used when building a copy of the model.boolean
isEmpty()
This is used to determine if the model list is empty.Model
lookup(int index)
This is used to find a model based on its index.void
register(Model model)
This is used to register the model within the list.Model
take()
This is used to take the models from the model list at the first index.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Method Detail
-
build
public ModelList build()
This is used when building a copy of the model. A copy is required when serializing or deserializing so that the list remains intact for the next time it is used- Returns:
- this returns an exact copy of the model list
-
isEmpty
public boolean isEmpty()
This is used to determine if the model list is empty. The model list is considered empty if it does not contain any models with element or attribute registrations. This does not mean that the list itself does not contain models.
-
lookup
public Model lookup(int index)
This is used to find a model based on its index. If there are no models at the specified index this will return null. Unlike the get method this does not throw exceptions.- Parameters:
index
- this is the index to acquire the model at- Returns:
- this returns the model if one exists at the index
-
register
public void register(Model model)
This is used to register the model within the list. The model is registered at the index provided. If the registration is out of sequence all indexes that do not have models are populated with null values to ensure each model resides in its index position within the list.- Parameters:
model
- the model to be registered within the list
-
take
public Model take()
This is used to take the models from the model list at the first index. This is used when iterating over the models to ensure there is only ever one visit of a specific model- Returns:
- this returns the next model in the sequence
-
-