| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
class CopyrightSegment { |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public static final int CODE_SOURCE_INFORMATION = 0x00; |
| 36 |
|
| 37 |
|
| 38 |
public static final int CODE_COPYRIGHT_TEXT_STRING = 0x06; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public static final int CODE_COPYRIGHT_BITMAP_REFERENCE = 0x07; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 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 |
} |