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
ADataNodeis 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 StringPROPERTY_NAME_DATAstatic StringPROPERTY_NAME_READ_ONLYstatic StringPROPERTY_NAME_SYNTHETICstatic StringPROPERTY_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 voidacceptVisitor(ProductVisitor visitor)Accepts the given visitor.protected voidcheckDataCompatibility(ProductData data)Checks if the data that should be used to access the data is compatible with the data this node can hold.ProductDatacreateCompatibleProductData(int numElems)Creates product data that is compatible to this dataset's data type.voiddispose()Releases all of the resources used by this object instance and all of its owned children.voidfireProductNodeDataChanged()Fires a node data changed event.ProductDatagetData()Gets the data of this data node.ObjectgetDataElems()Gets the data elements of this data node.intgetDataElemSize()Gets the data element size in bytes.intgetDataType()Gets the data type of this data node.longgetNumDataElems()Gets the number of data elements in this data node.longgetRawStorageSize(ProductSubsetDef subsetDef)Gets the estimated size in bytes of this product node.StringgetUnit()booleanisFloatingPointType()Tests whether the data type of this node is a floating point type.booleanisReadOnly()booleanisSynthetic()voidsetData(ProductData data)Sets the data of this data node.voidsetDataElems(Object elems)Sets the data elements of this data node.voidsetReadOnly(boolean readOnly)voidsetSynthetic(boolean synthetic)voidsetUnit(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_Xconstants
-
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:
acceptVisitorin 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:
getRawStorageSizein classProductNode- Parameters:
subsetDef- if notnullthe 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:
disposein classProductNode
-
createCompatibleProductData
public ProductData createCompatibleProductData(int numElems)
Creates product data that is compatible to this dataset's data type. The data buffer returned contains exactlynumElemselements 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
-
-