1 /* Copyright 2004 The Apache Software Foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package org.apache.xmlbeans; 17 18 import org.apache.xmlbeans.XmlCursor.XmlBookmark; 19 20 /** 21 * A subclass of XmlBookmark that holds line number information. 22 * If a document is parsed with line numbers 23 * enabled, these bookmarks will be placed at appropriate locations 24 * within the document. 25 * 26 * @see XmlOptions#setLoadLineNumbers 27 */ 28 public class XmlLineNumber extends XmlBookmark 29 { 30 /** 31 * Constructs a line number with no column or offset information. 32 * @param line the line number - the first line is 1 33 */ 34 public XmlLineNumber ( int line ) { this( line, -1, -1 ); } 35 36 /** 37 * Constructs a line number and column with no file offset information. 38 * @param line the line number - the first line is 1 39 * @param line the column number - the first column is 1 40 */ 41 public XmlLineNumber ( int line, int column ) { this( line, column, -1 ); } 42 43 /** 44 * Constructs a line number and column with no file offset information. 45 * @param line the line number - the first line is 1 46 * @param line the column number - the first column is 1 47 * @param line the file character offset - the first character in the file is 0 48 */ 49 public XmlLineNumber ( int line, int column, int offset ) 50 { 51 super( false ); 52 53 _line = line; 54 _column = column; 55 _offset = offset; 56 } 57 58 /** 59 * Returns the 1-based line number, or -1 if not known. 60 */ 61 public int getLine ( ) { return _line; } 62 63 /** 64 * Returns the 1-based column number, or -1 if not known. 65 */ 66 public int getColumn ( ) { return _column; } 67 68 /** 69 * Returns the 0-based file offset number, or -1 if not known. 70 */ 71 public int getOffset ( ) { return _offset; } 72 73 private int _line, _column, _offset; 74 }