jeters.components
Class RegExReplacer.Replacement

java.lang.Object
  extended by jeters.components.RegExReplacer.Replacement
All Implemented Interfaces:
RegExReplacer.ReplacementElement
Enclosing class:
RegExReplacer

public static class RegExReplacer.Replacement
extends java.lang.Object
implements RegExReplacer.ReplacementElement

a class that represents a single regex-pair together with other necessary information for performing replacements


Field Summary
 java.lang.String description
          a string describing this replacement.
 int rating
          a rating of this replacement's importance (possible values: 0, positive integers).
 java.lang.String regex
          regular expression that will be replaced.
 java.lang.String rwith
          the string the regex is replaced with.
 int times
          how often the replaceAll-function is called for this replacement.
 
Constructor Summary
RegExReplacer.Replacement(int times, java.lang.String regex, java.lang.String rwith)
          constructor that sets description to "" and rating to 0.
RegExReplacer.Replacement(int times, java.lang.String regex, java.lang.String rwith, int rating)
          constructor that sets description to "".
RegExReplacer.Replacement(int times, java.lang.String regex, java.lang.String rwith, java.lang.String description)
          constructor that sets rating to 0.
RegExReplacer.Replacement(int times, java.lang.String regex, java.lang.String rwith, java.lang.String description, int rating)
          constructor that has parameters for all attributes.
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regex

public java.lang.String regex
regular expression that will be replaced.


rwith

public java.lang.String rwith
the string the regex is replaced with. May contain back references like $3 (compare "Capturing groups" in Java API entry for java.util.regex.Pattern).


times

public int times
how often the replaceAll-function is called for this replacement. Possible values are -1 (unlimited, until every occurrence of regex is replaced), 0 (this replacement will ignored) and positive integers. The most common values are 1 and -1, others are rarely used.

Explanation/Examples:
Usually, even a value of 1 will replace every occurrence of regex. However, Java's replaceAll-function won't go back to look for regex again.
Examples (regex = "bcd"; rwith = "c"):
times = 1: "bbcdd" -> "bcd"
times = 2: "bbcdd" -> "bcd" -> "c"
times = 1: "bcdbcd" -> "cc"


description

public java.lang.String description
a string describing this replacement. It is used for generating the MediaWiki comment.


rating

public int rating
a rating of this replacement's importance (possible values: 0, positive integers). It may be used to decide whether the user is asked for confirmation (the minimum rating for a user request depends on the settings). Therefore, larger and more "dangerous" edits should get a higher rating. It is also a factor for determining the order of the entries in the MediaWiki comment.

Constructor Detail

RegExReplacer.Replacement

public RegExReplacer.Replacement(int times,
                                 java.lang.String regex,
                                 java.lang.String rwith,
                                 java.lang.String description,
                                 int rating)
constructor that has parameters for all attributes.


RegExReplacer.Replacement

public RegExReplacer.Replacement(int times,
                                 java.lang.String regex,
                                 java.lang.String rwith)
constructor that sets description to "" and rating to 0. It can be used if you feel that the replacement absolutely does not require the user's attention.


RegExReplacer.Replacement

public RegExReplacer.Replacement(int times,
                                 java.lang.String regex,
                                 java.lang.String rwith,
                                 int rating)
constructor that sets description to "".


RegExReplacer.Replacement

public RegExReplacer.Replacement(int times,
                                 java.lang.String regex,
                                 java.lang.String rwith,
                                 java.lang.String description)
constructor that sets rating to 0.