com.github.croesch.micro_debug.gui.debug
Class LineNumberMapper

java.lang.Object
  extended by com.github.croesch.micro_debug.gui.debug.LineNumberMapper

public class LineNumberMapper
extends Object

Abstraction layer to be able to have a special line numbering available but can this internal handle with normal line numbers. When constructed the real line numbers and the line numbers available for the user are the same.
The method setNewLines(int...) allows you to add your own scheme of line numbers. These numbers are the numbers available for the user and will be mapped to the real line numbers.

The methods getLineForNumber(int) and getNumberForLine(int) let you get the other representation of the line number you have.

line: the line number for the user (may be 2,4,8,10,11,..)
number: the real line number, zero-based: 0,1,2,3,..

Since:
Date: Mar 24, 2012
Author:
croesch

Constructor Summary
LineNumberMapper()
           
 
Method Summary
 int getLineForNumber(int number)
          Returns the representation for the user of the given real line number.
 int getNumberForLine(int line)
          Returns the internal representation for the given line number (users view).
 void setNewLines(int... lines)
          Set the new scheme of line numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineNumberMapper

public LineNumberMapper()
Method Detail

setNewLines

public final void setNewLines(int... lines)
Set the new scheme of line numbers. The given lines are the representation for the user in the given order. Each line will be mapped to a real line number, according to its position in the array.
A null-array or an empty array means to reset the line numbers scheme to the default behavior - lines (representation for the user: e.g. 2,6,7,8,10,..) and numbers (real line number: 0,1,2,3,...) are the same.

Parameters:
lines - the lines available for the user, note: may NOT contain duplicate entries!
Since:
Date: Mar 24, 2012

getLineForNumber

public final int getLineForNumber(int number)
Returns the representation for the user of the given real line number.

Parameters:
number - the internal line number: 0,1,2,3,..
Returns:
the users representation of the given line number
or -1 if no mapping is found for the given line number
Since:
Date: Mar 24, 2012

getNumberForLine

public final int getNumberForLine(int line)
Returns the internal representation for the given line number (users view).

Parameters:
line - the line number visible to the user, e.g. 4,5,7,12,..
Returns:
the real line number this line belongs to, result is greater than or equal zero.
or -1 if no mapping is found for the given line
Since:
Date: Mar 24, 2012


Copyright © 2012. All Rights Reserved.