Inspector | Message | Severity | Location |
---|---|---|---|
Java Inspector 048 | Copyrights information should be present in each file. | 1 | |
Java Inspector 070-A | Cyclomatic complexity is too high: 14, maximum allowed is 12 | 2 | 33:9 |
Java Inspector 089 | Type is not documented | 2 | 31:1 |
Java Inspector 089 | Undocumented method | 2 | 33:9 |
Java Inspector 089 | Undocumented method | 2 | 68:9 |
Java Inspector 005 | Classes, interfaces, methods, and variables should be named according to Sun's naming conventions. | 3 | 33:9 |
Java Inspector 026 | Avoid hardwired string literals. Allowed literals: [] | 3 | 55:65 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 34:17 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 36:24 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 44:33 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 52:24 |
Java Inspector 090 | Unnecessary else part in if. The main part terminates control flow (return, break, throw, or continue). | 3 | 61:17 |
1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.legacy.review;
24
25import java.util.Comparator;
26
27/**
28 * @author Pavel Vlasov
29 * @version $Revision: 1.3 $
30 */
31public class SourceMarkerComparator implements Comparator {
32
33 public static int _compare(Object o1, Object o2) {
34 if (o1==null) {
35 return o2==null ? 0 : 1;
36 } else if (o2==null) {
37 return -1;
38 } else if (o1 instanceof SourceMarker && o2 instanceof SourceMarker) {
39 SourceMarker sm1=(SourceMarker) o1;
40 SourceMarker sm2=(SourceMarker) o2;
41 int compareIds=_compare(sm1.getSourceId(), sm2.getSourceId());
42 if (compareIds==0) {
43 int compareSourceURLs=_compare(sm1.getSourceURL(), sm2.getSourceURL());
44 if (compareSourceURLs==0) {
45 return comparePosition(sm1, sm2);
46 } else {
47 return compareSourceURLs;
48 }
49 } else {
50 return compareIds;
51 }
52 } else if (o1 instanceof Comparable) {
53 return ((Comparable) o1).compareTo(o2);
54 } else {
55 throw new UnsupportedOperationException("Comparision of objects other than SourceMarker is not supported");
56 }
57 }
58
59
60 private static int comparePosition(SourceMarker sm1, SourceMarker sm2) {
61 if (sm1.getLine()==sm2.getLine()) {
62 return sm1.getColumn()-sm2.getColumn();
63 } else {
64 return sm1.getLine()-sm2.getLine();
65 }
66 }
67
68 public int compare(Object o1, Object o2) {
69 return _compare(o1, o2);
70 }
71}
72