Package org.esa.snap.core.datamodel
Class DataNode
- java.lang.Object
-
- com.bc.ceres.core.ExtensibleObject
-
- org.esa.snap.core.datamodel.ProductNode
-
- org.esa.snap.core.datamodel.DataNode
-
- All Implemented Interfaces:
Extensible
- Direct Known Subclasses:
MetadataAttribute
,RasterDataNode
public abstract class DataNode extends ProductNode
ADataNode
is the base class for all nodes within a data product which carry data. The data is represented by an instance of
.ProductData
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_NAME_DATA
static String
PROPERTY_NAME_READ_ONLY
static String
PROPERTY_NAME_SYNTHETIC
static String
PROPERTY_NAME_UNIT
-
Fields inherited from class org.esa.snap.core.datamodel.ProductNode
PROPERTY_NAME_DESCRIPTION, PROPERTY_NAME_NAME
-
-
Constructor Summary
Constructors Constructor Description DataNode(String name, int dataType, long numElems)
Constructs a new data node with the given name, data type and number of elements.DataNode(String name, ProductData data, boolean readOnly)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
acceptVisitor(ProductVisitor visitor)
Accepts the given visitor.protected void
checkDataCompatibility(ProductData data)
Checks if the data that should be used to access the data is compatible with the data this node can hold.ProductData
createCompatibleProductData(int numElems)
Creates product data that is compatible to this dataset's data type.void
dispose()
Releases all of the resources used by this object instance and all of its owned children.void
fireProductNodeDataChanged()
Fires a node data changed event.ProductData
getData()
Gets the data of this data node.Object
getDataElems()
Gets the data elements of this data node.int
getDataElemSize()
Gets the data element size in bytes.int
getDataType()
Gets the data type of this data node.long
getNumDataElems()
Gets the number of data elements in this data node.long
getRawStorageSize(ProductSubsetDef subsetDef)
Gets the estimated size in bytes of this product node.String
getUnit()
boolean
isFloatingPointType()
Tests whether the data type of this node is a floating point type.boolean
isReadOnly()
boolean
isSynthetic()
void
setData(ProductData data)
Sets the data of this data node.void
setDataElems(Object elems)
Sets the data elements of this data node.void
setReadOnly(boolean readOnly)
void
setSynthetic(boolean synthetic)
void
setUnit(String unit)
-
Methods inherited from class org.esa.snap.core.datamodel.ProductNode
fireProductNodeChanged, fireProductNodeChanged, getDescription, getDisplayName, getName, getOwner, getProduct, getProductReader, getProductReaderSafe, getProductRefString, getProductSafe, getProductWriter, getProductWriterSafe, getRawStorageSize, isModified, isPartOfSubset, isValidNodeName, removeFromFile, setDescription, setModified, setName, setNodeName, setOwner, toString, updateExpression
-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
-
-
-
Field Detail
-
PROPERTY_NAME_DATA
public static final String PROPERTY_NAME_DATA
- See Also:
- Constant Field Values
-
PROPERTY_NAME_READ_ONLY
public static final String PROPERTY_NAME_READ_ONLY
- See Also:
- Constant Field Values
-
PROPERTY_NAME_SYNTHETIC
public static final String PROPERTY_NAME_SYNTHETIC
- See Also:
- Constant Field Values
-
PROPERTY_NAME_UNIT
public static final String PROPERTY_NAME_UNIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DataNode
public DataNode(String name, int dataType, long numElems)
Constructs a new data node with the given name, data type and number of elements.
-
DataNode
public DataNode(String name, ProductData data, boolean readOnly)
-
-
Method Detail
-
getDataType
public int getDataType()
Gets the data type of this data node.- Returns:
- the data type which is always one of the multiple
ProductData.TYPE_X
constants
-
isFloatingPointType
public boolean isFloatingPointType()
Tests whether the data type of this node is a floating point type.- Returns:
- true, if so
-
getNumDataElems
public long getNumDataElems()
Gets the number of data elements in this data node.
-
setData
public void setData(ProductData data)
Sets the data of this data node.
-
getData
public ProductData getData()
Gets the data of this data node.
-
setDataElems
public void setDataElems(Object elems)
Sets the data elements of this data node.- See Also:
ProductData.setElems(Object)
-
getDataElems
public Object getDataElems()
Gets the data elements of this data node.- See Also:
ProductData.getElems()
-
getDataElemSize
public int getDataElemSize()
Gets the data element size in bytes.- See Also:
ProductData.getElemSize(int)
-
setReadOnly
public void setReadOnly(boolean readOnly)
-
isReadOnly
public boolean isReadOnly()
-
setUnit
public void setUnit(String unit)
-
getUnit
public String getUnit()
-
isSynthetic
public boolean isSynthetic()
-
setSynthetic
public void setSynthetic(boolean synthetic)
-
fireProductNodeDataChanged
public void fireProductNodeDataChanged()
Fires a node data changed event. This method is called after the data of this data node changed.
-
checkDataCompatibility
protected void checkDataCompatibility(ProductData data) throws IllegalArgumentException
Checks if the data that should be used to access the data is compatible with the data this node can hold.- Parameters:
data
- the data to be checked for compatibility- Throws:
IllegalArgumentException
- if data is invalid.
-
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.- Specified by:
acceptVisitor
in classProductNode
- Parameters:
visitor
- the visitor, must not benull
-
getRawStorageSize
public long getRawStorageSize(ProductSubsetDef subsetDef)
Gets the estimated size in bytes of this product node.- Specified by:
getRawStorageSize
in classProductNode
- Parameters:
subsetDef
- if notnull
the subset may limit the size returned- Returns:
- the size in bytes.
-
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.- Overrides:
dispose
in classProductNode
-
createCompatibleProductData
public ProductData createCompatibleProductData(int numElems)
Creates product data that is compatible to this dataset's data type. The data buffer returned contains exactlynumElems
elements of a compatible data type.- Parameters:
numElems
- the number of elements, must not be less than one- Returns:
- product data compatible with this data node
-
-