Class SchemaGenerator

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

public final class SchemaGenerator extends Object
Generates the machine-readable metadata key registry (metadata-keys.json) from the live Property declarations. Dependency-free: it scans the runtime classpath for classes that declare a Property field, force-loads them (their static init registers into the global Property table), then serializes that table as stable, sorted JSON.

The generated file is committed; MetadataSchemaTest regenerates and asserts no diff, so the registry can never drift from the declarations.

TIKA-4797: fieldTable() additionally emits a {class, field, key} table (the field provenance that Property.PROPERTIES discards) so the 3.x→4.x key migration can be built by a field-identity join. Synthesized keys with no declaring field (digests) are absent from that table by design; they migrate by prefix rule.

  • Method Details

    • generate

      public static String generate() throws Exception
      Returns:
      the registry as stable JSON (sorted by key).
      Throws:
      Exception
    • fieldTable

      public static String fieldTable() throws Exception
      TIKA-4797. @return the field-attributed table [{class, field, key}] as stable JSON, sorted by class#field — one record per static Property constant. Aliases (two fields, same key) are distinct records; that is what lets the migration join detect renames.
      Throws:
      Exception
    • passthroughJson

      public static String passthroughJson()
      Declared passthrough prefixes as stable JSON. Call after generate() has loaded classes (and populated lastPrefixModules).
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception