com.norconex.importer.tagger.impl
Class ForceSingleValueTagger

java.lang.Object
  extended by com.norconex.importer.tagger.impl.ForceSingleValueTagger
All Implemented Interfaces:
IXMLConfigurable, IImportHandler, IDocumentTagger, Serializable

public class ForceSingleValueTagger
extends Object
implements IDocumentTagger, IXMLConfigurable

Forces a metadata field to be single-value. The action can be one of the following:

Can be used both as a pre-parse or post-parse handler.

    keepFirst          Keeps the first occurrence found.
    keepLast           Keeps the first occurrence found.
    mergeWith:<sep>    Merges all occurrences, joining them with the
                       specified separator (<sep>). 
 

If you do not specify any action, the default behavior is to merge all occurrences, joining values with a comma.

XML configuration usage:

  <tagger class="com.norconex.importer.tagger.impl.SingleValueTagger">
      <singleValue field="FIELD_NAME" action="[keepFirst|keepLast|mergeWith:<separator>]"/>
      <-- multiple single value fields allowed -->
  </tagger>
 

Author:
Pascal Essiembre
See Also:
Serialized Form

Constructor Summary
ForceSingleValueTagger()
           
 
Method Summary
 void addSingleValueField(String field, String action)
           
 boolean equals(Object obj)
           
 Map<String,String> getSingleValueFields()
           
 int hashCode()
           
 void loadFromXML(Reader in)
           
 void removeSingleValueField(String name)
           
 void saveToXML(Writer out)
           
 void tagDocument(String reference, InputStream document, Properties metadata, boolean parsed)
          Tags a document with extra metadata information.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForceSingleValueTagger

public ForceSingleValueTagger()
Method Detail

tagDocument

public void tagDocument(String reference,
                        InputStream document,
                        Properties metadata,
                        boolean parsed)
                 throws IOException
Description copied from interface: IDocumentTagger
Tags a document with extra metadata information.

Specified by:
tagDocument in interface IDocumentTagger
Parameters:
reference - document reference (e.g. URL)
document - document
metadata - document metadata
parsed - whether the document has been parsed already or not (a parsed document should normally be text-based)
Throws:
IOException - problem reading the document

getSingleValueFields

public Map<String,String> getSingleValueFields()

addSingleValueField

public void addSingleValueField(String field,
                                String action)

removeSingleValueField

public void removeSingleValueField(String name)

loadFromXML

public void loadFromXML(Reader in)
                 throws IOException
Specified by:
loadFromXML in interface IXMLConfigurable
Throws:
IOException

saveToXML

public void saveToXML(Writer out)
               throws IOException
Specified by:
saveToXML in interface IXMLConfigurable
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2009-2013 Norconex Inc.. All Rights Reserved.