Package org.simpleframework.xml.core
Class ModelList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<Model>
,Collection<Model>
,List<Model>
,RandomAccess
,SequencedCollection<Model>
The
ModelList
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.-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
This is used when building a copy of the model.boolean
isEmpty()
This is used to determine if the model list is empty.lookup
(int index) This is used to find a model based on its index.void
This is used to register the model within the list.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, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll, reversed
-
Constructor Details
-
ModelList
public ModelList()Constructor for theModelList
object. This is used to construct a linked list that can take registrations ofModel
objects out of sequence. Once complete the list should contain a full ordered set of models.
-
-
Method Details
-
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
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
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
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
-