KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > source > tree > LineMap


1 /*
2  * @(#)LineMap.java 1.1 06/04/19
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  *
7  * Use and Distribution is subject to the Java Research License available
8  * at <http://www.sun.com/software/communitysource/jrl.html>.
9  */

10
11 package com.sun.source.tree;
12
13 /**
14  * Provides methods to convert between character positions and line numbers
15  * for a compilation unit.
16  *
17  * @since 1.6
18  */

19 public interface LineMap {
20     /**
21      * Find the start position of a line.
22      *
23      * @param line line number (beginning at 1)
24      * @return position of first character in line
25      * @throws IndexOutOfBoundsException
26      * if <tt>lineNumber < 1</tt>
27      * if <tt>lineNumber > no. of lines</tt>
28      */

29     long getStartPosition(long line);
30     
31     /**
32      * Find the position corresponding to a (line,column).
33      *
34      * @param line line number (beginning at 1)
35      * @param column tab-expanded column number (beginning 1)
36      *
37      * @return position of character
38      * @throws IndexOutOfBoundsException
39      * if {@code line < 1}
40      * if {@code line > no. of lines}
41      */

42     long getPosition(long line, long column);
43     
44     /**
45      * Find the line containing a position; a line termination
46      * character is on the line it terminates.
47      *
48      * @param pos character offset of the position
49      * @return the line number of pos (first line is 1)
50      */

51     long getLineNumber(long pos);
52     
53     /**
54      * Find the column for a character position.
55      * Tab characters preceding the position on the same line
56      * will be expanded when calculating the column number.
57      *
58      * @param pos character offset of the position
59      * @return the tab-expanded column number of pos (first column is 1)
60      */

61     long getColumnNumber(long pos);
62     
63 }
64
Popular Tags