kmy.regex.jvm
Class JavaClassRegexStub

java.lang.Object
  |
  +--kmy.regex.util.Regex
        |
        +--kmy.regex.jvm.JavaClassRegexStub

public abstract class JavaClassRegexStub
extends Regex


Field Summary
protected  int[] cells
          Variable values.
protected  int end
          Index (in the buffer) of the last character in the string being matched plus one.
protected  char[][] extCells
          Character buffers for referenced variable values.
protected  int forkPtr
          Number of elements used in the forks array.
protected  int[] forks
          This keeps information about forks in matching.
protected  int headStart
          Starting index for the next search/match.
protected  int matchEnd
          On successful match/search - index of the last character in matching string plus one.
protected  int matchStart
          On successful match/search - index of the first character in matching string.
protected  int maxStart
          Maximum value for the start of the matching string.
protected  RegexRefiller refiller
          RegexRefiller to use when end of buffer is reached.
protected  boolean searching
          True if searching is going on, false if matching.
protected  int start
          Index (in the buffer) of the first character of the string being matched.
protected  char[] string
          Character buffer which stores the string being matched.
 
Fields inherited from class kmy.regex.util.Regex
factory
 
Constructor Summary
protected JavaClassRegexStub()
           
 
Method Summary
 Regex cloneRegex()
           
 void dumpForks()
          Debugging method to print regex state.
 char[] getCharBuffer(int extHandle)
          Returns external variable buffer by its buffer handle.
 int getExtVariableHandle(java.lang.String var)
          Returns external variable buffer handle that can be used later to get or set variable value efficiently.
 int getIndex(int handle)
          Returns external or internal variable index using its index handle.
 int getMatchEnd()
          After successiful search returns matching substring's final position in the input buffer (that was set up by init method).
 int getMatchStart()
          After successiful search returns matching substring's initial position in the input buffer (that was set up by init method).
 int getVariableHandle(java.lang.String var, boolean begin)
          Returns variable index handle that can be used later to get or set variable value efficiently.
protected abstract  java.util.Hashtable getVars()
           
 boolean match()
          Match the beginning of the buffer (that was set up by init method) against this regex.
 boolean matchWhole()
          Match the buffer (that was set up by init method) against this regex.
protected abstract  boolean nextMatchInt()
           
 boolean search()
          Search the buffer (that was set up by init method) for a substring that matches this regex.
 boolean searchAgain()
          Search the buffer (that was set up by init method) for a substring that matches this regex.
 void setExtVariableBuffer(int extHandle, char[] arr)
          Assignes external variable buffer by its buffer handle.
 void setIndex(int handle, int value)
          Returns internal variable index using its index handle.
 void setRefilledBuffer(char[] buf)
          Refiller can call this method after refilling the buffer, if buffer has been reallocated.
 void setRefiller(RegexRefiller r)
           
 java.util.Enumeration variables()
          Enumerates all external and internal variables in this regex.
 
Methods inherited from class kmy.regex.util.Regex
accept, clone, createFilePattern, createLowerCaseRegex, createRegex, createRegex, createRegex, get, getMatch, getMatchString, init, init, init, initFactory, matches, matches, matchesWhole, matchesWhole, searchOnce, searchOnce, searchOnce, searchOnce, set, setExtVariable, setExtVariable, setExtVariable, setExtVariable, setFactory
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

string

protected char[] string
Character buffer which stores the string being matched.

cells

protected int[] cells
Variable values. Earch variable is given two cells in this array: one stores index of the first character in the buffer and the other stores index of the last character in the buffer plus one. Note that variables that are only referenced (but not "picked") by this regex have their own buffers (stored in extCells).

start

protected int start
Index (in the buffer) of the first character of the string being matched.

end

protected int end
Index (in the buffer) of the last character in the string being matched plus one.

forks

protected int[] forks
This keeps information about forks in matching. Forks occur when several ways of matching are possible. Matching algorithm picks the first way and tries it out. If it eventually fails, it goes back to the fork point and tries the other way.

forkPtr

protected int forkPtr
Number of elements used in the forks array.

headStart

protected int headStart
Starting index for the next search/match.

matchStart

protected int matchStart
On successful match/search - index of the first character in matching string.

matchEnd

protected int matchEnd
On successful match/search - index of the last character in matching string plus one.

extCells

protected char[][] extCells
Character buffers for referenced variable values.

searching

protected boolean searching
True if searching is going on, false if matching.

maxStart

protected int maxStart
Maximum value for the start of the matching string.

refiller

protected RegexRefiller refiller
RegexRefiller to use when end of buffer is reached.
Constructor Detail

JavaClassRegexStub

protected JavaClassRegexStub()
Method Detail

nextMatchInt

protected abstract boolean nextMatchInt()

getVars

protected abstract java.util.Hashtable getVars()

dumpForks

public void dumpForks()
Debugging method to print regex state. Called if internal error happens.

getVariableHandle

public int getVariableHandle(java.lang.String var,
                             boolean begin)
Description copied from class: Regex
Returns variable index handle that can be used later to get or set variable value efficiently. If efficiency is not a concern, use get and set methods instead. Every variable has two index handles - 'begin' and 'end' index handle.
Overrides:
getVariableHandle in class Regex

getExtVariableHandle

public int getExtVariableHandle(java.lang.String var)
Description copied from class: Regex
Returns external variable buffer handle that can be used later to get or set variable value efficiently. If efficiency is not a concern, use get and set methods instead. Only external variables have buffer handle. This is different from index handles. For internal variables this method returs -1.
Overrides:
getExtVariableHandle in class Regex

setExtVariableBuffer

public void setExtVariableBuffer(int extHandle,
                                 char[] arr)
Description copied from class: Regex
Assignes external variable buffer by its buffer handle. It is needed to completely specify value of an external variable.
Overrides:
setExtVariableBuffer in class Regex

variables

public java.util.Enumeration variables()
Description copied from class: Regex
Enumerates all external and internal variables in this regex.
Overrides:
variables in class Regex

getCharBuffer

public char[] getCharBuffer(int extHandle)
Description copied from class: Regex
Returns external variable buffer by its buffer handle. If -1 is passed as a handle the input buffer that was set up for matching (using init) is returned.
Overrides:
getCharBuffer in class Regex

getMatchStart

public int getMatchStart()
Description copied from class: Regex
After successiful search returns matching substring's initial position in the input buffer (that was set up by init method).
Overrides:
getMatchStart in class Regex

getMatchEnd

public int getMatchEnd()
Description copied from class: Regex
After successiful search returns matching substring's final position in the input buffer (that was set up by init method).
Overrides:
getMatchEnd in class Regex

getIndex

public int getIndex(int handle)
Description copied from class: Regex
Returns external or internal variable index using its index handle. Every variable has two indices - 'begin' and 'end'. Use 'begin' and 'end' handles to get them. These indices can be used to determine which part of the input buffer (set by init method) corresponding internal variable matched. An external variable 'begin' and 'end' indices point to its own buffer. They are assinged by setIndex and are never changed.
Overrides:
getIndex in class Regex

setIndex

public void setIndex(int handle,
                     int value)
Description copied from class: Regex
Returns internal variable index using its index handle. Every variable has two indices - 'begin' and 'end'. Use 'begin' and 'end' handles to assign them. These indices are needed to completely specify value of an external variable.
Overrides:
setIndex in class Regex

setRefiller

public void setRefiller(RegexRefiller r)
Overrides:
setRefiller in class Regex

setRefilledBuffer

public void setRefilledBuffer(char[] buf)
Description copied from class: Regex
Refiller can call this method after refilling the buffer, if buffer has been reallocated.
Overrides:
setRefilledBuffer in class Regex

searchAgain

public boolean searchAgain()
Description copied from class: Regex
Search the buffer (that was set up by init method) for a substring that matches this regex. See description of this class for difference between search and match. On success do not discard record of all other possible matches, so if this method is called again, different way of matching can be found for already found substring or a substring overlapping already found substring. Most often, search(), not searchAgain() should be used.
Overrides:
searchAgain in class Regex

search

public boolean search()
Description copied from class: Regex
Search the buffer (that was set up by init method) for a substring that matches this regex. See description of this class for difference between search and match. All records for other possible matches withing matching substring that was found are destroyed, so if this method is called again, search will start at the first position after previously found substring.
Overrides:
search in class Regex

matchWhole

public boolean matchWhole()
Description copied from class: Regex
Match the buffer (that was set up by init method) against this regex. See description of this class for difference between search/match/matchWhole.
Overrides:
matchWhole in class Regex

match

public boolean match()
Description copied from class: Regex
Match the beginning of the buffer (that was set up by init method) against this regex. See description of this class for difference between search/match/matchWhole.
Overrides:
match in class Regex

cloneRegex

public Regex cloneRegex()
Overrides:
cloneRegex in class Regex