Package org.esa.snap.core.datamodel
Class ProductNodeList<T extends ProductNode>
- java.lang.Object
-
- org.esa.snap.core.datamodel.ProductNodeList<T>
-
public final class ProductNodeList<T extends ProductNode> extends Object
A type-safe list for elements of the typeProductNode
.- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description ProductNodeList()
Constructs a new list named nodes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, T node)
Inserts a new node to this list at the given index.boolean
add(T node)
Adds a new node to this list.void
clearRemovedList()
Clears the internal removed product nodes list.boolean
contains(String name)
Tests if this list contains a node with the given name.boolean
contains(T node)
Tests if this list contains the given node.void
copyInto(T[] array)
Copies the product nodes of this product node list into the specified array.ProductNodeList<T>
createSubset(ProductNodeFilter<T> filter)
Creates a subset of this list using the given filter.void
dispose()
Releases all of the resources used by this object instance and all of its owned children.T
get(String name)
Gets the element with the given name.T
getAt(int index)
T
getByDisplayName(String displayName)
Gets the element with the given display name.String[]
getDisplayNames()
Gets the display names of all nodes contained in this list.String[]
getNames()
Gets the names of all nodes contained in this list.Collection<T>
getRemovedNodes()
Gets all removed product nodes.int
indexOf(String name)
Gets the index of the node with the given name.int
indexOf(T node)
Gets the index of the given node.boolean
remove(T node)
Removes the given node from this list.void
removeAll()
Removes all nodes from this list.int
size()
ProductNode[]
toArray()
Returns the list of named nodes as an array.T[]
toArray(T[] array)
Returns the list of named nodes as an array.
-
-
-
Method Detail
-
size
public final int size()
- Returns:
- the size of this list.
-
getAt
public final T getAt(int index)
- Parameters:
index
- the index, must be in the range zero tosize()
- Returns:
- the element at the spcified index.
-
getNames
public final String[] getNames()
Gets the names of all nodes contained in this list. If this list is empty a zero-length array is returned.- Returns:
- a string array containing all node names, never
null
-
getDisplayNames
public String[] getDisplayNames()
Gets the display names of all nodes contained in this list. If this list is empty a zero-length array is returned.- Returns:
- a string array containing all node display names, never
null
- See Also:
ProductNode.getDisplayName()
-
get
public final T get(String name)
Gets the element with the given name. The method performs a case insensitive search.- Parameters:
name
- the name of the node, must not benull
- Returns:
- the node with the given name or
null
if a node with the given name is not contained in this list - Throws:
IllegalArgumentException
- if the name isnull
-
getByDisplayName
public T getByDisplayName(String displayName)
Gets the element with the given display name.- Parameters:
displayName
- the display name of the node, must not benull
- Returns:
- the node with the given display name or
null
if a node with the given display name is not contained in this list - Throws:
IllegalArgumentException
- if the display name isnull
- See Also:
ProductNode.getDisplayName()
-
contains
public final boolean contains(String name)
Tests if this list contains a node with the given name.- Parameters:
name
- the name of the node, must not benull
- Returns:
- true if this list contains a node with the given name.
- Throws:
IllegalArgumentException
- if the name isnull
-
contains
public final boolean contains(T node)
Tests if this list contains the given node.- Parameters:
node
- the node- Returns:
- true if this list contains the given node.
- Throws:
IllegalArgumentException
- if the node isnull
-
add
public final boolean add(T node)
Adds a new node to this list. Note thatnull
nodes are not added to this list.- Parameters:
node
- the node to be added, ignored ifnull
- Returns:
- true if the node was added, otherwise false.
-
add
public final void add(int index, T node)
Inserts a new node to this list at the given index. Note thatnull
nodes are not added to this list.- Parameters:
node
- the node to be added, ignored ifnull
index
- the insert index- Throws:
ArrayIndexOutOfBoundsException
- if the index was invalid.
-
clearRemovedList
public void clearRemovedList()
Clears the internal removed product nodes list.
-
getRemovedNodes
public Collection<T> getRemovedNodes()
Gets all removed product nodes.- Returns:
- a collection of all removed product nodes.
-
remove
public final boolean remove(T node)
Removes the given node from this list. The removed nodes will be added to the internal list of removed product nodes.- Parameters:
node
- the node to be removed, ignored ifnull
- Returns:
true
if the node is a member of this list and could successfully be removed,false
otherwise
-
removeAll
public final void removeAll()
Removes all nodes from this list.
-
dispose
public final void dispose()
Releases all of the resources used by this object instance and all of its owned children. Its primary use is to allow the garbage collector to perform a vanilla job.This method should be called only if it is for sure that this object instance will never be used again. The results of referencing an instance of this class after a call to
dispose()
are undefined.
-
createSubset
public ProductNodeList<T> createSubset(ProductNodeFilter<T> filter)
Creates a subset of this list using the given filter.- Parameters:
filter
- the product node filter to be used, ifnull
a clone of this list is created- Returns:
- the subset
-
toArray
public final ProductNode[] toArray()
Returns the list of named nodes as an array. If this list is empty a zero-length array is returned.- Returns:
- a string array containing all node names, never
null
-
toArray
public final T[] toArray(T[] array)
Returns the list of named nodes as an array. If this list is empty a zero-length array is returned.- Parameters:
array
- the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- an array containing the elements of the list. never
null
-
copyInto
public final void copyInto(T[] array)
Copies the product nodes of this product node list into the specified array. The array must be big enough to hold all the product nodes in this product node list, else an IndexOutOfBoundsException is thrown.- Parameters:
array
- the array into which the product nodes get copied.- Throws:
NullPointerException
- if the given array is null.IndexOutOfBoundsException
- if the given array is to small.
-
indexOf
public final int indexOf(String name)
Gets the index of the node with the given name. The method performs a case insensitive search.- Parameters:
name
- the name of the node, must not benull
- Returns:
- the index of the node with the given name or
-1
if a node with the given name is not contained in this list - Throws:
IllegalArgumentException
- if the name isnull
-
indexOf
public final int indexOf(T node)
Gets the index of the given node.- Parameters:
node
- the node to get the index, must not benull
- Returns:
- the index of the given node or
-1
if the node is not contained in this list - Throws:
IllegalArgumentException
- if the node isnull
-
-