public class StripBeforeTransformer extends AbstractStringTransformer implements IXMLConfigurable
Strips any content found before first match found for given pattern.
This class can be used as a pre-parsing (text content-types only) or post-parsing handlers.
<transformer class="com.norconex.importer.handler.transformer.impl.StripBeforeTransformer" inclusive="[false|true]" caseSensitive="[false|true]" sourceCharset="(character encoding)" maxReadSize="(max characters to read at once)" > <restrictTo caseSensitive="[false|true]" field="(name of header/metadata field name to match)"> (regular expression of value to match) </restrictTo> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <stripBeforeRegex>(regex)</stripBeforeRegex> </transformer>
The following will strip all text up to and including this HTML comment:
<!-- HEADER_END -->
.
<transformer class="com.norconex.importer.handler.transformer.impl.StripBeforeTransformer" inclusive="true"> <stripBeforeRegex><![CDATA[<!-- HEADER_END -->]]></stripBeforeRegex> </transformer>
Constructor and Description |
---|
StripBeforeTransformer() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getStripBeforeRegex() |
int |
hashCode() |
boolean |
isCaseSensitive() |
boolean |
isInclusive() |
protected void |
loadStringTransformerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveStringTransformerToXML(EnhancedXMLStreamWriter writer)
Saves configuration settings specific to the implementing class.
|
void |
setCaseSensitive(boolean caseSensitive)
Sets whether to ignore case when matching text.
|
void |
setInclusive(boolean inclusive)
Sets whether the match itself should be stripped or not.
|
void |
setStripBeforeRegex(String regex) |
String |
toString() |
protected void |
transformStringContent(String reference,
StringBuilder content,
ImporterMetadata metadata,
boolean parsed,
int sectionIndex) |
getMaxReadSize, loadCharStreamTransformerFromXML, saveCharStreamTransformerToXML, setMaxReadSize, transformTextDocument
getSourceCharset, loadHandlerFromXML, saveHandlerToXML, setSourceCharset, transformApplicableDocument
transformDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
loadFromXML, saveToXML
protected void transformStringContent(String reference, StringBuilder content, ImporterMetadata metadata, boolean parsed, int sectionIndex)
transformStringContent
in class AbstractStringTransformer
public boolean isInclusive()
public void setInclusive(boolean inclusive)
inclusive
- true
to strip start and end textpublic boolean isCaseSensitive()
public void setCaseSensitive(boolean caseSensitive)
caseSensitive
- true
to consider character casepublic String getStripBeforeRegex()
public void setStripBeforeRegex(String regex)
protected void loadStringTransformerFromXML(org.apache.commons.configuration.XMLConfiguration xml) throws IOException
AbstractStringTransformer
loadStringTransformerFromXML
in class AbstractStringTransformer
xml
- xml configurationIOException
- could not load from XMLprotected void saveStringTransformerToXML(EnhancedXMLStreamWriter writer) throws XMLStreamException
AbstractStringTransformer
saveStringTransformerToXML
in class AbstractStringTransformer
writer
- the xml writerXMLStreamException
- could not save to XMLpublic String toString()
toString
in class AbstractStringTransformer
public int hashCode()
hashCode
in class AbstractStringTransformer
public boolean equals(Object obj)
equals
in class AbstractStringTransformer
Copyright © 2009–2021 Norconex Inc.. All rights reserved.