Package org.esa.snap.core.datamodel
Class ProductManager
- java.lang.Object
-
- org.esa.snap.core.datamodel.ProductManager
-
public class ProductManager extends Object
A type-safe container for elements of the typeProduct
. ProductListeners can be added to inform if aProduct
was added or removed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProductManager.Event
An event object passed into theProductManager.Listener
methods.static interface
ProductManager.Listener
A listener for the product manager.
-
Constructor Summary
Constructors Constructor Description ProductManager()
Constructs an product manager with an empty list of products.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addListener(ProductManager.Listener listener)
Adds aProductManagerListener
to this product manager.void
addProduct(Product product)
Adds the given product to this product manager if it does not already exists and sets it's reference number one biger than the greatest reference number in this product manager.boolean
contains(Product product)
Tests whether the given product is contained in this list.boolean
containsProduct(String name)
Tests whether a product with the given name is contained in this list.Product
getProduct(int index)
Gets the product at the given index.Product
getProduct(String name)
Product
getProductByDisplayName(String displayName)
Product
getProductByRefNo(int refNo)
int
getProductCount()
String[]
getProductDisplayNames()
Returns the display names of all products currently managed.int
getProductIndex(Product product)
String[]
getProductNames()
Returns the names of all products currently managed.Product[]
getProducts()
Returns an array of all products currently managed.void
removeAllProducts()
Removes all product from this list.boolean
removeListener(ProductManager.Listener listener)
Removes aProductManagerListener
from this product manager.boolean
removeProduct(Product product)
Removes the given product from this product manager if it exists.
-
-
-
Method Detail
-
getProductCount
public int getProductCount()
- Returns:
- The number of products in this product manager.
-
getProduct
public Product getProduct(int index)
Gets the product at the given index.- Parameters:
index
- the index- Returns:
- The product at the given index.
-
getProductDisplayNames
public String[] getProductDisplayNames()
Returns the display names of all products currently managed.- Returns:
- an array containing the display names, never
null
, but the array can have zero length - See Also:
ProductNode.getDisplayName()
-
getProductNames
public String[] getProductNames()
Returns the names of all products currently managed.- Returns:
- an array containing the names, never
null
, but the array can have zero length
-
getProducts
public Product[] getProducts()
Returns an array of all products currently managed.- Returns:
- an array containing the products, never
null
, but the array can have zero length
-
getProductByDisplayName
public Product getProductByDisplayName(String displayName)
- Parameters:
displayName
- The product's display name.- Returns:
- The product with the given display name.
-
getProductByRefNo
public Product getProductByRefNo(int refNo)
- Parameters:
refNo
- The reference number.- Returns:
- The product with the given reference number.
-
getProduct
public Product getProduct(String name)
- Parameters:
name
- The product name.- Returns:
- The product with the given name.
-
getProductIndex
public int getProductIndex(Product product)
-
containsProduct
public boolean containsProduct(String name)
Tests whether a product with the given name is contained in this list.- Parameters:
name
- the product name- Returns:
- true, if so
-
contains
public boolean contains(Product product)
Tests whether the given product is contained in this list.- Parameters:
product
- The product.- Returns:
true
if so.
-
addProduct
public void addProduct(Product product)
Adds the given product to this product manager if it does not already exists and sets it's reference number one biger than the greatest reference number in this product manager.- Parameters:
product
- the product to be added, ignored ifnull
-
removeProduct
public boolean removeProduct(Product product)
Removes the given product from this product manager if it exists.- Parameters:
product
- the product to be removed, ignored ifnull
- Returns:
- true, if the product was removed
-
removeAllProducts
public void removeAllProducts()
Removes all product from this list.
-
addListener
public boolean addListener(ProductManager.Listener listener)
Adds aProductManagerListener
to this product manager. TheProductManagerListener
is informed each time a product was added or removed.- Parameters:
listener
- the listener to be added.- Returns:
- true if the listener was added, otherwise false.
-
removeListener
public boolean removeListener(ProductManager.Listener listener)
Removes aProductManagerListener
from this product manager.- Parameters:
listener
- The listener.- Returns:
- true, if the listener was removed, otherwise false.
-
-