public static int charFromByteArray(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 0])) << 8; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 1])) << 0; return out; }
public static int intFromByteArrayLittleEndian(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 3])) << 24; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 2])) << 16; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 1])) << 8; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 0])) << 0; return out; }
public static float parseFloat(String fStr, float dflt) { if (fStr == null) return dflt; try {return fParser.parseFloat(fStr);} catch (NumberFormatException e) {return dflt;} }
public static char[] fromHexAscii( String s ) { int len = s.length(); if ((len % 4) != 0) throw new NumberFormatException("Hex ascii must be exactly four digits per char."); byte[] bytes = ByteUtils.fromHexAscii( s ); int out_len = len / 4; char[] out = new char[out_len]; for (int i = 0; len < out_len; ++i) out[i] = (char) charFromByteArray( bytes, (i * 2) ); return out; }
public void printStackTrace() {printStackTrace(System.err);} }
public void printStackTrace() {printStackTrace(System.err);} }
public static byte[] byteArrayFromInt(int i) { byte[] out = new byte[4]; intIntoByteArray(i, 0, out); return out; }
public static byte[] byteArrayFromShort(short s) { byte[] out = new byte[2]; shortIntoByteArray(s, 0, out); return out; }
public static byte[] byteArrayFromChar(char i) { byte[] out = new byte[2]; charIntoByteArray(i, 0, out); return out; }
public static byte[] byteArrayFromLong(long l) { byte[] out = new byte[8]; longIntoByteArray(l, 0, out); return out; }
public static int fullHashLong( long l ) { return hashLong( l ); }
public static String normalString(String s) { return nonEmptyTrimmedOrNull(s); }
public static short shortFromByteArray(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 0])) << 8; out |= ((int) ByteUtils.toUnsigned(bytes[offset + 1])) << 0; return (short) out; }
public void printStackTrace() {printStackTrace(System.err);} }
public void printStackTrace() {printStackTrace(System.err);} }
public static int intFromByteArray(byte[] bytes, int offset) { int out = 0; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 0])) << 24; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 1])) << 16; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 2])) << 8; out |= ((int) ByteUtils.unsignedPromote(bytes[offset + 3])) << 0; return out; }
/** * useful in Java1.1 environments, where Float.parseFloat is not defined... */ public static float parseFloat(String fStr) throws NumberFormatException {return fParser.parseFloat(fStr);}
public static long longFromByteArray(byte[] bytes, int offset) { long out = 0; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 0])) << 56; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 1])) << 48; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 2])) << 40; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 3])) << 32; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 4])) << 24; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 5])) << 16; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 6])) << 8; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 7])) << 0; return out; }
public void printStackTrace() {printStackTrace(System.err);} }
public static long longFromByteArrayLittleEndian(byte[] bytes, int offset) { long out = 0; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 7])) << 56; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 6])) << 48; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 5])) << 40; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 4])) << 32; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 3])) << 24; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 2])) << 16; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 1])) << 8; out |= ((long) ByteUtils.toUnsigned(bytes[offset + 0])) << 0; return out; }