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
The ProductNode is the base class for all nodes within a remote sensing data product and even the data product itself.
  • Field Details

  • Constructor Details

    • 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 Details

    • 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.
    • setNodeName

      protected void setNodeName(String trimmedName, boolean silent, boolean allowSameName)
      Perform various checks and set the new name .
      Parameters:
      trimmedName - the name
      silent - signal or not the change
      allowSameName - allow the name to be identical to another item's 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:
    • 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 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 an IllegalStateException if no such reader exists.
      Returns:
      the product reader, never null
      Throws:
      IllegalStateException - if 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 throws 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

      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 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.