Debian Codegraph @

src/uk/me/parabola/imgfmt/app/mdr/Mdr4Record.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13
14 package uk.me.parabola.imgfmt.app.mdr;
15
16 /**
17 * The records in MDR 4 are a list of poi types with an unknown byte.
18 */
19 public class Mdr4Record implements Comparable<Mdr4Record> {
20 private final int type;
21 private final int subtype;
22 private int unknown;
23
24 public Mdr4Record(int type, int subtype) {
25 this.type = type;
26 this.subtype = subtype;
27 }
28
29 public int compareTo(Mdr4Record o) {
30 int t1 = ((type << 8) + subtype) & 0xffff;
31 int t2 = ((o.type << 8) + o.subtype) & 0xffff;
32 return Integer.compare(t1, t2);
33 }
34
35 public boolean equals(Object o) {
36 if (this == o) return true;
37 if (o == null || getClass() != o.getClass()) return false;
38
39 Mdr4Record that = (Mdr4Record) o;
40
41 if (subtype != that.subtype) return false;
42 return (type == that.type);
43 }
44
45
46 public int hashCode() {
47 int result = type;
48 result = 31 * result + subtype;
49 return result;
50 }
51
52 public int getType() {
53 return type;
54 }
55
56 public int getSubtype() {
57 return subtype;
58 }
59
60 public int getUnknown() {
61 return unknown;
62 }
63
64 public void setUnknown(int unknown) {
65 this.unknown = unknown;
66 }
67 }