Package org.esa.snap.core.datamodel
Class ProductNode
- java.lang.Object
-
- com.bc.ceres.core.ExtensibleObject
-
- org.esa.snap.core.datamodel.ProductNode
-
- All Implemented Interfaces:
Extensible
- Direct Known Subclasses:
DataNode
,MetadataElement
,Placemark
,Product
,ProductNodeGroup
,Quicklook
,VectorDataNode
public abstract class ProductNode extends ExtensibleObject
TheProductNode
is the base class for all nodes within a remote sensing data product and even the data product itself.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_NAME_DESCRIPTION
static String
PROPERTY_NAME_NAME
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProductNode(String name)
Constructs a new product node with the given name.protected
ProductNode(String name, String description)
Constructs a new product node with the given name and an optional description.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
acceptVisitor(ProductVisitor visitor)
Accepts the given visitor.void
dispose()
Releases all of the resources used by this object instance and all of its owned children.void
fireProductNodeChanged(String propertyName)
void
fireProductNodeChanged(String propertyName, Object oldValue, Object newValue)
String
getDescription()
Returns a short textual description for this products node.String
getDisplayName()
Returns this node's display name.String
getName()
ProductNode
getOwner()
Product
getProduct()
Returns the product to which this node belongs to.ProductReader
getProductReader()
Returns the product reader for the product to which this node belongs to.protected ProductReader
getProductReaderSafe()
Returns the product reader for the product to which this node belongs to.String
getProductRefString()
Gets the product reference string.protected Product
getProductSafe()
Returns safely the product to which this node belongs to.ProductWriter
getProductWriter()
Returns the product writer for the product to which this node belongs to.protected ProductWriter
getProductWriterSafe()
Returns the product writer for the product to which this node belongs to.long
getRawStorageSize()
Gets an estimated, raw storage size in bytes of this product node.abstract long
getRawStorageSize(ProductSubsetDef subsetDef)
Gets an estimated, raw storage size in bytes of this product node.boolean
isModified()
Returns whether or not this node is modified.protected boolean
isPartOfSubset(ProductSubsetDef subsetDef)
Returns whether this node is part of the given subset.static boolean
isValidNodeName(String name)
Tests whether the given name is valid name for a node.void
removeFromFile(ProductWriter productWriter)
Physically remove this node from the file associated with the given product writer.void
setDescription(String description)
Sets a short textual description for this products node.void
setModified(boolean modified)
Sets this node's modified flag.void
setName(String name)
Sets this product's name.void
setOwner(ProductNode owner)
Sets the owner node of this node.String
toString()
void
updateExpression(String oldExternalName, String newExternalName)
Asks a product node to replace all occurences of and references to the node name given byoldExternalName
witholdExternalName
.-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
-
-
-
Field Detail
-
PROPERTY_NAME_NAME
public static final String PROPERTY_NAME_NAME
- See Also:
- Constant Field Values
-
PROPERTY_NAME_DESCRIPTION
public static final String PROPERTY_NAME_DESCRIPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProductNode
protected ProductNode(String name)
Constructs a new product node with the given name.- Parameters:
name
- the node name, must not benull
- Throws:
IllegalArgumentException
- if the given name is not a valid node identifier
-
ProductNode
protected ProductNode(String name, String description)
Constructs a new product node with the given name and an optional description.- Parameters:
name
- the node name, must not benull
description
- a descriptive string, can benull
- Throws:
IllegalArgumentException
- if the given name is not a valid node identifier
-
-
Method Detail
-
setOwner
public void setOwner(ProductNode owner)
Sets the owner node of this node.Overrides shall finally call
super.setOwner(owner)
.- Parameters:
owner
- the new owner
-
getOwner
public ProductNode getOwner()
- Returns:
- The owner node of this node.
-
getName
public String getName()
- Returns:
- This node's name.
-
setName
public void setName(String name)
Sets this product's name.- Parameters:
name
- The name.
-
getDescription
public String getDescription()
Returns a short textual description for this products node.- Returns:
- a description or
null
-
setDescription
public void setDescription(String description)
Sets a short textual description for this products node.- Parameters:
description
- a description, can benull
-
isModified
public boolean isModified()
Returns whether or not this node is modified.- Returns:
true
if so
-
setModified
public void setModified(boolean modified)
Sets this node's modified flag.If the modified flag changes to true and this node has an owner, the owner's modified flag is also set to true.
- Parameters:
modified
- whether or not this node is beeing marked as modified.- See Also:
Product.fireNodeChanged(org.esa.snap.core.datamodel.ProductNode, java.lang.String, java.lang.Object, java.lang.Object)
-
dispose
public 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.Overrides of this method should always call
super.dispose();
after disposing this instance.
-
isValidNodeName
public static boolean isValidNodeName(String name)
Tests whether the given name is valid name for a node. A valid node name must not start with a dot. Also a valid node name must not contain any of the character\/:*?"<>|
- Parameters:
name
- the name to test- Returns:
true
if the name is a valid node identifier,false
otherwise
-
getProduct
public Product getProduct()
Returns the product to which this node belongs to.- Returns:
- the product, or
null
if this node was not owned by a product at the time this method was called
-
getProductSafe
protected Product getProductSafe() throws IllegalStateException
Returns safely the product to which this node belongs to.- Returns:
- the product, never
null
- Throws:
IllegalStateException
- if this node does not belong to a product
-
getProductReader
public ProductReader getProductReader()
Returns the product reader for the product to which this node belongs to.- Returns:
- the product reader, or
null
if no such exists
-
getProductReaderSafe
protected ProductReader getProductReaderSafe()
Returns the product reader for the product to which this node belongs to. The method throws anIllegalStateException
if no such reader exists.- Returns:
- the product reader, never
null
- Throws:
IllegalStateException
- if the product reader isnull
-
getProductWriter
public ProductWriter getProductWriter()
Returns the product writer for the product to which this node belongs to.- Returns:
- the product writer, or
null
if no such exists
-
getProductWriterSafe
protected ProductWriter getProductWriterSafe()
Returns the product writer for the product to which this node belongs to. The method throws anIllegalStateException
if no such writer exists.- Returns:
- the product writer, never
null
- Throws:
IllegalStateException
- if the the product writer isnull
-
getDisplayName
public String getDisplayName()
Returns this node's display name. The display name is the product reference string with the node name appended.Example: The string
"[2] node-name"
means nodenode-name
of the product with the reference number2
.- Returns:
- this node's name with a product prefix
or this node's name only if this node's product prefix isnull
- See Also:
getProductRefString()
-
getProductRefString
public String getProductRefString()
Gets the product reference string. The product reference string is the product reference number enclosed in square brackets.Example: The string
"[2]"
stands for a product with the reference number2
.- Returns:
- the product reference string.
ornull
if this node has no product
ornull
if its product reference number was inactive
-
getRawStorageSize
public long getRawStorageSize()
Gets an estimated, raw storage size in bytes of this product node.- Returns:
- the size in bytes.
-
getRawStorageSize
public abstract long getRawStorageSize(ProductSubsetDef subsetDef)
Gets an estimated, raw storage size in bytes of this product node.- Parameters:
subsetDef
- if notnull
the subset may limit the size returned- Returns:
- the size in bytes.
-
updateExpression
public void updateExpression(String oldExternalName, String newExternalName)
Asks a product node to replace all occurences of and references to the node name given byoldExternalName
witholdExternalName
. Such references most often occur in band arithmetic expressions.- Parameters:
oldExternalName
- The old node name.newExternalName
- The new node name.
-
fireProductNodeChanged
public void fireProductNodeChanged(String propertyName)
-
fireProductNodeChanged
public void fireProductNodeChanged(String propertyName, Object oldValue, Object newValue)
-
acceptVisitor
public abstract void acceptVisitor(ProductVisitor visitor)
Accepts the given visitor. This method implements the well known 'Visitor' design pattern of the gang-of-four. The visitor pattern allows to define new operations on the product data model without the need to add more code to it. The new operation is implemented by the visitor.- Parameters:
visitor
- the visitor
-
isPartOfSubset
protected boolean isPartOfSubset(ProductSubsetDef subsetDef)
Returns whether this node is part of the given subset.- Parameters:
subsetDef
- The subset definition.- Returns:
true
if the subset is notnull
and it contains a node name equal to this node's name.
-
removeFromFile
public void removeFromFile(ProductWriter productWriter)
Physically remove this node from the file associated with the given product writer. The default implementation does nothing.- Parameters:
productWriter
- the product writer to be used to remove this node from the underlying file.
-
-