Changeset 6007


Ignore:
Timestamp:
2003-11-25T16:33:38+13:00 (20 years ago)
Author:
jmt12
Message:

Had to add a new method to calculate the offset to the first character of the last line of the document. It wasn't that hard I suppose - well not as hard as writing this class in the first place

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r5707 r6007  
    118118    public int getLength() {
    119119    return (int) length;
     120    }
     121
     122    /** A version of get length which essentially returns the offset to the start of the last line in the document.
     123     * @return the offset length as an int
     124     */
     125    public int getLengthToNearestLine() {
     126    AppendLineOnlyFileDocumentElement last_element = (AppendLineOnlyFileDocumentElement)root_element.getElement(root_element.getElementCount() - 1);
     127    if(last_element != null ) {
     128        return last_element.getStartOffset();
     129    }
     130    else {
     131        return (int) length; // The best we can do.
     132    }
    120133    }
    121134   
Note: See TracChangeset for help on using the changeset viewer.