Debian Codegraph @

src/uk/me/parabola/tdbfmt/CopyrightSegment.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 Steve Ratcliffe
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 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: 23-Sep-2007
16 */
17 package uk.me.parabola.tdbfmt;
18
19 import uk.me.parabola.io.StructuredInputStream;
20 import uk.me.parabola.io.StructuredOutputStream;
21
22 import java.io.IOException;
23
24 /**
25 * One copyright that is within the copyright block.
26 *
27 * @author Steve Ratcliffe
28 */
29 class CopyrightSegment {
30
31 /**
32 * Source information text string. Describes what data sources were used
33 * in generating the map.
34 */
35 public static final int CODE_SOURCE_INFORMATION = 0x00;
36
37 /** Copyright information from the map manufacturer. */
38 public static final int CODE_COPYRIGHT_TEXT_STRING = 0x06;
39
40 /**
41 * A filename that contains a BMP image to be printed along with
42 * the map.
43 */
44 public static final int CODE_COPYRIGHT_BITMAP_REFERENCE = 0x07;
45
46 /**
47 * A code that shows what kind of copyright information is
48 * contained in this segment.
49 * The field {@link #extraProperties} can be used too as extra information.
50 */
51 private final byte copyrightCode;
52 private final byte whereCode;
53 private final short extraProperties;
54 private final String copyright;
55
56 CopyrightSegment(StructuredInputStream ds) throws IOException {
57 copyrightCode = (byte) ds.read();
58 whereCode = (byte) ds.read();
59 extraProperties = (short) ds.read2();
60 copyright = ds.readString();
61 }
62
63 CopyrightSegment(int code, int where, String msg) {
64 this.copyrightCode = (byte) code;
65 this.whereCode = (byte) where;
66 this.copyright = msg;
67 this.extraProperties = 0;
68 }
69
70 public void write(StructuredOutputStream os) throws IOException {
71 os.write(copyrightCode);
72 os.write(whereCode);
73 os.write2(extraProperties);
74 os.writeString(copyright);
75 }
76
77 public String toString() {
78 return "Copyright: "
79 + copyrightCode
80 + ", where="
81 + whereCode
82 + ", extra="
83 + extraProperties
84 + ": "
85 + copyright
86 ;
87 }
88
89 public boolean equals(Object o) {
90 if (this == o) return true;
91 if (o == null || !(o instanceof CopyrightSegment)) return false;
92
93 CopyrightSegment that = (CopyrightSegment) o;
94
95 if (copyrightCode != that.copyrightCode) return false;
96 if (extraProperties != that.extraProperties) return false;
97 if (whereCode != that.whereCode) return false;
98 if (!copyright.equals(that.copyright)) return false;
99
100 return true;
101 }
102
103 public int hashCode() {
104 int result = (int) copyrightCode;
105 result = 31 * result + (int) whereCode;
106 result = 31 * result + (int) extraProperties;
107 result = 31 * result + copyright.hashCode();
108 return result;
109 }
110 }