fr.umlv.tatoo.runtime.buffer.impl
Class LocationTracker

java.lang.Object
  extended by fr.umlv.tatoo.runtime.buffer.impl.LocationTracker
All Implemented Interfaces:
LocationProvider

public class LocationTracker
extends Object
implements LocationProvider

A class that is able to map buffer position to text location.

Author:
Julien Cervelle

Constructor Summary
LocationTracker()
          Creates a location tracker.
 
Method Summary
 void bufferClear()
          Set the current and unwinded location to zero.
 void bufferDiscard()
           
 void bufferNext(int character)
          Update the columnNumber and lineNumber location.
 void bufferReset()
          Update the unwinded location.
 void bufferRestart()
           
 void bufferUnwind(int count)
          Update the current and unwinded location.
 int getColumnNumber()
          Returns the current column number in the stream.
 int getLineNumber()
          Returns the current line number in the stream.
 int getUnwindedColumnNumber()
          Returns the column number of the last unwind operation.
 int getUnwindedLineNumber()
          Returns the line number of the last unwind operation.
 void setColumnNumber(int columnNumber)
          Changes the current column number.
 void setLineNumber(int lineNumber)
          Changes the current line number.
 void setUnwindedColumnNumber(int unwindedColumnNumber)
          Changes the column number of the last unwind operation.
 void setUnwindedLineNumber(int unwindedLineNumber)
          Changes the line number of the last unwind operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocationTracker

public LocationTracker()
Creates a location tracker.

Method Detail

bufferNext

public void bufferNext(int character)
Update the columnNumber and lineNumber location. This method is called by method LexerBuffer.next() of a buffer to update line and column of the current tracker.

Parameters:
character - the current character of the buffer.
See Also:
LexerBuffer.next()

bufferUnwind

public void bufferUnwind(int count)
Update the current and unwinded location. This method is called by method LexerBuffer.unwind(int) of a buffer to update line and column of the current tracker.

Parameters:
count - the number of characters to unwind
See Also:
LexerBuffer.unwind(int)

bufferReset

public void bufferReset()
Update the unwinded location. This method is called by method LexerBuffer.reset() of a buffer to update line and column of the current tracker.

See Also:
LexerBuffer.reset()

bufferClear

public void bufferClear()
Set the current and unwinded location to zero.


getColumnNumber

public int getColumnNumber()
Returns the current column number in the stream.

Specified by:
getColumnNumber in interface LocationProvider
Returns:
the column number.

setColumnNumber

public void setColumnNumber(int columnNumber)
Changes the current column number.

Parameters:
columnNumber - the new value.

getLineNumber

public int getLineNumber()
Returns the current line number in the stream.

Specified by:
getLineNumber in interface LocationProvider
Returns:
the line number.

setLineNumber

public void setLineNumber(int lineNumber)
Changes the current line number.

Parameters:
lineNumber - the new line number

getUnwindedColumnNumber

public int getUnwindedColumnNumber()
Returns the column number of the last unwind operation.

Specified by:
getUnwindedColumnNumber in interface LocationProvider
Returns:
the column number

setUnwindedColumnNumber

public void setUnwindedColumnNumber(int unwindedColumnNumber)
Changes the column number of the last unwind operation.

Parameters:
unwindedColumnNumber - the new column number.

getUnwindedLineNumber

public int getUnwindedLineNumber()
Returns the line number of the last unwind operation.

Specified by:
getUnwindedLineNumber in interface LocationProvider
Returns:
the line number

setUnwindedLineNumber

public void setUnwindedLineNumber(int unwindedLineNumber)
Changes the line number of the last unwind operation.

Parameters:
unwindedLineNumber - the new line number.

bufferRestart

public void bufferRestart()

bufferDiscard

public void bufferDiscard()