This commit is contained in:
@@ -36,7 +36,7 @@ public final class DLongSimpledCoder<R extends Reader, W extends Writer> extends
|
||||
public DLong convertFrom(R in) {
|
||||
byte[] bs = bsSimpledCoder.convertFrom(in);
|
||||
if (bs == null) return null;
|
||||
return new DLong(bs);
|
||||
return DLong.create(bs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,6 @@ public class DLongJsonSimpledCoder extends JsonSimpledCoder<DLong> {
|
||||
public DLong convertFrom(JsonReader in) {
|
||||
final String str = in.readString();
|
||||
if (str == null) return null;
|
||||
return new DLong(Utility.hexToBin(str));
|
||||
return DLong.create(Utility.hexToBin(str));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract class Sncp {
|
||||
synchronized (md5) {
|
||||
bytes = md5.digest(bytes);
|
||||
}
|
||||
return new DLong(bytes);
|
||||
return DLong.create(bytes);
|
||||
}
|
||||
|
||||
public static boolean isRemote(Service service) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public final class DLong extends Number implements Comparable<DLong> {
|
||||
(byte) (v2 >> 24), (byte) (v2 >> 16), (byte) (v2 >> 8), (byte) v2};
|
||||
}
|
||||
|
||||
public DLong(byte[] bytes) {
|
||||
protected DLong(byte[] bytes) {
|
||||
if (bytes == null || bytes.length != 16) throw new NumberFormatException("Not 16 length bytes");
|
||||
this.bytes = bytes;
|
||||
}
|
||||
@@ -40,6 +40,11 @@ public final class DLong extends Number implements Comparable<DLong> {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static DLong create(byte[] bytes) {
|
||||
if (ZERO.equals(bytes)) return ZERO;
|
||||
return new DLong(bytes);
|
||||
}
|
||||
|
||||
public static DLong read(ByteBuffer buffer) {
|
||||
byte[] bs = new byte[16];
|
||||
buffer.get(bs);
|
||||
@@ -71,7 +76,7 @@ public final class DLong extends Number implements Comparable<DLong> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if(this == ZERO) return "0";
|
||||
if (this == ZERO) return "0";
|
||||
return new String(Utility.binToHex(bytes));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user