Skip to content
Snippets Groups Projects
Commit dd1fc768 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Add klass utility to return class name.

parent 1884f515
No related branches found
No related tags found
No related merge requests found
......@@ -15,4 +15,6 @@ public interface ICacheFile {
CacheFileHeader getHeader();
void report(StringBuilder builder);
String klass();
}
......@@ -19,7 +19,7 @@ public class SQCacheFile implements ICacheFile {
assert (header.getCodebookSize() == codebook.getCodebookSize());
}
public void writeToStream(DataOutputStream outputStream) throws IOException {
public void writeToStream(final DataOutputStream outputStream) throws IOException {
header.writeToStream(outputStream);
final int[] quantizationValues = codebook.getCentroids();
final long[] frequencies = codebook.getSymbolFrequencies();
......@@ -32,13 +32,13 @@ public class SQCacheFile implements ICacheFile {
}
}
public void readFromStream(DataInputStream inputStream) throws IOException {
public void readFromStream(final DataInputStream inputStream) throws IOException {
header = new CacheFileHeader();
header.readFromStream(inputStream);
readFromStream(inputStream, header);
}
public void readFromStream(DataInputStream inputStream, CacheFileHeader header) throws IOException {
public void readFromStream(final DataInputStream inputStream, final CacheFileHeader header) throws IOException {
this.header = header;
final int codebookSize = header.getCodebookSize();
final int[] centroids = new int[codebookSize];
......@@ -62,7 +62,7 @@ public class SQCacheFile implements ICacheFile {
}
@Override
public void report(StringBuilder builder) {
public void report(final StringBuilder builder) {
final int[] centroids = codebook.getCentroids();
for (int i = 0; i < centroids.length; i++) {
......@@ -73,4 +73,9 @@ public class SQCacheFile implements ICacheFile {
}
}
}
@Override
public String klass() {
return "SQCacheFile";
}
}
......@@ -19,7 +19,7 @@ public class VQCacheFile implements ICacheFile {
assert (header.getCodebookSize() == codebook.getCodebookSize());
}
public void writeToStream(DataOutputStream outputStream) throws IOException {
public void writeToStream(final DataOutputStream outputStream) throws IOException {
header.writeToStream(outputStream);
final int[][] entries = codebook.getVectors();
......@@ -35,14 +35,14 @@ public class VQCacheFile implements ICacheFile {
}
}
public void readFromStream(DataInputStream inputStream) throws IOException {
public void readFromStream(final DataInputStream inputStream) throws IOException {
header = new CacheFileHeader();
header.readFromStream(inputStream);
readFromStream(inputStream, header);
}
@Override
public void readFromStream(DataInputStream inputStream, CacheFileHeader header) throws IOException {
public void readFromStream(final DataInputStream inputStream, final CacheFileHeader header) throws IOException {
this.header = header;
final int codebookSize = header.getCodebookSize();
......@@ -72,13 +72,18 @@ public class VQCacheFile implements ICacheFile {
}
@Override
public void report(StringBuilder builder) {
public void report(final StringBuilder builder) {
final int[][] vectors = codebook.getVectors();
for (int[] vector : vectors) {
for (final int[] vector : vectors) {
builder.append("- - - - - - - - - - - - - - - - - - - - - - - - -\n");
for (final int x : vector) {
builder.append(x).append(';');
}
}
}
@Override
public String klass() {
return "VQCacheFile";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment