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 type ProductNode.
Version:
$Revision$ $Date$
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new list named nodes.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(int index, T node)
    Inserts a new node to this list at the given index.
    final boolean
    add(T node)
    Adds a new node to this list.
    void
    Clears the internal removed product nodes list.
    final boolean
    Tests if this list contains a node with the given name.
    final boolean
    contains(T node)
    Tests if this list contains the given node.
    final void
    copyInto(T[] array)
    Copies the product nodes of this product node list into the specified array.
    Creates a subset of this list using the given filter.
    final void
    Releases all of the resources used by this object instance and all of its owned children.
    final T
    get(String name)
    Gets the element with the given name.
    final T
    getAt(int index)
     
    getByDisplayName(String displayName)
    Gets the element with the given display name.
    Gets the display names of all nodes contained in this list.
    final String[]
    Gets the names of all nodes contained in this list.
    Gets all removed product nodes.
    final int
    Gets the index of the node with the given name.
    final int
    indexOf(T node)
    Gets the index of the given node.
    final boolean
    remove(T node)
    Removes the given node from this list.
    final void
    Removes all nodes from this list.
    final int
     
    final ProductNode[]
    Returns the list of named nodes as an array.
    final T[]
    toArray(T[] array)
    Returns the list of named nodes as an array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProductNodeList

      public ProductNodeList()
      Constructs a new list named nodes.
  • Method Details

    • 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 to size()
      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:
    • 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 be null
      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 is null
    • getByDisplayName

      public T getByDisplayName(String displayName)
      Gets the element with the given display name.
      Parameters:
      displayName - the display name of the node, must not be null
      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 is null
      See Also:
    • 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 be null
      Returns:
      true if this list contains a node with the given name.
      Throws:
      IllegalArgumentException - if the name is null
    • 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 is null
    • add

      public final boolean add(T node)
      Adds a new node to this list. Note that null nodes are not added to this list.
      Parameters:
      node - the node to be added, ignored if null
      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 that null nodes are not added to this list.
      Parameters:
      index - the insert index
      node - the node to be added, ignored if null
      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 if null
      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, if null 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 be null
      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 is null
    • indexOf

      public final int indexOf(T node)
      Gets the index of the given node.
      Parameters:
      node - the node to get the index, must not be null
      Returns:
      the index of the given node or -1 if the node is not contained in this list
      Throws:
      IllegalArgumentException - if the node is null