com.norconex.importer.transformer.impl
Class StripAfterTransformer

java.lang.Object
  extended by com.norconex.importer.transformer.AbstractRestrictiveTransformer
      extended by com.norconex.importer.transformer.AbstractCharStreamTransformer
          extended by com.norconex.importer.transformer.AbstractStringTransformer
              extended by com.norconex.importer.transformer.impl.StripAfterTransformer
All Implemented Interfaces:
IXMLConfigurable, IImportHandler, IDocumentTransformer, Serializable

public class StripAfterTransformer
extends AbstractStringTransformer
implements IXMLConfigurable

Strips any content found after first match found for given pattern.

This class can be used as a pre-parsing (text content-types only) or post-parsing handlers.

XML configuration usage:

  <transformer class="com.norconex.importer.transformer.impl.StripAfterTransformer"
          inclusive="[false|true]" 
          caseSensitive="[false|true]" >
      <contentTypeRegex>
          (regex to identify text content-types for pre-import, 
           overriding default)
      </contentTypeRegex>
      <restrictTo
              caseSensitive="[false|true]" >
              property="(name of header/metadata name to match)"
          (regular expression of value to match)
      </restrictTo>
      <stripAfterRegex>(regex)</stripAfterRegex>
  </transformer>
 

Author:
Pascal Essiembre
See Also:
Serialized Form

Constructor Summary
StripAfterTransformer()
           
 
Method Summary
 boolean equals(Object obj)
           
 String getStripAfterRegex()
           
 int hashCode()
           
 boolean isCaseSensitive()
           
 boolean isInclusive()
           
 void loadFromXML(Reader in)
           
 void saveToXML(Writer out)
           
 void setCaseSensitive(boolean caseSensitive)
          Sets whether to ignore case when matching start and end text.
 void setInclusive(boolean inclusive)
          Sets whether start and end text pairs should themselves be stripped or not.
 void setStripAfterRegex(String regex)
           
 String toString()
           
protected  void transformStringDocument(String reference, StringBuilder content, Properties metadata, boolean parsed, boolean partialContent)
           
 
Methods inherited from class com.norconex.importer.transformer.AbstractStringTransformer
transformTextDocument
 
Methods inherited from class com.norconex.importer.transformer.AbstractCharStreamTransformer
getContentTypeRegex, loadFromXML, saveToXML, setContentTypeRegex, transformRestrictedDocument
 
Methods inherited from class com.norconex.importer.transformer.AbstractRestrictiveTransformer
setRestriction, transformDocument
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StripAfterTransformer

public StripAfterTransformer()
Method Detail

transformStringDocument

protected void transformStringDocument(String reference,
                                       StringBuilder content,
                                       Properties metadata,
                                       boolean parsed,
                                       boolean partialContent)
Specified by:
transformStringDocument in class AbstractStringTransformer

isInclusive

public boolean isInclusive()

setInclusive

public void setInclusive(boolean inclusive)
Sets whether start and end text pairs should themselves be stripped or not.

Parameters:
inclusive - true to strip start and end text

isCaseSensitive

public boolean isCaseSensitive()

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Sets whether to ignore case when matching start and end text.

Parameters:
caseSensitive - true to consider character case

getStripAfterRegex

public String getStripAfterRegex()

setStripAfterRegex

public void setStripAfterRegex(String regex)

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 AbstractStringTransformer

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractStringTransformer

equals

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


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