Class MetadataElement
- All Implemented Interfaces:
 Extensible
- Direct Known Subclasses:
 SampleCoding
MetadataElement is a data node used to store metadata. Metadata elements can have any number of
 metadata attributes of the type MetadataAttribute and any number of inner MetadataElements.- Version:
 - $Revision: 6651 $ $Date: 2009-10-27 12:59:39 +0100 (Di, 27 Okt 2009) $
 
- 
Field Summary
Fields inherited from class org.esa.snap.core.datamodel.ProductNode
PROPERTY_NAME_DESCRIPTION, PROPERTY_NAME_NAME - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionvoidacceptVisitor(ProductVisitor visitor) Accepts the given visitor.voidaddAttribute(MetadataAttribute attribute) Adds an attribute to this node.voidaddElement(MetadataElement element) Adds the given element to this element.voidaddElementAt(MetadataElement element, int index) Adds the given element to this element at index.booleancontainsAttribute(String name) Checks whether this node has an element with the given name.booleancontainsElement(String name) Tests if a element with the given name is contained in this element.voiddispose()Releases all of the resources used by this object instance and all of its owned children.getAttribute(String name) Returns the attribute with the given name.getAttributeAt(int index) Returns the attribute at the given index.doublegetAttributeDouble(String name) Returns the double value of the attribute with the given name.doublegetAttributeDouble(String name, double defaultValue) Returns the double value of the attribute with the given name.intgetAttributeIndex(MetadataAttribute attribute) Gets the index of the given attribute.intgetAttributeInt(String name) Returns the integer value of the attribute with the given name.intgetAttributeInt(String name, int defaultValue) Returns the integer value of the attribute with the given name.String[]Returns the names of all attributes of this node.Returns an array of attributes contained in this element.getAttributeString(String name) Returns the string value of the attribute with the given name.getAttributeString(String name, String defaultValue) Returns the string value of the attribute with the given name.getAttributeUTC(String name) Returns the UTC value of the attribute with the given name.getAttributeUTC(String name, ProductData.UTC defaultValue) Returns the UTC value of the attribute with the given name.getElement(String name) Returns the element with the given name.getElementAt(int index) Returns the element at the given index.Gets the group of child elements.intgetElementIndex(MetadataElement element) Gets the index of the given element.String[]Returns a string array containing the names of the groups contained in this elementReturns an array of elements contained in this element.intReturns the number of attributes attached to this node.intlonggetRawStorageSize(ProductSubsetDef subsetDef) Gets an estimated, raw storage size in bytes of this product node.booleanremoveAttribute(MetadataAttribute attribute) Removes the given attribute from this annotation.booleanremoveElement(MetadataElement element) Removes the given element from this element.voidsetAttributeDouble(String name, double value) Sets the attribute with the given name to the given double value.voidsetAttributeInt(String name, int value) Sets the attribute with the given name to the given integer value.voidsetAttributeString(String name, String value) Sets the attribute with the given name to the given string value.voidsetAttributeUTC(String name, ProductData.UTC value) Sets the attribute with the given name to the given utc value.voidsetModified(boolean modified) Sets this node's modified flag.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, setName, setNodeName, setOwner, toString, updateExpressionMethods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension 
- 
Constructor Details
- 
MetadataElement
Constructs a new metadata element.- Parameters:
 name- the element name
 
 - 
 - 
Method Details
- 
getElementGroup
Gets the group of child elements. The method returns null, if this element has no children.- Returns:
 - The child element group, may be null.
 
 - 
getParentElement
 - 
addElement
Adds the given element to this element.- Parameters:
 element- the element to added, ignored ifnull
 - 
addElementAt
Adds the given element to this element at index.- Parameters:
 element- the element to added, ignored ifnullindex- where to put it
 - 
removeElement
Removes the given element from this element.- Parameters:
 element- the element to be removed, ignored ifnull- Returns:
 - true, if so
 
 - 
getNumElements
public int getNumElements()- Returns:
 - the number of elements contained in this element.
 
 - 
getElementAt
Returns the element at the given index.- Parameters:
 index- the element index- Returns:
 - the element at the given index
 - Throws:
 IndexOutOfBoundsException- if the index is out of bounds
 - 
getElementNames
Returns a string array containing the names of the groups contained in this element- Returns:
 - a string array containing the names of the groups contained in this element. If this element has no groups a zero-length-array is returned.
 
 - 
getElements
Returns an array of elements contained in this element.- Returns:
 - an array of elements contained in this product. If this element has no elements a zero-length-array is returned.
 
 - 
getElement
Returns the element with the given name.- Parameters:
 name- the element name- Returns:
 - the element with the given name or 
nullif a element with the given name is not contained in this element. 
 - 
containsElement
Tests if a element with the given name is contained in this element.- Parameters:
 name- the name, must not benull- Returns:
 trueif a element with the given name is contained in this element,falseotherwise
 - 
getElementIndex
Gets the index of the given element.- Parameters:
 element- The element .- Returns:
 - The element's index, or -1.
 - Since:
 - BEAM 4.7
 
 - 
addAttribute
Adds an attribute to this node.- Parameters:
 attribute- the attribute to be added,nullis ignored
 - 
removeAttribute
Removes the given attribute from this annotation. If an attribute with the same name already exists, the method does nothing.- Parameters:
 attribute- the attribute to be removed,nullis ignored- Returns:
 trueif it was removed
 - 
getNumAttributes
public int getNumAttributes()Returns the number of attributes attached to this node.- Returns:
 - the number of attributes
 
 - 
getAttributeAt
Returns the attribute at the given index.- Parameters:
 index- the attribute index- Returns:
 - the attribute, or 
nullif this node does not contain attributes - Throws:
 IndexOutOfBoundsException
 - 
getAttributeNames
Returns the names of all attributes of this node.- Returns:
 - the attribute name array, never 
null 
 - 
getAttributes
Returns an array of attributes contained in this element.- Returns:
 - an array of attributes contained in this product. If this element has no attributes a zero-length-array is returned.
 
 - 
getAttribute
Returns the attribute with the given name.- Parameters:
 name- the attribute name- Returns:
 - the attribute with the given name or 
nullif it could not be found 
 - 
containsAttribute
Checks whether this node has an element with the given name.- Parameters:
 name- the attribute name- Returns:
 trueif so
 - 
getAttributeIndex
Gets the index of the given attribute.- Parameters:
 attribute- The attribute.- Returns:
 - The attribute's index, or -1.
 - Since:
 - BEAM 4.7
 
 - 
getAttributeDouble
Returns the double value of the attribute with the given name.The given default value is returned if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute namedefaultValue- the default value- Returns:
 - the attribute value as double.
 - Throws:
 NumberFormatException- if the attribute type is ASCII but cannot be converted to a number
 - 
getAttributeDouble
Returns the double value of the attribute with the given name.An Exception is thrown if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute name- Returns:
 - the attribute value as double.
 - Throws:
 NumberFormatException- if the attribute type is ASCII but cannot be converted to a numberIllegalArgumentException- if an attribute with the given name could not be found
 - 
getAttributeUTC
Returns the UTC value of the attribute with the given name.The given default value is returned if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute namedefaultValue- the default value- Returns:
 - the attribute value as UTC.
 
 - 
getAttributeUTC
Returns the UTC value of the attribute with the given name.- Parameters:
 name- the attribute name- Returns:
 - the attribute value as UTC.
 - Throws:
 IllegalArgumentException- if an attribute with the given name could not be found
 - 
getAttributeInt
Returns the integer value of the attribute with the given name.The given default value is returned if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute namedefaultValue- the default value- Returns:
 - the attribute value as integer.
 - Throws:
 NumberFormatException- if the attribute type is ASCII but cannot be converted to a number
 - 
getAttributeInt
Returns the integer value of the attribute with the given name.An Exception is thrown if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute name- Returns:
 - the attribute value as integer.
 - Throws:
 NumberFormatException- if the attribute type is ASCII but cannot be converted to a numberIllegalArgumentException- if an attribute with the given name could not be found
 - 
setAttributeInt
Sets the attribute with the given name to the given integer value.A new attribute with
ProductData.TYPE_INT32is added to this node if an attribute with the given name could not be found in this node.- Parameters:
 name- the attribute namevalue- the new value
 - 
setAttributeDouble
Sets the attribute with the given name to the given double value.A new attribute with
ProductData.TYPE_FLOAT64is added to this node if an attribute with the given name could not be found in this node.- Parameters:
 name- the attribute namevalue- the new value
 - 
setAttributeUTC
Sets the attribute with the given name to the given utc value.A new attribute with
ProductData.UTCis added to this node if an attribute with the given name could not be found in this node.- Parameters:
 name- the attribute namevalue- the new value
 - 
getAttributeString
Returns the string value of the attribute with the given name.An Exception is thrown if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute name- Returns:
 - the attribute value as integer.
 - Throws:
 IllegalArgumentException- if an attribute with the given name could not be found
 - 
getAttributeString
Returns the string value of the attribute with the given name.The given default value is returned if an attribute with the given name could not be found in this node.
- Parameters:
 name- the attribute namedefaultValue- the default value- Returns:
 - the attribute value as integer.
 
 - 
setAttributeString
Sets the attribute with the given name to the given string value.A new attribute with
ProductData.TYPE_ASCIIis added to this node if an attribute with the given name could not be found in this node.- Parameters:
 name- the attribute namevalue- the new value
 - 
setModified
public void setModified(boolean modified) Description copied from class:ProductNodeSets 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.
- Overrides:
 setModifiedin classProductNode- Parameters:
 modified- whether or not this node is beeing marked as modified.- See Also:
 
 - 
acceptVisitor
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.The method first visits (calls
acceptVisitorfor) all elements contained in this element and then visits all attributes. Finally the method callsvisitor.visit(this).- Specified by:
 acceptVisitorin classProductNode- Parameters:
 visitor- the visitor
 - 
getRawStorageSize
Gets an estimated, raw storage 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.
 
 - 
createDeepClone
 - 
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
 
 -