-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPalmDocHeader.java
136 lines (111 loc) · 3.63 KB
/
PalmDocHeader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package org.bandarra.mobireader;
/**
*
* @author andreban
*/
public class PalmDocHeader {
public enum CompressionType {
NO_COMPRESSION(1),
PALMDOC_COMPRESSION(2),
HUFF_CDIC_COMPRESSION(17480),
UNKNOWN(-1);
private int id;
private CompressionType(int id) {
this.id = id;
}
public int getId() {
return id;
}
public static CompressionType getById(int id) {
for (CompressionType type: CompressionType.values()) {
if (type.getId() == id) return type;
}
return CompressionType.UNKNOWN;
}
}
public enum EncryptionType {
NO_ENCRYPTION(0),
OLD_MOBIPOCKET_ENCRYPTION(1),
MOBIPOCKET_ENCRYPTION(2),
UNKNOWN(-1);
private int id;
private EncryptionType(int id) {
this.id = id;
}
public int getId() {
return this.id;
}
public static EncryptionType getById(int id) {
for (EncryptionType type: EncryptionType.values()) {
if (type.getId() == id) {
return type;
}
}
return EncryptionType.UNKNOWN;
}
}
private long textLength = 0;
private int recordCount = 0;
private int recordSize = 0;
private long currentPosition = 0;
private int compression = -1;
private int encryption = -1;
private CompressionType compressionType = CompressionType.UNKNOWN;
private EncryptionType encriptionType = EncryptionType.UNKNOWN;
public long getTextLength() {
return textLength;
}
public void setTextLength(long textLength) {
this.textLength = textLength;
}
public int getRecordCount() {
return recordCount;
}
public void setRecordCount(int recordCount) {
this.recordCount = recordCount;
}
public int getRecordSize() {
return recordSize;
}
public void setRecordSize(int recordSize) {
this.recordSize = recordSize;
}
public long getCurrentPosition() {
return currentPosition;
}
public void setCurrentPosition(long currentPosition) {
this.currentPosition = currentPosition;
}
public int getCompression() {
return compression;
}
public void setCompression(int compression) {
this.compression = compression;
this.compressionType = CompressionType.getById(compression);
}
public int getEncryption() {
return encryption;
}
public void setEncryption(int encryption) {
this.encryption = encryption;
this.encriptionType = EncryptionType.getById(encryption);
}
public CompressionType getCompressionType() {
return compressionType;
}
public void setCompressionType(CompressionType compressionType) {
this.compressionType = compressionType;
this.compression = compressionType.getId();
}
public EncryptionType getEncriptionType() {
return encriptionType;
}
public void setEncriptionType(EncryptionType encriptionType) {
this.encriptionType = encriptionType;
this.encryption = encriptionType.getId();
}
@Override
public String toString() {
return "PalmDocHeader{" + "textLength=" + textLength + ", recordCount=" + recordCount + ", recordSize=" + recordSize + ", currentPosition=" + currentPosition + ", compression=" + compression + ", encryption=" + encryption + ", compressionType=" + compressionType + ", encriptionType=" + encriptionType + '}';
}
}