Class ExtendedDocumentArray
java.lang.Object
com.inductiveautomation.ignition.common.document.DocumentElement
com.inductiveautomation.ignition.common.document.DocumentArray
com.inductiveautomation.ignition.common.document.ExtendedDocumentArray
- All Implemented Interfaces:
com.inductiveautomation.ignition.common.document.DiffTree.Producer<DocumentElement>
,Serializable
,Iterable<DocumentElement>
Allows cloning a
It's extremely important that the delegate DocumentArray is never modified. In cases where the delegate DocumentArray might change,
DocumentArray
without having to create a deep copy of all it's elements. This is managed by
tracking all modifications to a delegate DocumentArray instead of applying those modifications directly to the
DocumentArray. If extend(com.inductiveautomation.ignition.common.document.DocumentArray)
is called on an ExtendedDocumentArray
the delegate
DocumentArray is reused and modifications are copied to the new ExtendedDocumentArray
.
It's extremely important that the delegate DocumentArray is never modified. In cases where the delegate DocumentArray might change,
DocumentArray.deepCopy()
should be used instead.- See Also:
-
Field Summary
Fields inherited from class com.inductiveautomation.ignition.common.document.DocumentArray
elements
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(DocumentElement element) Adds the specified element to self.void
addAll
(DocumentArray array) Adds all the elements of the specified array to self.boolean
contains
(DocumentElement element) Returns true if this array contains the specified element.deepCopy()
Creates a deep copy of this element and all its childrenstatic DocumentArray
extend
(DocumentArray array) get
(int i) Returns the ith element of the array.iterator()
Provides a safe iterator that extends elements before publishing through iterator, preventing mutation of backing array elements.remove
(int index) Removes the element at the specified position in this array.boolean
remove
(DocumentElement element) Removes the first occurrence of the specified element from this array, if it is present.set
(int index, DocumentElement element) Replaces the element at the specified position in this array with the specified element.int
size()
Returns the number of elements in the array.protected Iterator<DocumentElement>
Provides iterator that publishes objects from backing array.Methods inherited from class com.inductiveautomation.ignition.common.document.DocumentArray
add, add, add, add, equals, getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInt, getAsLong, getAsNumber, getAsShort, getAsString, hashCode, toJsonElement
Methods inherited from class com.inductiveautomation.ignition.common.document.DocumentElement
fromJson, getAsDocument, getAsDocumentArray, getAsDocumentNull, getAsDocumentPrimitive, isDocument, isDocumentArray, isDocumentNull, isDocumentPrimitive, toString, toStringNoIndent
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
extend
-
deepCopy
Description copied from class:DocumentArray
Creates a deep copy of this element and all its children- Overrides:
deepCopy
in classDocumentArray
-
add
Description copied from class:DocumentArray
Adds the specified element to self.- Overrides:
add
in classDocumentArray
- Parameters:
element
- the element that needs to be added to the array.
-
addAll
Description copied from class:DocumentArray
Adds all the elements of the specified array to self.- Overrides:
addAll
in classDocumentArray
- Parameters:
array
- the array whose elements need to be added to the array.
-
set
Description copied from class:DocumentArray
Replaces the element at the specified position in this array with the specified element. Element can be null.- Overrides:
set
in classDocumentArray
- Parameters:
index
- index of the element to replaceelement
- element to be stored at the specified position- Returns:
- the element previously at the specified position
-
remove
Description copied from class:DocumentArray
Removes the first occurrence of the specified element from this array, if it is present. If the array does not contain the element, it is unchanged.- Overrides:
remove
in classDocumentArray
- Parameters:
element
- element to be removed from this array, if present- Returns:
- true if this array contained the specified element, false otherwise
-
remove
Description copied from class:DocumentArray
Removes the element at the specified position in this array. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the array.- Overrides:
remove
in classDocumentArray
- Parameters:
index
- index the index of the element to be removed- Returns:
- the element previously at the specified position
-
contains
Description copied from class:DocumentArray
Returns true if this array contains the specified element.- Overrides:
contains
in classDocumentArray
- Parameters:
element
- whose presence in this array is to be tested- Returns:
- true if this array contains the specified element.
-
size
public int size()Description copied from class:DocumentArray
Returns the number of elements in the array.- Specified by:
size
in interfacecom.inductiveautomation.ignition.common.document.DiffTree.Producer<DocumentElement>
- Overrides:
size
in classDocumentArray
- Returns:
- the number of elements in the array.
-
iterator
Provides a safe iterator that extends elements before publishing through iterator, preventing mutation of backing array elements.- Specified by:
iterator
in interfaceIterable<DocumentElement>
- Overrides:
iterator
in classDocumentArray
- Returns:
- an iterator to navigate the elements of the array.
-
unsafeIterator
Provides iterator that publishes objects from backing array. Used internally for more efficient access to elements that we know won't be modified (equals, hashCode, etc).- Overrides:
unsafeIterator
in classDocumentArray
-
get
Description copied from class:DocumentArray
Returns the ith element of the array.- Specified by:
get
in interfacecom.inductiveautomation.ignition.common.document.DiffTree.Producer<DocumentElement>
- Overrides:
get
in classDocumentArray
- Parameters:
i
- the index of the element that is being sought.- Returns:
- the element present at the ith index.
-