Class MetadataKeyValidator

java.lang.Object
org.apache.tika.metadata.schema.MetadataKeyValidator

public final class MetadataKeyValidator extends Object
Registry-driven lint: classifies a metadata key against the committed registries rather than a hand-coded rule. A key is legitimate iff it is an enumerated closed key (metadata-keys.json), sits under a registered passthrough prefix (metadata-open-namespaces.json), or is a documented template instance. Anything else is MetadataKeyValidator.Classification.UNKNOWN — a typo, an unregistered namespace, or a key someone forgot to declare.

Reads the JSON snapshots (which MetadataSchemaTest gates against the live declarations), so it needs no parser classes loaded and stays dependency-free.

  • Method Details

    • fromClasspath

      public static MetadataKeyValidator fromClasspath()
      Loads the validator from the committed registries on the classpath.
    • classify

    • isLegitimate

      public boolean isLegitimate(String key)
    • moduleOf

      public String moduleOf(String key)
      The supplying module (Maven artifactId) of the registry entry that classifies key -- the key itself for CLOSED, the matched prefix for OPEN. Empty for TEMPLATE/UNKNOWN or if the registry didn't attribute a module for that entry.
    • findUnknown

      public List<String> findUnknown(Iterable<String> names)
      The unregistered keys among names, in encounter order.