edu.iastate.jtm.util
Class SlidingWindow

java.lang.Object
  extended by edu.iastate.jtm.util.SlidingWindow

public class SlidingWindow
extends java.lang.Object

Author:
dingjing

Nested Class Summary
 class SlidingWindow.Stride
           
 
Field Summary
static int DASH
           
static int DIGIT
           
static int LEFT
           
static int LETTER
           
static int PUNC
           
static int RIGHT
           
static int SPACE
           
 
Constructor Summary
SlidingWindow()
           
SlidingWindow(boolean split)
          Creates a new instance of SlidingWindow
 
Method Summary
 boolean atStart()
           
 boolean atStart(int id)
           
 int copyFromMark(java.nio.CharBuffer dst)
           
 int copyFromTo(java.nio.CharBuffer dst, int from, int to)
           
 int copyToMark(java.nio.CharBuffer dst)
           
 int copyWindow(java.nio.CharBuffer dst)
           
 int end()
           
 void end(int e)
           
 int expandWindow(java.nio.CharBuffer dst, boolean skipParen, boolean skipSpace)
          Increase window size by 1 stride.
 java.lang.String getAllText()
           
 int getSkipTo(int i)
           
 int getWindowEndPosition()
           
 int getWindowStartPosition()
           
 java.lang.String getWindowText()
           
 int length()
           
static void main(java.lang.String[] args)
           
 void mark()
           
 boolean markValid()
           
 boolean nextSkippable()
           
 void printStrides()
           
 boolean reachEnd()
           
 boolean reachEnd(int id)
           
 void resetSize()
           
 void resetSizeToMark()
           
 int resetWindow(java.nio.CharBuffer dst)
           
 int resetWindow(java.lang.CharSequence sen, java.nio.CharBuffer dst)
           
 void setCharType(CharType ct)
           
 void setSplitDigit(boolean sp)
           
 int skip(java.nio.CharBuffer content)
           
 int slideWindow(java.nio.CharBuffer dst, boolean skipParen, boolean skipSpace)
           
 int start()
           
 void start(int s)
           
 void unmark()
           
 int walkWindow(java.nio.CharBuffer dst, boolean skipParen, boolean skipSpace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPACE

public static final int SPACE
See Also:
Constant Field Values

DASH

public static final int DASH
See Also:
Constant Field Values

PUNC

public static final int PUNC
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

LETTER

public static final int LETTER
See Also:
Constant Field Values

DIGIT

public static final int DIGIT
See Also:
Constant Field Values
Constructor Detail

SlidingWindow

public SlidingWindow(boolean split)
Creates a new instance of SlidingWindow


SlidingWindow

public SlidingWindow()
Method Detail

setSplitDigit

public void setSplitDigit(boolean sp)

setCharType

public void setCharType(CharType ct)

atStart

public boolean atStart()

atStart

public boolean atStart(int id)

reachEnd

public boolean reachEnd()

reachEnd

public boolean reachEnd(int id)

start

public int start()

start

public void start(int s)

end

public int end()

end

public void end(int e)

mark

public void mark()

markValid

public boolean markValid()

unmark

public void unmark()

resetWindow

public int resetWindow(java.nio.CharBuffer dst)

resetWindow

public int resetWindow(java.lang.CharSequence sen,
                       java.nio.CharBuffer dst)

resetSize

public void resetSize()

resetSizeToMark

public void resetSizeToMark()

expandWindow

public int expandWindow(java.nio.CharBuffer dst,
                        boolean skipParen,
                        boolean skipSpace)
Increase window size by 1 stride. If skipParen is true, and the immediately followed stride is a skippable, increase the window size to the end of the skippable. Copy new content to a buffer (not include skipped content).

Parameters:
dst - destination buffer for new content
skipParen - whether or not skip parenthesis if followed
skipSpace - whether or not copy space to the destination buffer
Returns:
number of characters copied

slideWindow

public int slideWindow(java.nio.CharBuffer dst,
                       boolean skipParen,
                       boolean skipSpace)

walkWindow

public int walkWindow(java.nio.CharBuffer dst,
                      boolean skipParen,
                      boolean skipSpace)

skip

public int skip(java.nio.CharBuffer content)

getSkipTo

public int getSkipTo(int i)

copyWindow

public int copyWindow(java.nio.CharBuffer dst)

getWindowText

public java.lang.String getWindowText()

getAllText

public java.lang.String getAllText()

length

public int length()

getWindowStartPosition

public int getWindowStartPosition()

getWindowEndPosition

public int getWindowEndPosition()

copyToMark

public int copyToMark(java.nio.CharBuffer dst)

copyFromMark

public int copyFromMark(java.nio.CharBuffer dst)

copyFromTo

public int copyFromTo(java.nio.CharBuffer dst,
                      int from,
                      int to)

nextSkippable

public boolean nextSkippable()

printStrides

public void printStrides()

main

public static void main(java.lang.String[] args)