upidiff.merge
Class LineOffset

java.lang.Object
  |
  +--upidiff.merge.LineOffset

public class LineOffset
extends Object

This class represents the management of an Line/Char Offset

Author:
Alexander Jung

Field Summary
private  Vector offset
          The container for the LineElements
 
Constructor Summary
LineOffset()
          Constructs a new object of this class
 
Method Summary
 void addLine(LineElement line)
          Adds the given LineElement to the end of the Vector
 void addStringInLine(int line, int length)
          Adds the Offset of an inserted String to the LineElement of the line it was added to.
 void connectWithNextLine(int linenumber)
          This method connects the LineElement in the given line with the the one in the next line
 void deleteLine(int line)
          Deletes a line from the Offset
 void deleteLineRange(int start, int end)
          This method deletes the given range of lines
 void deleteStringInLine(int line, int length)
          Decreases the offset of the given line about the given length
 int getLength()
          Queries the number of lines in the document
 LineElement getLineByChange(Change change)
          Queries the LineElement that contains the given change
 LineElement getLineByNumber(int number)
          Queries the lineinformation by its number
 int getLinenumberByChange(Change change)
          Queries the linenumber that contains the given change
 int getLineNumberByTotalChar(int thisPos)
          Queries the LineElement that contains the given total position in the Text
 void insertLine(int line, LineElement lineElement)
          Inserts a LineElement at the given line
 void recalculateCharOffset(int startLine)
          Recalculates the offset after a char-change
private  void recalculateLineNumberOffset(int linenumber)
           
 void recalculateLineOffset(int startLine)
          Recalculates the offset after a line-change
 void setStringInLine(int line, int length)
          Sets the number of Chars in Line
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offset

private Vector offset
The container for the LineElements

Constructor Detail

LineOffset

public LineOffset()
Constructs a new object of this class

Method Detail

getLineByChange

public LineElement getLineByChange(Change change)
Queries the LineElement that contains the given change

Parameters:
change - The Change-Object to querie for
Returns:
This Element contains all information about the queried line

getLinenumberByChange

public int getLinenumberByChange(Change change)
Queries the linenumber that contains the given change

Parameters:
change - The Change-Object to querie for
Returns:
The linenumber

getLineNumberByTotalChar

public int getLineNumberByTotalChar(int thisPos)
Queries the LineElement that contains the given total position in the Text

Parameters:
thisPos - The total position in the Text
Returns:
Linenumber in which this total position takes place

getLength

public int getLength()
Queries the number of lines in the document

Returns:
The number of lines

getLineByNumber

public LineElement getLineByNumber(int number)
Queries the lineinformation by its number

Parameters:
number - The number of the queried line
Returns:
This Element contains all informantion about the queried line

addLine

public void addLine(LineElement line)
Adds the given LineElement to the end of the Vector

Parameters:
line - The LineElement with the information about the line

setStringInLine

public void setStringInLine(int line,
                            int length)
Sets the number of Chars in Line

Parameters:
line - The line to set the number
length - the number of Chars

addStringInLine

public void addStringInLine(int line,
                            int length)
Adds the Offset of an inserted String to the LineElement of the line it was added to.

Parameters:
line - Number of the line
length - The length of the inserted String

deleteLine

public void deleteLine(int line)
Deletes a line from the Offset

Parameters:
line - The number of the line to be deleted

deleteLineRange

public void deleteLineRange(int start,
                            int end)
This method deletes the given range of lines

Parameters:
start - The first line to be deleted
end - The last line to be deleted

deleteStringInLine

public void deleteStringInLine(int line,
                               int length)
Decreases the offset of the given line about the given length

Parameters:
line - The line to be decreased
length - The length to decrease the line about

insertLine

public void insertLine(int line,
                       LineElement lineElement)
Inserts a LineElement at the given line

Parameters:
line - The new position of the given LineElement
lineElement - The LineElement to be inserted

recalculateCharOffset

public void recalculateCharOffset(int startLine)
Recalculates the offset after a char-change

Parameters:
startLine - The line to start the recalculation with. Use the the linenumber the change took place in.

recalculateLineOffset

public void recalculateLineOffset(int startLine)
Recalculates the offset after a line-change

Parameters:
startLine - The line to start the recalculation with. Use the the linenumber the change took place in.

recalculateLineNumberOffset

private void recalculateLineNumberOffset(int linenumber)

connectWithNextLine

public void connectWithNextLine(int linenumber)
This method connects the LineElement in the given line with the the one in the next line

Parameters:
linenumber - The linenumber of the LinenElement to connect