com.stevesoft.pat
Class RegRes

java.lang.Object
  |
  +--com.stevesoft.pat.RegRes
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Regex

public class RegRes
extends java.lang.Object
implements java.lang.Cloneable

This class is used to store a result from Regex


Field Summary
protected  int charsMatched_
           
protected  boolean didMatch_
           
protected  int[] marks
           
protected  int matchFrom_
           
protected  int numSubs_
           
protected  StringLike src
           
 
Constructor Summary
RegRes()
           
RegRes(RegRes r)
           
 
Method Summary
 int charsMatched()
          After a successful match, this returns the number of characters in the match, or -1 if the match failed.
 int charsMatched(int i)
          Obtains the number of characters matched by backreference i, or -1 if backreference i was not matched.
 java.lang.Object clone()
           
 void copyOutOf(RegRes r)
           
 boolean didMatch()
          Contains true if the last match was successful.
 boolean equals(RegRes r)
           
 java.lang.String getString()
          Obtain the text String that was matched against.
 StringLike getStringLike()
          Obtain the source StringLike object.
 java.lang.String left()
          This returns the part of the string that preceeds the match, or null if the match failed.
 java.lang.String left(int i)
          This returns the part of the string that follows the ith backreference, or null if the backreference did not match.
 int matchedFrom()
          After a successful match, this returns the location of the first matching character, or -1 if the match failed.
 int matchedFrom(int i)
          Obtains the position backreference number i begins to match, or -1 if backreference i was not matched.
 int matchedTo()
          This is matchedFrom()+charsMatched() after a successful match, or -1 otherwise.
 int matchedTo(int i)
          This is either equal to matchedFrom(i)+charsMatched(i) if the match was successful, or -1 if it was not.
 int matchFrom()
          An older name for matchedFrom.
 int matchFrom(int i)
          An older name for matchedFrom.
 int numSubs()
          This returns the number of backreferences (parenthesis) in the pattern, i.e.
 java.lang.String right()
          This returns the part of the string that follows the match, or null if the backreference did not match.
 java.lang.String right(int i)
          This returns the string to the right of the ith backreference, or null if the backreference did not match.
 java.lang.String stringMatched()
          Obtains the match if successful, null otherwise.
 java.lang.String stringMatched(int i)
          Obtains a substring matching the nth set of parenthesis from the pattern.
 java.lang.String substring()
          An older name for stringMatched().
 java.lang.String substring(int i)
          An older name for stringMatched.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

marks

protected int[] marks

didMatch_

protected boolean didMatch_

src

protected StringLike src

charsMatched_

protected int charsMatched_

matchFrom_

protected int matchFrom_

numSubs_

protected int numSubs_
Constructor Detail

RegRes

public RegRes()

RegRes

public RegRes(RegRes r)
Method Detail

getString

public java.lang.String getString()
Obtain the text String that was matched against.

getStringLike

public StringLike getStringLike()
Obtain the source StringLike object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

copyOutOf

public void copyOutOf(RegRes r)

clone

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

equals

public boolean equals(RegRes r)

stringMatched

public java.lang.String stringMatched()
Obtains the match if successful, null otherwise.

matchedFrom

public int matchedFrom(int i)
Obtains the position backreference number i begins to match, or -1 if backreference i was not matched.

charsMatched

public int charsMatched(int i)
Obtains the number of characters matched by backreference i, or -1 if backreference i was not matched.

matchedTo

public int matchedTo(int i)
This is either equal to matchedFrom(i)+charsMatched(i) if the match was successful, or -1 if it was not.

stringMatched

public java.lang.String stringMatched(int i)
Obtains a substring matching the nth set of parenthesis from the pattern. See numSubs(void), or null if the nth backrefence did not match.

left

public java.lang.String left()
This returns the part of the string that preceeds the match, or null if the match failed.

left

public java.lang.String left(int i)
This returns the part of the string that follows the ith backreference, or null if the backreference did not match.

right

public java.lang.String right()
This returns the part of the string that follows the match, or null if the backreference did not match.

right

public java.lang.String right(int i)
This returns the string to the right of the ith backreference, or null if the backreference did not match.

matchedFrom

public int matchedFrom()
After a successful match, this returns the location of the first matching character, or -1 if the match failed.

charsMatched

public int charsMatched()
After a successful match, this returns the number of characters in the match, or -1 if the match failed.

matchedTo

public int matchedTo()
This is matchedFrom()+charsMatched() after a successful match, or -1 otherwise.

numSubs

public int numSubs()
This returns the number of backreferences (parenthesis) in the pattern, i.e. the pattern "(ab)" has one, the pattern "(a)(b)" has two, etc.

didMatch

public boolean didMatch()
Contains true if the last match was successful.

matchFrom

public int matchFrom()
An older name for matchedFrom.

substring

public java.lang.String substring()
An older name for stringMatched().

matchFrom

public int matchFrom(int i)
An older name for matchedFrom.

substring

public java.lang.String substring(int i)
An older name for stringMatched.