553N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 553N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 553N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 553N/A * or visit www.oracle.com if you need additional information or have any 0N/A/** A class that defines source code positions as simple character 0N/A * offsets from the beginning of the file. The first character 0N/A * Support is also provided for (line,column) coordinates, but tab 0N/A * expansion is optional and no Unicode excape translation is considered. 0N/A * The first character is at location (1,1). 580N/A * <p><b>This is NOT part of any supported API. 580N/A * If you write code that depends on this, you do so at your own risk. 0N/A * This code and its internal interfaces are subject to change or 0N/A * deletion without notice.</b> 0N/A * This is class is not supposed to be instantiated. 0N/A * derived from a scan done at creation time. Tab expansion is 0N/A * optionally supported via a character map. Text content 0N/A * Notes: The first character position FIRSTPOS is at 0N/A * (FIRSTLINE,FIRSTCOLUMN). No account is taken of Unicode escapes. 0N/A * @param src Source characters 0N/A * @param max Number of characters to read 0N/A * @param expandTabs If true, expand tabs when calculating columns 0N/A /** Encode line and column numbers in an integer as: 0N/A * line-number << LINESHIFT + column-number 0N/A * {@link Position.NOPOS represents an undefined position. 0N/A * @param line number of line (first is 1) 0N/A * @param col number of character on line (first is 1) 0N/A * @return an encoded position or {@link Position.NOPOS 0N/A * if the line or column number is too big to 0N/A * represent in the encoded format 0N/A * @throws IllegalArgumentException if line or col is less than 1 0N/A /** Find the start position of a line. 0N/A * @param line number of line (first is 1) 0N/A * @return position of first character in line 0N/A * @throws ArrayIndexOutOfBoundsException 0N/A * if <tt>lineNumber < 1</tt> 0N/A * if <tt>lineNumber > no. of lines</tt> 0N/A /** Find the position corresponding to a (line,column). 0N/A * @param line number of line (first is 1) 0N/A * @param column number of character on line (first is 1) 0N/A * @return position of character 0N/A * @throws ArrayIndexOutOfBoundsException 0N/A * if <tt>line < 1</tt> 0N/A * if <tt>line > no. of lines</tt> 0N/A /** Find the line containing a position; a line termination 0N/A * character is on the line it terminates. 0N/A * @param pos character offset of the position 0N/A * @return the line number on which pos occurs (first line is 1) 0N/A /** Find the column for a character position. 0N/A * Note: this method does not handle tab expansion. 0N/A * If tab expansion is needed, use a LineTabMap instead. 0N/A * @param pos character offset of the position 0N/A * @return the column number at which pos occurs 0N/A // Cache of last line number lookup 0N/A * A LineMap that handles tab expansion correctly. The cost is 0N/A * an additional bit per character in the source array.