org.ow2.weblab.service.normaliser.tika.metadatawriter
Class MetadataWriter

java.lang.Object
  extended by org.ow2.weblab.service.normaliser.tika.metadatawriter.MetadataWriter
Direct Known Subclasses:
DefaultMetaDataWriter

public abstract class MetadataWriter
extends java.lang.Object

This class is the base class for MetadataWriters. It contains the mapping between metadata as found by Tika to Weblab ontology (or any ontology you'd like) and write these metadata in the Weblab resource according to the PokHelper given. As this class does not contain any mapping, a subclass must be created. This subclass have to provide an implementation for init method which basically makes calls to addMapping method. This method takes MappingDescription (or one of its subclasses) instances.

Author:
Frédéric Praca
See Also:
PoKHelper, Metadata, MappingDescription

Field Summary
protected  org.apache.commons.logging.Log logger
          The logger to be used inside this class.
 
Constructor Summary
MetadataWriter()
          Default constructor used by subclasses
 
Method Summary
protected  void addMapping(java.lang.String propertyToMap, MappingDescription toDescription)
          Method used by subclass in their init method to add a mapping
protected abstract  void init()
          Method to implement in subclass.
 void write(Metadata metadataToWrite, PoKHelper pokHelperToWriteInto, java.net.URI documentUri)
          This method allows to write the Metadata created by Tika inside the correct part of the document pointed out by a PokHelper instance.
protected  void writeUnmmappedMetadata(Metadata metadataToWrite, java.lang.String name, PoKHelper pokHelperToWriteInto, java.net.URI documentUri)
          This method aims to write a metadata that was not mapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
The logger to be used inside this class.

Constructor Detail

MetadataWriter

public MetadataWriter()
Default constructor used by subclasses

Method Detail

write

public void write(Metadata metadataToWrite,
                  PoKHelper pokHelperToWriteInto,
                  java.net.URI documentUri)
This method allows to write the Metadata created by Tika inside the correct part of the document pointed out by a PokHelper instance. Each annotation is written to reference the URI of the document provided.

Parameters:
metadataToWrite - The Metadata object to map and write
pokHelperToWriteInto - The PokHelper used to write into the document
documentUri - The URI of the document that should be used for reference

addMapping

protected void addMapping(java.lang.String propertyToMap,
                          MappingDescription toDescription)
Method used by subclass in their init method to add a mapping

Parameters:
propertyToMap - the Tika property name to map
toDescription - the description to use for mapping. Can be instance of MappingDescription or one of its subclass.

init

protected abstract void init()
Method to implement in subclass. Should basically be a set of calls to addMapping


writeUnmmappedMetadata

protected void writeUnmmappedMetadata(Metadata metadataToWrite,
                                      java.lang.String name,
                                      PoKHelper pokHelperToWriteInto,
                                      java.net.URI documentUri)
This method aims to write a metadata that was not mapped. By default, this method only logs in debug mode that the property was not mapped. For a different behaviour, this method should be overridden

Parameters:
metadataToWrite - The Metadata object to map and write
name - Name of the metadata which is not mapped
pokHelperToWriteInto - The PokHelper used to write into the document
documentUri - The URI of the document that should be used for reference


Copyright © 2004-2012. All Rights Reserved.