|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SourceArea.java | 0% | 60% | 42,9% | 42,9% |
|
||||||||||||||
| 1 | /* $Id: SourceArea.java,v 1.1 2007/04/12 23:50:10 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 a file area. | |
| 26 | * | |
| 27 | * @version $Revision: 1.1 $ | |
| 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 | /** Local address of input, for loading source. */ | |
| 36 | private final URL localAddress; | |
| 37 | ||
| 38 | /** Start position. */ | |
| 39 | private final SourcePosition startPosition; | |
| 40 | ||
| 41 | /** End position. Might be <code>null</code>. */ | |
| 42 | private final SourcePosition endPosition; | |
| 43 | ||
| 44 | /** | |
| 45 | * Constructs source area object. | |
| 46 | * | |
| 47 | * @param localAddress source address | |
| 48 | * @param startPosition Start position. | |
| 49 | * @param endPosition Start position. | |
| 50 | */ | |
| 51 | 0 | public SourceArea(final URL localAddress, final SourcePosition startPosition, |
| 52 | final SourcePosition endPosition) { | |
| 53 | 0 | this(localAddress, localAddress, startPosition, endPosition); |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Constructs file position object. | |
| 58 | * | |
| 59 | * @param address For identifying source. | |
| 60 | * @param localAddress Source address. | |
| 61 | * @param startPosition Start position. | |
| 62 | * @param endPosition Start position. | |
| 63 | */ | |
| 64 | 17 | public SourceArea(final URL address, final URL localAddress, |
| 65 | final SourcePosition startPosition, final SourcePosition endPosition) { | |
| 66 | 17 | this.address = address; |
| 67 | 17 | this.localAddress = localAddress; |
| 68 | 17 | this.startPosition = startPosition; |
| 69 | 17 | this.endPosition = endPosition; |
| 70 | } | |
| 71 | ||
| 72 | /** | |
| 73 | * Get address (or something to identify it) of input source. | |
| 74 | * | |
| 75 | * @return address of input source | |
| 76 | */ | |
| 77 | 0 | public final URL getAddress() { |
| 78 | 0 | return this.address; |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Get local address (or something to identify it) of input source. | |
| 83 | * | |
| 84 | * @return local address of input source | |
| 85 | */ | |
| 86 | 4 | public final URL getLocalAddress() { |
| 87 | 4 | return this.localAddress; |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * Get start position. | |
| 92 | * | |
| 93 | * @return Start position. | |
| 94 | */ | |
| 95 | 42 | public final SourcePosition getStartPosition() { |
| 96 | 42 | return startPosition; |
| 97 | } | |
| 98 | ||
| 99 | /** | |
| 100 | * Get end position. | |
| 101 | * | |
| 102 | * @return End position. | |
| 103 | */ | |
| 104 | 0 | public final SourcePosition getEndPosition() { |
| 105 | 0 | return endPosition; |
| 106 | } | |
| 107 | ||
| 108 | ||
| 109 | 0 | public final String toString() { |
| 110 | 0 | return getAddress() |
| 111 | 0 | + (getStartPosition() != null ? ":" + getStartPosition().getLine() + ":" |
| 112 | + getStartPosition().getColumn() : "") | |
| 113 | 0 | + (getEndPosition() != null ? ":" + getEndPosition().getLine() + ":" |
| 114 | + getEndPosition().getColumn() : ""); | |
| 115 | } | |
| 116 | ||
| 117 | } |
|
||||||||||