mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Added comments and am in the process of testing
This commit is contained in:
parent
ee3c0c01d2
commit
859f1faba9
@ -27,17 +27,16 @@ import java.nio.file.Path;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts XRY entities and determines the report type. An
|
* Extracts XRY entities and determines the report type. An example of an XRY
|
||||||
* example of an XRY entity would be:
|
* entity would be:
|
||||||
*
|
*
|
||||||
* Calls # 1
|
* Calls # 1
|
||||||
* Call Type: Missed
|
* Call Type: Missed
|
||||||
* Time: 1/2/2019 1:23:45 PM (Device)
|
* Time: 1/2/2019 1:23:45 PM (Device)
|
||||||
* From
|
* From
|
||||||
* Tel: 12345678
|
* Tel: 12345678
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class XRYFileReader {
|
public final class XRYFileReader implements AutoCloseable {
|
||||||
|
|
||||||
///Assume UTF_16LE
|
///Assume UTF_16LE
|
||||||
private static final Charset CHARSET = StandardCharsets.UTF_16LE;
|
private static final Charset CHARSET = StandardCharsets.UTF_16LE;
|
||||||
@ -45,6 +44,7 @@ public final class XRYFileReader {
|
|||||||
//Assume all headers are 5 lines in length.
|
//Assume all headers are 5 lines in length.
|
||||||
private static final int HEADER_LENGTH_IN_LINES = 5;
|
private static final int HEADER_LENGTH_IN_LINES = 5;
|
||||||
|
|
||||||
|
//Underlying reader for the xry file.
|
||||||
private final BufferedReader reader;
|
private final BufferedReader reader;
|
||||||
|
|
||||||
private final StringBuilder xryEntity;
|
private final StringBuilder xryEntity;
|
||||||
@ -62,8 +62,8 @@ public final class XRYFileReader {
|
|||||||
public XRYFileReader(Path xryFile) throws IOException {
|
public XRYFileReader(Path xryFile) throws IOException {
|
||||||
reader = Files.newBufferedReader(xryFile, CHARSET);
|
reader = Files.newBufferedReader(xryFile, CHARSET);
|
||||||
|
|
||||||
//Advance reader to start of the first XRY entity.
|
//Advance the reader to the start of the first XRY entity.
|
||||||
for(int i = 0; i < HEADER_LENGTH_IN_LINES; i++) {
|
for (int i = 0; i < HEADER_LENGTH_IN_LINES; i++) {
|
||||||
reader.readLine();
|
reader.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +71,11 @@ public final class XRYFileReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Advances the reader until the next valid XRY entity is detected.
|
||||||
*
|
*
|
||||||
* @return
|
* @return Indication that there is another XRY entity to consume or that
|
||||||
* @throws IOException
|
* the file has been exhausted.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public boolean hasNextEntity() throws IOException {
|
public boolean hasNextEntity() throws IOException {
|
||||||
//Entity has yet to be consumed.
|
//Entity has yet to be consumed.
|
||||||
@ -98,9 +100,12 @@ public final class XRYFileReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns an XRY entity if there is one, otherwise an exception is thrown.
|
||||||
*
|
*
|
||||||
* @return
|
* @return A non-empty XRY entity.
|
||||||
* @throws IOException
|
* @throws IOException if an I/O error occurs.
|
||||||
|
* @throws NoSuchElementException if there are no more XRY entities to
|
||||||
|
* consume.
|
||||||
*/
|
*/
|
||||||
public String nextEntity() throws IOException {
|
public String nextEntity() throws IOException {
|
||||||
if (hasNextEntity()) {
|
if (hasNextEntity()) {
|
||||||
@ -113,9 +118,11 @@ public final class XRYFileReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Closes any file handles this reader may have open.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
reader.close();
|
reader.close();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user