Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed .class files and refactored to generic InputStream instead of FileInputStream #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed src/ch/timesplinter/sfo4j/common/SFODataValue.class
Binary file not shown.
Binary file removed src/ch/timesplinter/sfo4j/common/SFOUtilities.class
Binary file not shown.
Binary file removed src/ch/timesplinter/sfo4j/reader/SFOHeader.class
Binary file not shown.
4 changes: 2 additions & 2 deletions src/ch/timesplinter/sfo4j/reader/SFOHeader.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.timesplinter.sfo4j.reader;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import ch.timesplinter.sfo4j.common.SFOUtilities;

Expand All @@ -13,7 +13,7 @@ public class SFOHeader {
private int offsetValueTable;
private int numberDataItems;

public static SFOHeader read(FileInputStream fIn) throws IOException {
public static SFOHeader read(InputStream fIn) throws IOException {
SFOHeader sfoHeader = new SFOHeader();

byte[] tempByteArray = new byte[4];
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/ch/timesplinter/sfo4j/reader/SFOIndexTableEntry.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.timesplinter.sfo4j.reader;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import ch.timesplinter.sfo4j.common.SFOUtilities;

Expand All @@ -22,7 +22,7 @@ public class SFOIndexTableEntry {
* @return SFOIndexTableEntry
* @throws IOException
*/
public static SFOIndexTableEntry readEntry(FileInputStream fIn) throws IOException {
public static SFOIndexTableEntry readEntry(InputStream fIn) throws IOException {
SFOIndexTableEntry sfoIndexTableEntry = new SFOIndexTableEntry();

byte[] tempByteArray1 = new byte[1];
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/ch/timesplinter/sfo4j/reader/SFOKeyTableEntry.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.timesplinter.sfo4j.reader;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class SFOKeyTableEntry {
public final static byte DELIMITER_BYTE = 0;
Expand All @@ -18,7 +18,7 @@ public SFOKeyTableEntry() {
* @return String
* @throws IOException
*/
public String readEntry(FileInputStream fIn) throws IOException {
public String readEntry(InputStream fIn) throws IOException {
byte[] tempByteArray1 = new byte[1];
StringBuilder sb = new StringBuilder();

Expand Down
Binary file removed src/ch/timesplinter/sfo4j/reader/SFOReader.class
Binary file not shown.
24 changes: 13 additions & 11 deletions src/ch/timesplinter/sfo4j/reader/SFOReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -28,29 +29,30 @@
public class SFOReader {
public static final int HEADER_SIZE = 20;

private String sfoFile;
private SFOHeader sfoHeader;
private List<SFOIndexTableEntry> indexTableEntryList = new ArrayList<SFOIndexTableEntry>();
private List<String> keyTableEntryList = new ArrayList<String>();
private List<SFODataValue> valueTableEntryList = new ArrayList<SFODataValue>();
private Map<String,SFODataValue> keyValueMap = new TreeMap<String,SFODataValue>();

public SFOReader(String sfoFile) throws IOException {
this.sfoFile = sfoFile;
parse();
File inFile = new File(sfoFile);
FileInputStream fIn;

fIn = new FileInputStream(inFile);
parse(fIn);
}

public SFOReader(InputStream fIn) throws IOException {
parse(fIn);
}

/**
* parse the submitted file (sfoFile) with the constructor and
* parse the submitted inputStream and
* fills the different ArrayLists and HashMaps
* @throws IOException
*/
private void parse() throws IOException {
File inFile = new File(sfoFile);
FileInputStream fIn;

fIn = new FileInputStream(inFile);

private void parse(InputStream fIn) throws IOException {
// sfoHeader lesen
sfoHeader = SFOHeader.read(fIn);

Expand All @@ -60,7 +62,7 @@ private void parse() throws IOException {
}

// Zum KeyTable Anfang springen
// (offset der KeyTabelle - Header-L�nge - Anzahl * IndexEntry L�nge = restl. zu ignorierende Bytes)
// (offset der KeyTabelle - Header-Länge - Anzahl * IndexEntry Länge = restl. zu ignorierende Bytes)
int skipBytesToKeyTable = sfoHeader.getOffsetKeyTable()-HEADER_SIZE-(sfoHeader.getNumberDataItems()*SFOIndexTableEntry.INDEX_TABLE_ENTRY_LENGTH);
fIn.skip(skipBytesToKeyTable);

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions src/ch/timesplinter/sfo4j/reader/SFOValueTableEntry.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.timesplinter.sfo4j.reader;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;


public class SFOValueTableEntry {
Expand All @@ -19,7 +19,7 @@ public SFOValueTableEntry() {
* @return String
* @throws IOException
*/
public byte[] readEntry(FileInputStream fIn, SFOIndexTableEntry sfoIndexTableEntry) throws IOException {
public byte[] readEntry(InputStream fIn, SFOIndexTableEntry sfoIndexTableEntry) throws IOException {
byte[] entryByteArray = new byte[sfoIndexTableEntry.getSizeValueData()];

fIn.read(entryByteArray,0,sfoIndexTableEntry.getSizeValueData());
Expand Down
Binary file removed src/ch/timesplinter/sfo4j/writer/SFOWriter.class
Binary file not shown.