org.esa.beam.framework.datamodel
Class ProductNode

java.lang.Object
  extended by com.bc.ceres.core.ExtensibleObject
      extended by org.esa.beam.framework.datamodel.ProductNode
All Implemented Interfaces:
com.bc.ceres.core.Extensible
Direct Known Subclasses:
BitmaskDef, DataNode, MetadataElement, Placemark, Product, ProductNodeGroup, VectorDataNode

public abstract class ProductNode
extends com.bc.ceres.core.ExtensibleObject

The ProductNode is the base class for all nodes within a remote sensing data product and even the data product itself.

Author:
Norman Fomferra

Field Summary
static String PROPERTY_NAME_DESCRIPTION
           
static String PROPERTY_NAME_NAME
           
 
Constructor Summary
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
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 or not 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.
protected  void setOwner(ProductNode owner)
          Sets the 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 by oldExternalName with oldExternalName.
 
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 be null
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 be null
description - a descriptive string, can be null
Throws:
IllegalArgumentException - if the given name is not a valid node identifier
Method Detail

setOwner

protected void setOwner(ProductNode owner)
Sets the 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 be null

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.beam.framework.datamodel.ProductNode, java.lang.String, java.lang.Object, java.lang.Object)

toString

public String toString()
Overrides:
toString in class 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 ifentifier, 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 thrws an IllegalStateException if no such reader exists.

Returns:
the product reader, never null
Throws:
IllegalStateException - if the the product reader is null

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 thrws an IllegalStateException if no such writer exists.

Returns:
the product writer, never null
Throws:
IllegalStateException - if the the product writer is null

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 node node-name of the product with the reference number 2.

Returns:
this node's name with a product prefix
or this node's name only if this node's product prefix is null
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 number 2.

Returns:
the product reference string.
or null if this node has no product
or null 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 not null 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 by oldExternalName with oldExternalName. 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 or not this node is part of the given subset.

Parameters:
subsetDef - The subset definition.
Returns:
true if the subset is not null 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.


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.