blob: c14af9eb13aecda962baa06ecbdd7968800799ad (
plain) (
blame)
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
|
package org.uic.barcode.asn1.uper;
public class AsnExtractor {
private String path = null;
private boolean extractionStarted = false;
private boolean extractionCompleted = false;
private BitBuffer bitBuffer = null;
private int startBit = 0;
private int endBit = 0;
AsnExtractor(String path, BitBuffer bitBuffer) {
this.path = path;
this.bitBuffer = bitBuffer;
}
public byte[] getResult() {
if (!extractionCompleted) {
return null;
}
if (!(endBit > startBit)) {
return null;
}
String bitString = bitBuffer.toBooleanString(startBit, endBit - startBit);
while (bitString.length() % 8 != 0) {
bitString = bitString + "0";
}
return AsnUtils.fromBooleanString(bitString);
}
public boolean found(String className) {
if (extractionStarted || extractionCompleted) return false;
if (path != null && path.length() > 0 &&
className != null && className.length() > 0 &&
className.endsWith(path)) {
return true;
}
return false;
}
public void startExtraction(int position) {
if (path == null || path.length() == 0 || bitBuffer == null) {
return;
}
if (!extractionCompleted && !extractionStarted) {
extractionStarted = true;
startBit = position;
}
}
public void endExtraction(int position) {
if (extractionStarted) {
extractionCompleted = true;
endBit = position;
}
}
public boolean isStarted() {
return extractionStarted;
}
}
|