Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
16   119   13   1.78
4   48   0.81   9
9     1.44  
1    
 
  SourceArea       Line # 26 16 13 86.2% 0.86206895
 
  (97)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.base.io;
17   
18    import java.io.Serializable;
19   
20   
21    /**
22    * Describes an area of an URL contents.
23    *
24    * @author Michael Meyling
25    */
 
26    public final class SourceArea implements Serializable {
27   
28    /** Address of input, for identifying source. */
29    private final String address;
30   
31    /** Start position. Must be not <code>null</code>. */
32    private final SourcePosition startPosition;
33   
34    /** End position. Must be not <code>null</code>. */
35    private final SourcePosition endPosition;
36   
37    /**
38    * Constructs file position object.
39    *
40    * @param address For identifying source. Must not be <code>null</code>.
41    * @param startPosition Start position. Must not be <code>null</code>.
42    * @param endPosition Start position. Must not be <code>null</code>.
43    */
 
44  67104 toggle public SourceArea(final String address, final SourcePosition startPosition,
45    final SourcePosition endPosition) {
46  67104 this.address = address;
47  67104 if (address == null || startPosition == null || endPosition == null) {
48  3 throw new NullPointerException();
49    }
50  67101 this.startPosition = startPosition;
51  67101 this.endPosition = endPosition;
52    }
53   
54    /**
55    * Constructs file position object with dummy location at begin of file.
56    *
57    * @param address For identifying source. Must not be <code>null</code>.
58    */
 
59  54 toggle public SourceArea(final String address) {
60  54 this(address, SourcePosition.BEGIN, SourcePosition.BEGIN);
61    }
62   
63    /**
64    * Get address (or something to identify it) of input source.
65    *
66    * @return address of input source
67    */
 
68  54003 toggle public final String getAddress() {
69  54003 return this.address;
70    }
71   
72    /**
73    * Get start position.
74    *
75    * @return Start position.
76    */
 
77  120997 toggle public final SourcePosition getStartPosition() {
78  120997 return startPosition;
79    }
80   
81    /**
82    * Get end position.
83    *
84    * @return End position.
85    */
 
86  67142 toggle public final SourcePosition getEndPosition() {
87  67142 return endPosition;
88    }
89   
 
90  47 toggle public final int hashCode() {
91  47 return getAddress().hashCode() ^ getStartPosition().hashCode() ^ getEndPosition().hashCode();
92    }
93   
 
94  26772 toggle public final boolean equals(final Object obj) {
95  26772 if (!(obj instanceof SourceArea)) {
96  0 return false;
97    }
98  26772 final SourceArea other = (SourceArea) obj;
99  26772 return getAddress().equals(other.getAddress())
100    && getStartPosition().equals(other.getStartPosition())
101    && getEndPosition().equals(other.getEndPosition());
102    }
103   
104    /**
105    * Get short description of area. Looks like "line1:column1 - line2:column2".
106    *
107    * @return Textual description of area without address.
108    */
 
109  0 toggle public final String getShortDescription() {
110  0 return getStartPosition().getRow() + ":" + getStartPosition().getColumn()
111    + " - " + getEndPosition().getRow() + ":" + getEndPosition().getColumn();
112    }
113   
 
114  44 toggle public final String toString() {
115  44 return getAddress() + ":" + getStartPosition().getRow() + ":" + getStartPosition().getColumn()
116    + ":" + getEndPosition().getRow() + ":" + getEndPosition().getColumn();
117    }
118   
119    }