Package org.apache.sis.storage.geotiff
Class XMLMetadata
java.lang.Object
org.apache.sis.storage.geotiff.XMLMetadata
- All Implemented Interfaces:
Filter
Supports for metadata encoded in XML inside a GeoTIFF tags.
This is a temporary object used only at parsing time.
Two TIFF tags are associated to XML data:
GDAL_METADATA
(A480) stored as ASCII characters.GEO_METADATA
(C6DD) stored as bytes with UTF-8 encoding.
GEO_METADATA
is defined by the Defense Geospatial Information Working Group (DGIWG)
in the GeoTIFF Profile for Georeferenced Imagery standard.- Since:
- 1.2
- Version:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Parser of GDAL metadata.(package private) static final class
A tree-table representation of the XML document contained in the enclosingXMLMetadata
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
The bytes to decode as an XML document.private String
Name of the XML element being processed.private final boolean
true
if the XML is GDAL metadata.private static final String
The "Item" string, used in GDAL metadata.private final StoreListeners
Where to report non-fatal warnings.private static final String
The "name" string, used in GDAL metadata.private XMLMetadata
The next metadata in a list of linked metadata.private String
The XML document as string. -
Constructor Summary
ConstructorsConstructorDescriptionXMLMetadata
(String xml, boolean isGDAL) Creates a new instance with the given XML.XMLMetadata
(Reader reader, Type type, long count, short tag) Creates new metadata which will decode the given vector of bytes. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
append
(XMLEventReader reader, StartElement element, TreeTable.Node node) Converts an XML element and its children to a tree table node.appendTo
(MetadataBuilder metadata) Appends the content of this object to the given metadata builder.(package private) final void
appendTo
(XMLMetadata head) Appends this metadata at the end of a linked list starting with the given element.boolean
isEmpty()
Returnstrue
if the XML document could not be read.boolean
isLoggable
(LogRecord warning) Invoked when a non-fatal warning occurs during the parsing of XML document.(package private) String
tag()
Returns the name of the tag from which the XML has been read.toString()
Returns the XML document as a character string, ornull
if the document could not be read.private XMLEventReader
toXML()
Returns a reader for the XML document, ornull
if the document could not be read.
-
Field Details
-
ITEM
The "Item" string, used in GDAL metadata.- See Also:
-
NAME
The "name" string, used in GDAL metadata.- See Also:
-
bytes
private byte[] bytesThe bytes to decode as an XML document. DGIWG specification mandates UTF-8 encoding. -
string
The XML document as string. -
currentElement
Name of the XML element being processed. Used for error message only: this field is left to a non-null value if an exception occurred during XML parsing. -
listeners
Where to report non-fatal warnings. -
isGDAL
private final boolean isGDALtrue
if the XML is GDAL metadata. Example: -
next
The next metadata in a list of linked metadata. Should always benull
, but we nevertheless define this field in case a file defines more than oneGEO_METADATA
orGDAL_METADATA
tags.
-
-
Constructor Details
-
XMLMetadata
XMLMetadata(String xml, boolean isGDAL) Creates a new instance with the given XML. Used for testing purposes. -
XMLMetadata
XMLMetadata(Reader reader, Type type, long count, short tag) throws IOException Creates new metadata which will decode the given vector of bytes.- Parameters:
reader
- the TIFF reader.type
- type of the metadata tag to read.count
- number of bytes or characters in the value to read.tag
- the tag where the metadata was stored.- Throws:
IOException
-
-
Method Details
-
appendTo
Appends this metadata at the end of a linked list starting with the given element. This method is inefficient because it iterates over all elements for reaching the tail, but it should not be an issue because this method is invoked only in the unlikely case where a file would define more than one*_METADATA
tag.- Parameters:
head
- first element of the linked list where to append this metadata.
-
tag
String tag()Returns the name of the tag from which the XML has been read. This is used for error messages. -
isEmpty
public boolean isEmpty()Returnstrue
if the XML document could not be read. -
toString
Returns the XML document as a character string, ornull
if the document could not be read. -
toXML
Returns a reader for the XML document, ornull
if the document could not be read.- Throws:
XMLStreamException
-
append
private void append(XMLEventReader reader, StartElement element, TreeTable.Node node) throws XMLStreamException Converts an XML element and its children to a tree table node. This is used forNativeMetadata
representation.- Parameters:
reader
- the XML reader with its cursor set after the XML element.element
- the XML element to append.node
- an initially empty node which is added to the tree.- Throws:
XMLStreamException
-
appendTo
Appends the content of this object to the given metadata builder.- Parameters:
metadata
- the builder where to append the content of thisXMLMetadata
.- Returns:
- the next metadata in a linked list of metadata, or
null
if none. - Throws:
XMLStreamException
- if an error occurred while parsing the XML.JAXBException
- if an error occurred while parsing the XML.
-
isLoggable
Invoked when a non-fatal warning occurs during the parsing of XML document.- Specified by:
isLoggable
in interfaceFilter
-