public static String toHexAscii(char c) { StringWriter sw = new StringWriter(4); ByteUtils.addHexAscii((byte) ((c >>> 8) & 0xFF), sw); ByteUtils.addHexAscii((byte) (c & 0xFF), sw); return sw.toString(); }
static void addHexAscii(byte b, StringWriter sw) { short ub = toUnsigned(b); int h1 = ub / 16; int h2 = ub % 16; sw.write(toHexDigit(h1)); sw.write(toHexDigit(h2)); }
public static String toLowercaseHexAscii(byte[] bytes) { int len = bytes.length; StringWriter sw = new StringWriter(len * 2); for (int i = 0; i < len; ++i) addLowercaseHexAscii(bytes[i], sw); return sw.toString(); }
static void addHexAscii(byte b, StringWriter sw) { int ub = unsignedPromote(b); int h1 = ub / 16; int h2 = ub % 16; sw.write(toHexDigit(h1)); sw.write(toHexDigit(h2)); }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public static String createUserOverridesAsString( Map userOverrides ) throws IOException { StringBuffer sb = new StringBuffer(); sb.append(HASM_HEADER); sb.append('['); sb.append( ByteUtils.toHexAscii( SerializableUtils.toByteArray( userOverrides ) ) ); sb.append(']'); return sb.toString(); }
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 byte[] fromHexAscii(String s) throws NumberFormatException { try { int len = s.length(); if ((len % 2) != 0) throw new NumberFormatException("Hex ascii must be exactly two digits per byte."); int out_len = len / 2; byte[] out = new byte[out_len]; int i = 0; StringReader sr = new StringReader(s); while (i < out_len) { int val = (16 * fromHexDigit(sr.read())) + fromHexDigit(sr.read()); out[i++] = (byte) val; } return out; } catch (IOException e) {throw new InternalError("IOException reading from StringReader?!?!");} }
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 static String createUserOverridesAsString( Map userOverrides ) throws IOException { StringBuffer sb = new StringBuffer(); sb.append(HASM_HEADER); sb.append('['); sb.append( ByteUtils.toHexAscii( SerializableUtils.toByteArray( userOverrides ) ) ); sb.append(']'); return sb.toString(); }
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 static byte[] fromHexAscii(String s) throws NumberFormatException { try { int len = s.length(); if ((len % 2) != 0) throw new NumberFormatException("Hex ascii must be exactly two digits per byte."); int out_len = len / 2; byte[] out = new byte[out_len]; int i = 0; StringReader sr = new StringReader(s); while (i < out_len) { int val = (16 * fromHexDigit(sr.read())) + fromHexDigit(sr.read()); out[i++] = (byte) val; } return out; } catch (IOException e) {throw new InternalError("IOException reading from StringReader?!?!");} }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }
public static String createUserOverridesAsString( Map userOverrides ) throws IOException { StringBuffer sb = new StringBuffer(); sb.append(HASM_HEADER); sb.append('['); sb.append( ByteUtils.toHexAscii( SerializableUtils.toByteArray( userOverrides ) ) ); sb.append(']'); return sb.toString(); }
static void addHexAscii(byte b, StringWriter sw) { short ub = toUnsigned(b); int h1 = ub / 16; int h2 = ub % 16; sw.write(toHexDigit(h1)); sw.write(toHexDigit(h2)); }
public static String toHexAscii(byte b) { StringWriter sw = new StringWriter(2); addHexAscii(b, sw); return sw.toString(); }
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 static byte[] fromHexAscii(String s) throws NumberFormatException { try { int len = s.length(); if ((len % 2) != 0) throw new NumberFormatException("Hex ascii must be exactly two digits per byte."); int out_len = len / 2; byte[] out = new byte[out_len]; int i = 0; StringReader sr = new StringReader(s); while (i < out_len) { int val = (16 * fromHexDigit(sr.read())) + fromHexDigit(sr.read()); out[i++] = (byte) val; } return out; } catch (IOException e) {throw new InternalError("IOException reading from StringReader?!?!");} }
public static String toLowercaseHexAscii(byte b) { StringWriter sw = new StringWriter(2); addLowercaseHexAscii(b, sw); return sw.toString(); }
public static Map parseUserOverridesAsString( String userOverridesAsString ) throws IOException, ClassNotFoundException { if (userOverridesAsString != null) { String hexAscii = userOverridesAsString.substring(HASM_HEADER.length() + 1, userOverridesAsString.length() - 1); byte[] serBytes = ByteUtils.fromHexAscii( hexAscii ); return Collections.unmodifiableMap( (Map) SerializableUtils.fromByteArray( serBytes ) ); } else return Collections.EMPTY_MAP; }