Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 136   Methods: 7
NCLOC: 36   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SourcePosition.java - 61,5% 71,4% 65%
coverage coverage
 1    /* $Id: SourcePosition.java,v 1.7 2006/10/20 20:23:06 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.xml.tracker;
 19   
 20    import java.net.URL;
 21   
 22   
 23    /**
 24    * Describes a file position.
 25    *
 26    * @version $Revision: 1.7 $
 27    * @author Michael Meyling
 28    */
 29    public final class SourcePosition {
 30   
 31    /** Address of input, for identifying source. */
 32    private final URL address;
 33   
 34    /** Local address of input, for loading source. */
 35    private final URL localAddress;
 36   
 37    /** Line number, starting with 1. */
 38    private int line;
 39   
 40    /** Column number, starting with 1. */
 41    private int column;
 42   
 43    /**
 44    * Constructs source position object.
 45    *
 46    * @param localAddress source address
 47    * @param line Line number.
 48    * @param column Column number.
 49    */
 50  4912 public SourcePosition(final URL localAddress, final int line, final int column) {
 51  4912 this.address = localAddress;
 52  4912 this.localAddress = localAddress;
 53  4912 this.line = line;
 54  4912 this.column = column;
 55    }
 56   
 57    /**
 58    * Constructs file position object.
 59    *
 60    * @param address for identifying source
 61    * @param localAddress source address
 62    * @param line Line number.
 63    * @param column Column number.
 64    */
 65  0 public SourcePosition(final URL address, final URL localAddress,
 66    final int line, final int column) {
 67  0 this.address = address;
 68  0 this.localAddress = localAddress;
 69  0 this.line = line;
 70  0 this.column = column;
 71    }
 72   
 73    /**
 74    * Get address (or something to identify it) of input source.
 75    *
 76    * @return address of input source
 77    */
 78  16 public final URL getAddress() {
 79  16 return this.address;
 80    }
 81   
 82    /**
 83    * Get local address (or something to identify it) of input source.
 84    *
 85    * @return local address of input source
 86    */
 87  0 public final URL getLocalAddress() {
 88  0 return this.localAddress;
 89    }
 90   
 91    /**
 92    * Get line number, starting with 1.
 93    *
 94    * @return Line number.
 95    */
 96  33 public final int getLine() {
 97  33 return line;
 98    }
 99   
 100    /**
 101    * Get column number, starting with 1.
 102    *
 103    * @return column number
 104    */
 105  33 public final int getColumn() {
 106  33 return column;
 107    }
 108   
 109    // TODO mime 20050608: remove if no use
 110    /*
 111    public final int findCaretPosition(final int line, final int column, final String source) {
 112    if (line == 1) {
 113    return 0;
 114    }
 115    int k = 1;
 116    for (int j = 0; j < source.length(); j++) {
 117    if (source.charAt(j) == '\n') {
 118    k++;
 119    }
 120    if (k == line) {
 121    j += column - 1;
 122    if (j > source.length()) {
 123    j = source.length();
 124    }
 125    return j;
 126    }
 127    }
 128    return 0;
 129    }
 130    */
 131   
 132  16 public final String toString() {
 133  16 return getAddress() + ":" + getLine() + ":" + getColumn();
 134    }
 135   
 136    }