Class StripAfterTransformer
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.transformer.AbstractDocumentTransformer
-
- com.norconex.importer.handler.transformer.AbstractCharStreamTransformer
-
- com.norconex.importer.handler.transformer.AbstractStringTransformer
-
- com.norconex.importer.handler.transformer.impl.StripAfterTransformer
-
- All Implemented Interfaces:
IXMLConfigurable,IImporterHandler,IDocumentTransformer
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:
<handler class="com.norconex.importer.handler.transformer.impl.StripAfterTransformer" inclusive="[false|true]" maxReadSize="(max characters to read at once)" sourceCharset="(character encoding)"> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <restrictTo> <fieldMatcher>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> <stripAfterMatcher> > (expression matching text from which to strip) </stripAfterMatcher> </handler>XML usage example:
<handler class="StripAfterTransformer" inclusive="true"> <stripAfterMatcher> <![CDATA[<!-- FOOTER -->]]> </stripAfterMatcher> </handler>The above example will strip all text starting with the following HTML comment and everything after it:
<!-- FOOTER -->.- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description StripAfterTransformer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object other)TextMatchergetStripAfterMatcher()Gets the matcher for the text from which to strip content.StringgetStripAfterRegex()Deprecated.Since 3.0.0, usegetStripAfterMatcher().inthashCode()booleanisCaseSensitive()Deprecated.Since 3.0.0, usegetStripAfterMatcher().booleanisInclusive()protected voidloadStringTransformerFromXML(XML xml)Loads configuration settings specific to the implementing class.protected voidsaveStringTransformerToXML(XML xml)Saves configuration settings specific to the implementing class.voidsetCaseSensitive(boolean caseSensitive)Deprecated.Since 3.0.0, usesetStripAfterMatcher(TextMatcher).voidsetInclusive(boolean inclusive)Sets whether the match itself should be stripped or not.voidsetStripAfterMatcher(TextMatcher stripAfterMatcher)Sets the matcher for the text from which to strip content.voidsetStripAfterRegex(String regex)Deprecated.Since 3.0.0, usesetStripAfterMatcher(TextMatcher).StringtoString()protected voidtransformStringContent(HandlerDoc doc, StringBuilder content, ParseState parseState, int sectionIndex)-
Methods inherited from class com.norconex.importer.handler.transformer.AbstractStringTransformer
getMaxReadSize, loadCharStreamTransformerFromXML, saveCharStreamTransformerToXML, setMaxReadSize, transformTextDocument
-
Methods inherited from class com.norconex.importer.handler.transformer.AbstractCharStreamTransformer
getSourceCharset, loadHandlerFromXML, saveHandlerToXML, setSourceCharset, transformApplicableDocument
-
Methods inherited from class com.norconex.importer.handler.transformer.AbstractDocumentTransformer
transformDocument
-
Methods inherited from class com.norconex.importer.handler.AbstractImporterHandler
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.norconex.commons.lang.xml.IXMLConfigurable
loadFromXML, saveToXML
-
-
-
-
Method Detail
-
transformStringContent
protected void transformStringContent(HandlerDoc doc, StringBuilder content, ParseState parseState, int sectionIndex)
- Specified by:
transformStringContentin classAbstractStringTransformer
-
getStripAfterMatcher
public TextMatcher getStripAfterMatcher()
Gets the matcher for the text from which to strip content.- Returns:
- text matcher
- Since:
- 3.0.0
-
setStripAfterMatcher
public void setStripAfterMatcher(TextMatcher stripAfterMatcher)
Sets the matcher for the text from which to strip content.- Parameters:
stripAfterMatcher- text matcher- Since:
- 3.0.0
-
isInclusive
public boolean isInclusive()
-
setInclusive
public void setInclusive(boolean inclusive)
Sets whether the match itself should be stripped or not.- Parameters:
inclusive-trueto strip start and end text
-
isCaseSensitive
@Deprecated public boolean isCaseSensitive()
Deprecated.Since 3.0.0, usegetStripAfterMatcher().Gets whether matching is case sensitive.- Returns:
trueif case sensitive
-
setCaseSensitive
@Deprecated public void setCaseSensitive(boolean caseSensitive)
Deprecated.Since 3.0.0, usesetStripAfterMatcher(TextMatcher).Sets whether matching is case sensitive.- Parameters:
caseSensitive-trueif case sensitive
-
getStripAfterRegex
@Deprecated public String getStripAfterRegex()
Deprecated.Since 3.0.0, usegetStripAfterMatcher().Gets the expression matching text after which to strip.- Returns:
- expression
-
setStripAfterRegex
@Deprecated public void setStripAfterRegex(String regex)
Deprecated.Since 3.0.0, usesetStripAfterMatcher(TextMatcher).Sets the expression matching text after which to strip.- Parameters:
regex- expression
-
loadStringTransformerFromXML
protected void loadStringTransformerFromXML(XML xml)
Description copied from class:AbstractStringTransformerLoads configuration settings specific to the implementing class.- Specified by:
loadStringTransformerFromXMLin classAbstractStringTransformer- Parameters:
xml- XML configuration
-
saveStringTransformerToXML
protected void saveStringTransformerToXML(XML xml)
Description copied from class:AbstractStringTransformerSaves configuration settings specific to the implementing class. The parent tag along with the "class" attribute are already written. Implementors must not close the writer.- Specified by:
saveStringTransformerToXMLin classAbstractStringTransformer- Parameters:
xml- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classAbstractStringTransformer
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractStringTransformer
-
toString
public String toString()
- Overrides:
toStringin classAbstractStringTransformer
-
-