Package org.apache.tika.parser.xml
Class ElementMetadataHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.tika.parser.xml.ElementMetadataHandler
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
public class ElementMetadataHandler extends DefaultHandler
SAX event handler that maps the contents of an XML element into a metadata field.- Since:
- Apache Tika 0.10
-
-
Constructor Summary
Constructors Constructor Description ElementMetadataHandler(String uri, String localName, Metadata metadata, String name)Constructor for string metadata keys.ElementMetadataHandler(String uri, String localName, Metadata metadata, String name, boolean allowDuplicateValues, boolean allowEmptyValues)Constructor for string metadata keys which allows change of behavior for duplicate and empty entry values.ElementMetadataHandler(String uri, String localName, Metadata metadata, Property targetProperty)Constructor for Property metadata keys.ElementMetadataHandler(String uri, String localName, Metadata metadata, Property targetProperty, boolean allowDuplicateValues, boolean allowEmptyValues)Constructor for Property metadata keys which allows change of behavior for duplicate and empty entry values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddMetadata(String value)Adds the given metadata value.voidcharacters(char[] ch, int start, int length)voidendElement(String uri, String localName, String name)voidignorableWhitespace(char[] ch, int start, int length)protected booleanisMatchingElement(String uri, String localName)protected booleanisMatchingParentElement(String uri, String localName)voidstartElement(String uri, String localName, String name, Attributes attributes)-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Constructor Detail
-
ElementMetadataHandler
public ElementMetadataHandler(String uri, String localName, Metadata metadata, String name)
Constructor for string metadata keys.- Parameters:
uri- the uri of the namespace of the elementlocalName- the local name of the elementmetadata- the Tika metadata object to populatename- the Tika metadata field key
-
ElementMetadataHandler
public ElementMetadataHandler(String uri, String localName, Metadata metadata, String name, boolean allowDuplicateValues, boolean allowEmptyValues)
Constructor for string metadata keys which allows change of behavior for duplicate and empty entry values.- Parameters:
uri- the uri of the namespace of the elementlocalName- the local name of the elementmetadata- the Tika metadata object to populatename- the Tika metadata field keyallowDuplicateValues- add duplicate values to the Tika metadataallowEmptyValues- add empty values to the Tika metadata
-
ElementMetadataHandler
public ElementMetadataHandler(String uri, String localName, Metadata metadata, Property targetProperty)
Constructor for Property metadata keys.- Parameters:
uri- the uri of the namespace of the elementlocalName- the local name of the elementmetadata- the Tika metadata object to populatetargetProperty- the Tika metadata Property key
-
ElementMetadataHandler
public ElementMetadataHandler(String uri, String localName, Metadata metadata, Property targetProperty, boolean allowDuplicateValues, boolean allowEmptyValues)
Constructor for Property metadata keys which allows change of behavior for duplicate and empty entry values.- Parameters:
uri- the uri of the namespace of the elementlocalName- the local name of the elementmetadata- the Tika metadata object to populatetargetProperty- the Tika metadata Property keyallowDuplicateValues- add duplicate values to the Tika metadataallowEmptyValues- add empty values to the Tika metadata
-
-
Method Detail
-
startElement
public void startElement(String uri, String localName, String name, Attributes attributes)
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler
-
endElement
public void endElement(String uri, String localName, String name)
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length)- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length)- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler
-
addMetadata
protected void addMetadata(String value)
Adds the given metadata value. The value is ignored if it isnullor empty. If the metadata entry already exists, then the given value is appended to it with a comma as the separator.- Parameters:
value- metadata value
-
-