org.erowid.sperowider.htmlshredding
Class PatternMatchingMongler

java.lang.Object
  extended byorg.erowid.sperowider.htmlshredding.AMongler
      extended byorg.erowid.sperowider.htmlshredding.PatternMatchingMongler

public abstract class PatternMatchingMongler
extends AMongler

Uses pattern matching to perform mongling.

Version:
: $Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/htmlshredding/PatternMatchingMongler.java,v 1.3 2005/01/15 23:26:17 gurustu Exp $
Author:
: $Author: gurustu $

Constructor Summary
PatternMatchingMongler()
           
 
Method Summary
 String getPattern()
          Gets the pattern used to find URLs
 String getReplacementRegex()
          Gets the replacement pattern to replace found URLs with.
 int getURLGroup()
          Gets the number of the pattern group in the pattern set by setPattern(String) that has the actual URL in it.
 boolean isUseReplacementPattern()
          This returns true if the replacement pattern should be used to replace found URLs.
 String mongle(BufferedReader reader)
          Looks for URLs using the passed in pattern.
 void setPattern(String pattern)
          Sets the pattern used to find URLs.
 void setReplacementRegex(String regex)
          Sets the replacement pattern to replace found URLs with.
 void setURLGroup(int group)
          Sets the number of the pattern group in the pattern set by setPattern(String) that has the actual URL in it.
 void setUseReplacementPattern(boolean useReplacementPattern)
          Set this to true if the replacement pattern should be used to replace found URLs.
abstract  String urlFound(String url)
          Extending classes should return the URL to replace the passed in URL, or null to indicate that it should be kept.
 
Methods inherited from class org.erowid.sperowider.htmlshredding.AMongler
mongle, mongle, mongle, mongle, mongle, mongle, mongle, mongle, mongle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PatternMatchingMongler

public PatternMatchingMongler()
Method Detail

urlFound

public abstract String urlFound(String url)
Description copied from class: AMongler
Extending classes should return the URL to replace the passed in URL, or null to indicate that it should be kept.

Specified by:
urlFound in class AMongler

mongle

public String mongle(BufferedReader reader)
              throws IOException
Looks for URLs using the passed in pattern.

Overrides:
mongle in class AMongler
Throws:
IOException

getPattern

public String getPattern()
Gets the pattern used to find URLs


setPattern

public void setPattern(String pattern)
Sets the pattern used to find URLs. By default, this is : \$\{(.*)\}


getURLGroup

public int getURLGroup()
Gets the number of the pattern group in the pattern set by setPattern(String) that has the actual URL in it.

The whole returned element would be 0, the first group (as marked by parens in the regex) would be 1, etc.

For more discussion on this, see Pattern.


setURLGroup

public void setURLGroup(int group)
Sets the number of the pattern group in the pattern set by setPattern(String) that has the actual URL in it.

$0 is the whole returned element, $1 is the first group (as marked by parens), and so on.

For more discussion on this, see Pattern.


getReplacementRegex

public String getReplacementRegex()
Gets the replacement pattern to replace found URLs with.


setReplacementRegex

public void setReplacementRegex(String regex)
Sets the replacement pattern to replace found URLs with.


isUseReplacementPattern

public boolean isUseReplacementPattern()
This returns true if the replacement pattern should be used to replace found URLs. Otherwise, it will be replace by the raw value returned by urlFound(String).


setUseReplacementPattern

public void setUseReplacementPattern(boolean useReplacementPattern)
Set this to true if the replacement pattern should be used to replace found URLs. Otherwise, it will be replace by the raw value returned by urlFound(String).


spero logo small Sperowider is
© 2005 Erowid.org