Package org.esa.snap.core.metadata
Class XmlMetadata
- java.lang.Object
-
- org.esa.snap.core.metadata.GenericXmlMetadata
-
- org.esa.snap.core.metadata.XmlMetadata
-
public abstract class XmlMetadata extends GenericXmlMetadata
Base metadata class that exposes helper methods for easier access of interesting metadata values.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
height
protected int
numBands
protected int
width
-
Fields inherited from class org.esa.snap.core.metadata.GenericXmlMetadata
attributeMap, logger, MISSING_ELEMENT_WARNING, name, NO_SUCH_PATH_WARNING, path, rootElement
-
-
Constructor Summary
Constructors Constructor Description XmlMetadata(String name)
Constructs an instance of metadata class and assigns a name to the rootMetadataElement
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected float
asFloat(String value)
Silently converts a string to a float (i.e.protected float[]
asFloatArray(String value, String separator)
Converts the value to a float array.protected int
asInt(String value)
Silently converts a string to a int (i.e.abstract ProductData.UTC
getCenterTime()
Returns the product center time in UTC format.abstract String
getFormatName()
Returns the name of the raster format (for example: TIFF, NITF, etc).abstract int
getNumBands()
Returns the number of bands of the product.abstract String
getProductDescription()
Returns the product description, preferably from metadataabstract ProductData.UTC
getProductEndTime()
Returns the product end time in UTC format.abstract String
getProductName()
Returns the name of the product, as found in metadata.abstract ProductData.UTC
getProductStartTime()
Returns the product start time in UTC format.abstract String[]
getRasterFileNames()
Returns the names of raster files for the product.abstract int
getRasterHeight()
Returns the height of the product, in pixels.abstract int
getRasterWidth()
Returns the width of the product, in pixels.void
setName(String value)
Sets the name of this metadata (and also the name of the root element).-
Methods inherited from class org.esa.snap.core.metadata.GenericXmlMetadata
CopyChildElements, create, create, create, ensureAttributeTagPresent, getAttributeSiblingValue, getAttributeValue, getAttributeValue, getAttributeValues, getFileName, getMetadataProfile, getPath, getRootElement, indexAttribute, loadMetadata, setFileName, setPath, warn
-
-
-
-
Constructor Detail
-
XmlMetadata
public XmlMetadata(String name)
Constructs an instance of metadata class and assigns a name to the rootMetadataElement
.- Parameters:
name
- The name of this instance, and also the initial name of the root element.
-
-
Method Detail
-
getNumBands
public abstract int getNumBands()
Returns the number of bands of the product. This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.- Returns:
- the number of bands
-
getProductName
public abstract String getProductName()
Returns the name of the product, as found in metadata. This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.- Returns:
- The name of the product
-
getFormatName
public abstract String getFormatName()
Returns the name of the raster format (for example: TIFF, NITF, etc).This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.
- Returns:
- The raster format name/code.
-
getRasterWidth
public abstract int getRasterWidth()
Returns the width of the product, in pixels. This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.- Returns:
- The width (in pixels) of the product.
-
getRasterHeight
public abstract int getRasterHeight()
Returns the height of the product, in pixels. This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.- Returns:
- The height (in pixels) of the product.
-
getRasterFileNames
public abstract String[] getRasterFileNames()
Returns the names of raster files for the product. This getter should be overridden in all derived classes because each metadata type may have a different hierarchy of nodes for getting this value.- Returns:
- An array of raster file names.
-
setName
public void setName(String value)
Sets the name of this metadata (and also the name of the root element).- Overrides:
setName
in classGenericXmlMetadata
- Parameters:
value
- The name of the metadata file.
-
getProductStartTime
public abstract ProductData.UTC getProductStartTime()
Returns the product start time in UTC format. This method has to be implemented by subclasses since the value may be or may not be present in metadata, or may be in different formats for different products.- Returns:
- the product start time
-
getProductEndTime
public abstract ProductData.UTC getProductEndTime()
Returns the product end time in UTC format. This method has to be implemented by subclasses since the value may be or may not be present in metadata, or may be in different formats for different products.- Returns:
- the product end time
-
getCenterTime
public abstract ProductData.UTC getCenterTime()
Returns the product center time in UTC format. This method has to be implemented by subclasses since the value may be or may not be present in metadata, or may be in different formats for different products.- Returns:
- the product center time.
-
getProductDescription
public abstract String getProductDescription()
Returns the product description, preferably from metadata- Returns:
- the product description
-
asFloatArray
protected float[] asFloatArray(String value, String separator)
Converts the value to a float array.- Parameters:
value
- The string list of valuesseparator
- The items separator- Returns:
- An array of float values
-
asFloat
protected float asFloat(String value)
Silently converts a string to a float (i.e. without throwing exception for unconvertible values)- Parameters:
value
- The value to be converted- Returns:
- The float value or
Float.NaN
if the conversion cannot be performed.
-
asInt
protected int asInt(String value)
Silently converts a string to a int (i.e. without throwing exception for unconvertible values)- Parameters:
value
- The value to be converted- Returns:
- The int value or
0
if the conversion cannot be performed.
-
-