Some code style improvements

This commit is contained in:
Christian Basler 2016-12-11 14:27:21 +01:00
parent 6d67598a40
commit c11a1b78c4
4 changed files with 4 additions and 8 deletions

View File

@ -84,7 +84,7 @@ public class Message implements ExtendedEncoding.ExtendedType {
}
packer.packMapHeader(size);
packer.packString("");
packer.packString("message");
packer.packString(TYPE);
packer.packString("subject");
packer.packString(subject);
packer.packString("body");

View File

@ -58,7 +58,7 @@ public class Vote implements ExtendedEncoding.ExtendedType {
public void pack(MessagePacker packer) throws IOException {
packer.packMapHeader(3);
packer.packString("");
packer.packString("vote");
packer.packString(TYPE);
packer.packString("msgId");
packer.packBinaryHeader(msgId.getHash().length);
packer.writePayload(msgId.getHash());

View File

@ -22,6 +22,7 @@ import java.util.zip.InflaterInputStream;
public class ExtendedEncodingFactory {
private static final Logger LOG = LoggerFactory.getLogger(ExtendedEncodingFactory.class);
private static final ExtendedEncodingFactory INSTANCE = new ExtendedEncodingFactory();
private static final String KEY_MESSAGE_TYPE = "";
private Map<String, ExtendedEncoding.Unpacker<?>> factories = new HashMap<>();
private ExtendedEncodingFactory() {
@ -39,7 +40,7 @@ public class ExtendedEncodingFactory {
MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(unzipper);
int mapSize = unpacker.unpackMapHeader();
String key = unpacker.unpackString();
if (!"".equals(key)) {
if (!KEY_MESSAGE_TYPE.equals(key)) {
LOG.error("Unexpected content: " + key);
return null;
}

View File

@ -16,11 +16,6 @@
package ch.dissem.bitmessage.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
/**
* A helper class for working with byte arrays interpreted as unsigned big endian integers.
* This is one part due to the fact that Java doesn't support unsigned numbers, and another