Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD


Class COM.stevesoft.pat.Replacer

java.lang.Object
  |
  +--COM.stevesoft.pat.Replacer

public class Replacer
extends java.lang.Object

To use this class, first use either the getReplacer() method from Transformer or Regex. You can then use replaceAll, replaceFirst, etc. methods on the Replacer in the same way that you can from either of those two classes.

The only potential difference between using the methods of Replacer to do the replacing is that Replacer remembers changes to the replacing object between calls to replaceAll, replaceFirst etc. For details, see the example file trans3.java.

See Also:
Transformer, Regex

Constructor Summary
Replacer()
          Instantiate a new Replacer.
 
Method Summary
void apply1(RegRes rr)
           
void apply(RegRes r, ReplaceRule rp)
          This method allows you to apply the results of several matches in a sequence to modify a String of text.
void apply(Regex r)
          Another form of apply, it is the same as apply(r,r.getReplaceRule()).
java.lang.Object clone()
           
java.lang.String finish()
          This finishes the replacement, appending the right() part of the last RegRes given to substitute(RegRes).
boolean isSpecial(ReplaceRule x)
           
int lastMatchedTo()
           
java.lang.String replaceAllFrom(java.lang.String s, int start)
           
java.lang.String replaceAllRegion(java.lang.String s, Regex r, int start, int end)
          This method replaces all occurences of the Regex in the String starting with postition pos according to the Replacer rule of this object.
java.lang.String replaceAllRegion(java.lang.String s, int start, int end)
           
java.lang.String replaceAll(java.lang.String s)
           
java.lang.String replaceFirstFrom(java.lang.String s, int start)
           
java.lang.String replaceFirstRegion(java.lang.String s, Regex r, int start, int end)
          This method replaces the first occurence of the Regex in the String starting with position pos according to the Replacer rule of this object.
java.lang.String replaceFirstRegion(java.lang.String s, int start, int end)
           
java.lang.String replaceFirst(java.lang.String s)
           
boolean WantMoreText()
           

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

Replacer

public Replacer()
Instantiate a new Replacer.
Method Detail

replaceFirstRegion

public java.lang.String replaceFirstRegion(java.lang.String s,
                                 Regex r,
                                 int start,
                                 int end)
This method replaces the first occurence of the Regex in the String starting with position pos according to the Replacer rule of this object.

replaceFirst

public java.lang.String replaceFirst(java.lang.String s)

replaceFirstFrom

public java.lang.String replaceFirstFrom(java.lang.String s,
                               int start)

replaceFirstRegion

public java.lang.String replaceFirstRegion(java.lang.String s,
                                 int start,
                                 int end)

replaceAllRegion

public java.lang.String replaceAllRegion(java.lang.String s,
                               Regex r,
                               int start,
                               int end)
This method replaces all occurences of the Regex in the String starting with postition pos according to the Replacer rule of this object.

replaceAll

public java.lang.String replaceAll(java.lang.String s)

replaceAllFrom

public java.lang.String replaceAllFrom(java.lang.String s,
                             int start)

replaceAllRegion

public java.lang.String replaceAllRegion(java.lang.String s,
                               int start,
                               int end)

isSpecial

public final boolean isSpecial(ReplaceRule x)

apply1

public final void apply1(RegRes rr)

apply

public void apply(RegRes r,
                  ReplaceRule rp)
This method allows you to apply the results of several matches in a sequence to modify a String of text. Each call in the sequence must operate on the same piece of text and the matchedFrom() of each RegRes given to this method must be greater in value than the preceeding RegRes's matchedTo() value.

WantMoreText

public boolean WantMoreText()

apply

public void apply(Regex r)
Another form of apply, it is the same as apply(r,r.getReplaceRule()).

finish

public java.lang.String finish()
This finishes the replacement, appending the right() part of the last RegRes given to substitute(RegRes). After this method is called, the Replace object is reset to perform another substitution. If no RegRes objects with a true didMatch are applied, this returns null.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

lastMatchedTo

public int lastMatchedTo()

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD