Commit b638d1b1 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

refactored out decodeBytes and decodeIntentions

parent 4822f9c3
......@@ -16,17 +16,33 @@ public class DecoderChannel implements Decoder {
this.in = new DataInputStream(in);
}
private void processSampleDef() throws IOException {
int index = decodePacked32();
int numIntentions = decodePacked32();
if(numIntentions != 1) {
System.out.println("WARNING: #intentions == "+numIntentions);
private byte[] decodeBytes() throws IOException {
int len = decodePacked32();
byte result[] = new byte[len];
for(int i=0; i<len; i++) {
result[i] = decodeByte();
}
int keylen = decodePacked32();
if(keylen != 0) {
System.out.println("WARNING: keylen == "+keylen);
return result;
}
private String decodeIntentions() throws IOException {
int numIntentions = decodePacked32();
String name = "";
for(int i = 0; i<numIntentions; i++) {
byte key[] = decodeBytes();
byte val[] = decodeBytes();
if(key.length == 0) {
name = new String(val);
}
}
String name = decodeString();
return name;
}
private void processSampleDef() throws IOException {
int index = decodePacked32();
String name = decodeIntentions();
int signature_length = decodePacked32();
byte[] signature = new byte[signature_length];
ReadBytes(signature, signature_length);
......@@ -35,15 +51,7 @@ public class DecoderChannel implements Decoder {
private void processSampleRef() throws IOException {
int index = decodePacked32();
int numIntentions = decodePacked32();
if(numIntentions != 1) {
System.out.println("WARNING: #intentions == "+numIntentions);
}
int keylen = decodePacked32();
if(keylen != 0) {
System.out.println("WARNING: keylen == "+keylen);
}
String name = decodeString();
String name = decodeIntentions();
int signature_length = decodePacked32();
byte[] signature = new byte[signature_length];
ReadBytes(signature, signature_length);
......@@ -55,15 +63,7 @@ public class DecoderChannel implements Decoder {
processSample(Constant.TYPE_DEF);
} catch(Exception ex) {
int idx = decodePacked32();
int numIntentions = decodePacked32();
if(numIntentions != 1) {
System.out.println("WARNING: #intentions == "+numIntentions);
}
int keylen = decodePacked32();
if(keylen != 0) {
System.out.println("WARNING: keylen == "+keylen);
}
String name = decodeString();
String name = decodeIntentions();
int siglen = decodePacked32();
for(int i=0; i<siglen; i++) {
byte b = decodeByte();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment