-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathInputStreamIdentificationRequest.java
72 lines (61 loc) · 1.79 KB
/
InputStreamIdentificationRequest.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
/**
*
*/
package uk.bl.wap.nanite.droid;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import net.domesdaybook.reader.ByteReader;
import uk.gov.nationalarchives.droid.core.interfaces.IdentificationRequest;
import uk.gov.nationalarchives.droid.core.interfaces.RequestIdentifier;
import uk.gov.nationalarchives.droid.core.interfaces.resource.RequestMetaData;
/**
* @author Andrew Jackson <Andrew.Jackson@bl.uk>
*
*/
public class InputStreamIdentificationRequest extends ByteArrayIdentificationRequest {
private InputStream in = null;
private InputStreamByteReader isReader;
public InputStreamIdentificationRequest(RequestMetaData metaData,
RequestIdentifier identifier, InputStream in) {
this.metaData = metaData;
this.identifier = identifier;
try {
this.size = in.available();
} catch (IOException e) {
e.printStackTrace();
}
this.isReader = new InputStreamByteReader(in);
this.in = in;
}
/* (non-Javadoc)
* @see uk.gov.nationalarchives.droid.core.interfaces.IdentificationRequest#getByte(long)
*/
@Override
public byte getByte(long position) {
return this.isReader.readByte(position);
}
/* (non-Javadoc)
* @see uk.gov.nationalarchives.droid.core.interfaces.IdentificationRequest#getReader()
*/
@Override
public ByteReader getReader() {
return this.isReader;
}
/* (non-Javadoc)
* @see uk.gov.nationalarchives.droid.core.interfaces.IdentificationRequest#close()
*/
@Override
public void close() throws IOException {
in.close();
new Exception("ACK").printStackTrace();
}
/* (non-Javadoc)
* @see uk.gov.nationalarchives.droid.core.interfaces.IdentificationRequest#getSourceInputStream()
*/
@Override
public InputStream getSourceInputStream() throws IOException {
return in;
}
}