src/Tools/jEdit/src/proofdocument/Token.scala
author wenzelm
Sun Oct 19 16:51:55 2008 +0200 (2008-10-19)
changeset 34318 c13e168a8ae6
child 34388 23b8351ecbbe
permissions -rw-r--r--
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm@34318
     1
package isabelle.proofdocument
wenzelm@34318
     2
wenzelm@34318
     3
class Token[C](var start : Int, var stop : Int, val isCommandStart : Boolean,
wenzelm@34318
     4
               val isComment : Boolean) {
wenzelm@34318
     5
  var next : Token[C] = null
wenzelm@34318
     6
  var previous : Token[C] = null
wenzelm@34318
     7
  var command : C = null.asInstanceOf[C]
wenzelm@34318
     8
  
wenzelm@34318
     9
  def length = stop - start
wenzelm@34318
    10
wenzelm@34318
    11
  def shift(offset : Int, bottomClamp : Int) {
wenzelm@34318
    12
    start = bottomClamp max (start + offset)
wenzelm@34318
    13
    stop = bottomClamp max (stop + offset)
wenzelm@34318
    14
  }
wenzelm@34318
    15
  
wenzelm@34318
    16
  override def hashCode() : Int = (31 + start) * 31 + stop
wenzelm@34318
    17
wenzelm@34318
    18
  override def equals(obj : Any) : Boolean = {
wenzelm@34318
    19
    if (super.equals(obj))
wenzelm@34318
    20
      return true;
wenzelm@34318
    21
    
wenzelm@34318
    22
    if (null == obj)
wenzelm@34318
    23
      return false;
wenzelm@34318
    24
    
wenzelm@34318
    25
    obj match {
wenzelm@34318
    26
      case other: Token[_] => 
wenzelm@34318
    27
        (start == other.start) && (stop == other.stop)
wenzelm@34318
    28
      case other: Any => false  
wenzelm@34318
    29
    }
wenzelm@34318
    30
  }
wenzelm@34318
    31
}