Closed dragon66 closed 6 years ago
What we have done is to make the Metadata class implement Iterable interface for a collection of MetadataItem. MetadataItem is composed of key-value pair. MetadataItem is defined using composite pattern so that a MetadataItem itself can hold a collection of MetadataItem. This is similar to the menu design. While traversing the MetadataItem collection, there is also a flag we can use to detect whether or not it is a leaf. If we are at the leaf node, we stop there and visit other branches.
For XMP, we can actually create a tree structure with correct indentation (not exactly mimic XML file with open and closing tags). If you want XMP to have a beautiful XML look and feel, you can use XMP.showXMP(XMP xmp).
TestMetadata.java contains a private method printMetadata() to handle the indentation and traversal.
The following is a screenshot from an actual XMP metadata:
There was no direct way to iterate through a specific Metadata in ICAFE before. The showMetadata() method is not consistently implemented for all the Metadata types. To make it easier for user to iterate over different Metadata types in a uniform way, we need to introduce an iterator.