Class Cursor

java.lang.Object
org.htmlparser.lexer.Cursor
All Implemented Interfaces:
Serializable, Cloneable, Ordered

public class Cursor extends Object implements Serializable, Ordered, Cloneable
A bookmark in a page. This class remembers the page it came from and its position within the page.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Page
    This cursor's page.
    protected int
    This cursor's position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Cursor(Page page, int offset)
    Construct a Cursor from the page and position given.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Move the cursor position ahead one character.
    int
    Compare one reference to another.
    dup()
    Make a new cursor just like this one.
    Get this cursor's page.
    int
    Get the position of this cursor.
    void
    Move the cursor position back one character.
    void
    setPosition(int position)
    Set the position of this cursor.
    Return a string representation of this cursor

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • mPosition

      protected int mPosition
      This cursor's position.
    • mPage

      protected Page mPage
      This cursor's page.
  • Constructor Details

    • Cursor

      public Cursor(Page page, int offset)
      Construct a Cursor from the page and position given.
      Parameters:
      page - The page this cursor is on.
      offset - The character offset within the page.
  • Method Details

    • getPage

      public Page getPage()
      Get this cursor's page.
      Returns:
      The page associated with this cursor.
    • getPosition

      public int getPosition()
      Get the position of this cursor.
      Returns:
      The cursor position.
    • setPosition

      public void setPosition(int position)
      Set the position of this cursor.
      Parameters:
      position - The new cursor position.
    • advance

      public void advance()
      Move the cursor position ahead one character.
    • retreat

      public void retreat()
      Move the cursor position back one character.
    • dup

      public Cursor dup()
      Make a new cursor just like this one.
      Returns:
      The new cursor positioned where this one is, and referring to the same page.
    • toString

      public String toString()
      Return a string representation of this cursor
      Overrides:
      toString in class Object
      Returns:
      A string of the form "n[r,c]", where n is the character position, r is the row (zero based) and c is the column (zero based) on the page.
    • compare

      public int compare(Object that)
      Compare one reference to another.
      Specified by:
      compare in interface Ordered
      Parameters:
      that - The object to compare this to.
      Returns:
      A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than that object.
      See Also: