Package org.apache.tika.metadata
Class KeyPrefix
java.lang.Object
org.apache.tika.metadata.KeyPrefix
A Tika-owned prefix under which keys are passed through from the source: the prefix is fixed, but
each key name comes verbatim from the document or tool, so keys are unbounded and can't be
Property constants. Declaring one self-registers it, so the open set is enumerable (as
Property makes the closed set) and lintable: a String write is legitimate iff its key is a
registered Property or its prefix is a registered KeyPrefix.
Writes under a prefix go through Metadata.add(KeyPrefix, String, String) (or its
Instant overload for source-typed dates) — append-only, with built-in skip-and-WARN
handling of blank, over-length, or flooding source-derived names.
KeyPrefix instances are declaration-time constants. Declare one as a
static final field, the same way a curated Property constant is declared — never
construct one from document-derived text, and never construct one per-parse: the registry is
static and unbounded, so per-parse construction grows it forever. An identical redeclaration
(class re-init in another classloader) returns the incumbent; a conflicting one throws
IllegalStateException.
- Since:
- Apache Tika 4.0.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyPrefixDeclares a FILE-provenance prefix: names read from the document itself.static KeyPrefixThe registered prefix instance forprefix, ornull.The full key for a source-derivedsuffix.prefix()static Collection<KeyPrefix> Declared prefixes, from loaded classes only.static KeyPrefixDeclares a TOOL-provenance prefix: names coined by an external tool or service.toString()The prefix, so a String→KeyPrefix flip doesn't turn existing logging/concatenation intoKeyPrefix@<hex>with no compile signal.
-
Method Details
-
file
Declares a FILE-provenance prefix: names read from the document itself. An identical redeclaration (same provenance and description, e.g. class re-initialization in another classloader) returns the incumbent instance.- Throws:
IllegalArgumentException- ifprefixis null, empty, reserved, or lacks a trailing delimiterIllegalStateException- ifprefixis already registered with a different provenance or description
-
tool
Declares a TOOL-provenance prefix: names coined by an external tool or service. An identical redeclaration returns the incumbent instance; seefile(java.lang.String, java.lang.String).- Throws:
IllegalArgumentException- ifprefixis null, empty, reserved, or lacks a trailing delimiterIllegalStateException- ifprefixis already registered with a different provenance or description
-
get
The registered prefix instance forprefix, ornull. -
key
The full key for a source-derivedsuffix.- Throws:
IllegalArgumentException- ifsuffixis null or empty
-
prefix
-
provenance
-
description
-
toString
The prefix, so a String→KeyPrefix flip doesn't turn existing logging/concatenation intoKeyPrefix@<hex>with no compile signal. -
registered
Declared prefixes, from loaded classes only.
-