Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
file stats: LOC: 134   Methods: 7
NCLOC: 35   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SourcePosition.java - 61,5% 71,4% 65%
coverage coverage
 1    /* $Id: SourcePosition.java,v 1.6 2005/08/07 07:49:18 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2005, 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   
 21    /**
 22    * Describes a file position.
 23    *
 24    * @version $Revision: 1.6 $
 25    * @author Michael Meyling
 26    */
 27    public final class SourcePosition {
 28   
 29    /** Address of input, for identifying source. */
 30    private final String address;
 31   
 32    /** Local address of input, for loading source. */
 33    private final String localAddress;
 34   
 35    /** Line number, starting with 1. */
 36    private int line;
 37   
 38    /** Column number, starting with 1. */
 39    private int column;
 40   
 41    /**
 42    * Constructs source position object.
 43    *
 44    * @param localAddress source address
 45    * @param line Line number.
 46    * @param column Column number.
 47    */
 48  856 public SourcePosition(final String localAddress, final int line, final int column) {
 49  856 this.address = localAddress;
 50  856 this.localAddress = localAddress;
 51  856 this.line = line;
 52  856 this.column = column;
 53    }
 54   
 55    /**
 56    * Constructs file position object.
 57    *
 58    * @param address for identifying source
 59    * @param localAddress source address
 60    * @param line Line number.
 61    * @param column Column number.
 62    */
 63  0 public SourcePosition(final String address, final String localAddress,
 64    final int line, final int column) {
 65  0 this.address = address;
 66  0 this.localAddress = localAddress;
 67  0 this.line = line;
 68  0 this.column = column;
 69    }
 70   
 71    /**
 72    * Get address (or something to identify it) of input source.
 73    *
 74    * @return address of input source
 75    */
 76  16 public final String getAddress() {
 77  16 return this.address;
 78    }
 79   
 80    /**
 81    * Get local address (or something to identify it) of input source.
 82    *
 83    * @return local address of input source
 84    */
 85  0 public final String getLocalAddress() {
 86  0 return this.localAddress;
 87    }
 88   
 89    /**
 90    * Get line number, starting with 1.
 91    *
 92    * @return Line number.
 93    */
 94  33 public final int getLine() {
 95  33 return line;
 96    }
 97   
 98    /**
 99    * Get column number, starting with 1.
 100    *
 101    * @return column number
 102    */
 103  33 public final int getColumn() {
 104  33 return column;
 105    }
 106   
 107    // TODO mime 20050608: remove if no use
 108    /*
 109    public final int findCaretPosition(final int line, final int column, final String source) {
 110    if (line == 1) {
 111    return 0;
 112    }
 113    int k = 1;
 114    for (int j = 0; j < source.length(); j++) {
 115    if (source.charAt(j) == '\n') {
 116    k++;
 117    }
 118    if (k == line) {
 119    j += column - 1;
 120    if (j > source.length()) {
 121    j = source.length();
 122    }
 123    return j;
 124    }
 125    }
 126    return 0;
 127    }
 128    */
 129   
 130  16 public final String toString() {
 131  16 return getAddress() + ":" + getLine() + ":" + getColumn();
 132    }
 133   
 134    }