public abstract class GenericXmlMetadata extends Object
Modifier and Type | Field and Description |
---|---|
protected Map<String,List<MetadataAttribute>> |
attributeMap |
protected int |
height |
protected Logger |
logger |
protected static String |
MISSING_ELEMENT_WARNING |
protected String |
name |
protected static String |
NO_SUCH_PATH_WARNING |
protected int |
numBands |
protected Path |
path |
protected MetadataElement |
rootElement |
protected int |
width |
Constructor and Description |
---|
GenericXmlMetadata(String name)
Constructs an instance of metadata class and assigns a name to the root
MetadataElement . |
Modifier and Type | Method and Description |
---|---|
static void |
CopyChildElements(MetadataElement source,
MetadataElement target)
Helper method that copies the child nodes of a metadata element as child nodes
of another metadata element.
|
static <T extends GenericXmlMetadata> |
create(Class<T> clazz,
File inputFile) |
static <T extends GenericXmlMetadata> |
create(Class<T> clazz,
Path inputFile)
Factory method for creating instances of classes that (at least) extend
XmlMetadata class. |
static <T extends GenericXmlMetadata> |
create(Class<T> clazz,
String input) |
protected String |
ensureAttributeTagPresent(String path) |
String |
getAttributeSiblingValue(String attributePath,
String attributeValue,
String siblingPath,
String defaultSiblingValue)
Returns the value of the attribute (or the default value) specified by its XPath expression, and whose sibling value is equal to a certain value.
|
String |
getAttributeValue(String attributePath,
int attributeIndex,
String defaultValue)
Returns the value of the attribute (or the default value) specified by its XPath expression and the given index,
when multiple such attributes are present at the same XPath location.
|
String |
getAttributeValue(String attributePath,
String defaultValue)
Returns the value of the attribute (or the default value) specified by its XPath expression.
|
String[] |
getAttributeValues(String attributePath) |
abstract String |
getFileName()
Gets the name of the metadata file used to obtain this instance.
|
abstract String |
getMetadataProfile()
Returns the metadata profile (for example: L1A, etc.)
|
Path |
getPath()
Returns the path of the metadata file.
|
MetadataElement |
getRootElement()
Returns the root node of this metadata file.
|
void |
indexAttribute(String parentElementPath,
MetadataAttribute attribute) |
static <T extends GenericXmlMetadata> |
loadMetadata(Class<T> clazz,
Path inputFile) |
void |
setFileName(String actualName)
Sets the name of the file used to obtain this instance.
|
void |
setName(String value)
Sets the name of this metadata (and also the name of the root element).
|
void |
setPath(Path value)
Sets the path of the metadata file.
|
protected void |
warn(String message,
String argument) |
protected static final String MISSING_ELEMENT_WARNING
protected static final String NO_SUCH_PATH_WARNING
protected final MetadataElement rootElement
protected String name
protected int width
protected int height
protected int numBands
protected Path path
protected Logger logger
protected Map<String,List<MetadataAttribute>> attributeMap
public GenericXmlMetadata(String name)
MetadataElement
.name
- The name of this instance, and also the initial name of the root element.public static void CopyChildElements(MetadataElement source, MetadataElement target)
source
- The metadata element holding the nodes to be copiedtarget
- The destination metadata elementpublic MetadataElement getRootElement()
public abstract String getFileName()
public void setFileName(String actualName)
actualName
- The name of the filepublic abstract String getMetadataProfile()
public Path getPath()
public void setPath(Path value)
value
- The path of the file.public void setName(String value)
value
- The name of the metadata file.public String getAttributeValue(String attributePath, String defaultValue)
attributePath
- the XPath location of the attributedefaultValue
- the default value if the attribute is not found or has a null
valuepublic String getAttributeValue(String attributePath, int attributeIndex, String defaultValue)
attributePath
- the XPath location of the attributeattributeIndex
- the index of the attribute in the attribute arraydefaultValue
- the default value if the attribute is not found or has a null
valuepublic String getAttributeSiblingValue(String attributePath, String attributeValue, String siblingPath, String defaultSiblingValue)
attributePath
- The path of the attribute to be testedattributeValue
- The test valuesiblingPath
- The path of the attribute whose value we want to retrievedefaultSiblingValue
- The default value if the attribute does not exist or the condition of the sibling value is not met.public void indexAttribute(String parentElementPath, MetadataAttribute attribute)
public static <T extends GenericXmlMetadata> T create(Class<T> clazz, String input)
public static <T extends GenericXmlMetadata> T create(Class<T> clazz, File inputFile)
public static <T extends GenericXmlMetadata> T create(Class<T> clazz, Path inputFile)
XmlMetadata
class.T
- Generic type of the metadata class.clazz
- The actual class of the metadata. It should extend XmlMetadata
.inputFile
- The File
object that points to the file to be parsed.T
type.public static <T extends GenericXmlMetadata> T loadMetadata(Class<T> clazz, Path inputFile) throws IOException, InstantiationException, ParserConfigurationException, SAXException
Copyright © 2014–2022 European Space Agency (ESA). All rights reserved.