|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SourceArea.java | 0% | 71,4% | 60% | 50% |
|
||||||||||||||
| 1 | /* $Id: SourceArea.java,v 1.2 2007/12/21 23:33:47 m31 Exp $ | |
| 2 | * | |
| 3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
| 4 | * | |
| 5 | * Copyright 2000-2007, 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.common; | |
| 19 | ||
| 20 | import java.io.Serializable; | |
| 21 | import java.net.URL; | |
| 22 | ||
| 23 | ||
| 24 | /** | |
| 25 | * Describes an area of an URL contents. | |
| 26 | * | |
| 27 | * @version $Revision: 1.2 $ | |
| 28 | * @author Michael Meyling | |
| 29 | */ | |
| 30 | public final class SourceArea implements Serializable { | |
| 31 | ||
| 32 | /** Address of input, for identifying source. */ | |
| 33 | private final URL address; | |
| 34 | ||
| 35 | /** Start position. */ | |
| 36 | private final SourcePosition startPosition; | |
| 37 | ||
| 38 | /** End position. Might be <code>null</code>. */ | |
| 39 | private final SourcePosition endPosition; | |
| 40 | ||
| 41 | /** | |
| 42 | * Constructs file position object. | |
| 43 | * | |
| 44 | * @param address For identifying source. | |
| 45 | * @param startPosition Start position. | |
| 46 | * @param endPosition Start position. | |
| 47 | */ | |
| 48 | 2408 | public SourceArea(final URL address, final SourcePosition startPosition, |
| 49 | final SourcePosition endPosition) { | |
| 50 | 2408 | this.address = address; |
| 51 | 2408 | this.startPosition = startPosition; |
| 52 | 2408 | this.endPosition = endPosition; |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * Get address (or something to identify it) of input source. | |
| 57 | * | |
| 58 | * @return address of input source | |
| 59 | */ | |
| 60 | 28 | public final URL getAddress() { |
| 61 | 28 | return this.address; |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * Get start position. | |
| 66 | * | |
| 67 | * @return Start position. | |
| 68 | */ | |
| 69 | 875 | public final SourcePosition getStartPosition() { |
| 70 | 875 | return startPosition; |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * Get end position. | |
| 75 | * | |
| 76 | * @return End position. | |
| 77 | */ | |
| 78 | 0 | public final SourcePosition getEndPosition() { |
| 79 | 0 | return endPosition; |
| 80 | } | |
| 81 | ||
| 82 | ||
| 83 | 0 | public final String toString() { |
| 84 | 0 | return getAddress() |
| 85 | 0 | + (getStartPosition() != null ? ":" + getStartPosition().getLine() + ":" |
| 86 | + getStartPosition().getColumn() : "") | |
| 87 | 0 | + (getEndPosition() != null ? ":" + getEndPosition().getLine() + ":" |
| 88 | + getEndPosition().getColumn() : ""); | |
| 89 | } | |
| 90 | ||
| 91 | } |
|
||||||||||