Metadata Elements
This section explains how to process metadata elements using the KeyView API.
Standardized Elements
When KeyView understands the meaning of a metadata field in a document, it outputs that data in a standardized element - a MetadataElement
where:
isStandard()
returnstrue
.-
getStandardKey()
returns the standard key, which indicates the meaning of the element. For a list of standard keys, refer to the documentation for theMetadataKey
enum in the JavaDocs, or see Standardized Metadata Elements. -
getKey()
returns a string that is uniquely determined by the standard key. If you are handling the value of a standardized element based on its standard key, you can ignore this value. It is provided so that standardized elements can optionally be handled in the same way as non-standardized elements. getHasStandardAlternative()
returnsfalse
.getIsSuperseded()
returns a Boolean that specifies whether this element has been superseded, meaning that this element exists only to preserve backwards compatibility. An element can be superseded to fix issues with the key or value type. When this value istrue
, the same metadata is available through an improvedMetadataElement
in the sameMetadataList
.
Each standardized element is guaranteed to occur at most once in the metadata output. For example, the metadata output will contain zero or one MetadataElement
objects with the standardized name TITLE
.
Non-standardized Elements
Non-standard elements represent native metadata fields. Some non-standard elements might have been used to create a standardized element, and therefore have a standardized alternative. User-created metadata fields, and fields that are unique to one file format, are usually available only as non-standard elements. For a non-standard metadata element:
isStandard()
returnsfalse
.getStandardKey()
returnsOTHER
.getKey()
returns a string representation of a field's key. If a field key exists in the document, that value is returned. Otherwise, KeyView generates a value.getHasStandardAlternative()
returns a Boolean that specifies whether the element has a standardized alternative. When this method returnstrue
, this element contains metadata that also exists in a standardizedMetadataElement
in the sameMetadataList
.getIsSuperseded()
returns a Boolean that specifies whether this element has been superseded, meaning that this element exists only to preserve backwards compatibility. An element can be superseded to fix issues with the key or value type. When this value istrue
, the same metadata is available through an improvedMetadataElement
in the sameMetadataList
.
Field Values
To obtain a field value as a string, you can call the method getValueAsString()
on a MetadataElement
object.
However, you might prefer to process metadata field values as appropriate types through a visitor pattern. To do this, write a class that inherits from the MetadataVisitor
class and handles each of the possible metadata types. Then, pass your class to the accept()
method of a MetadataList
or MetadataElement
object.