public static String bytesToHex(byte[] bs) { if (bs == null) { return null; } return bytesToHex(bs, 0, bs.length); }
public static byte[] hexToBytes(String s) { return hexToBytes(s, 0); }
@Deprecated public static String formatBytes(byte[] bytes) { StringBuilder builder = new StringBuilder(); for (byte b : bytes) { appendHex(builder, b - Byte.MIN_VALUE); } return builder.toString(); }
@Deprecated public static String formatByte(int b) { assertByte(b); return "" + DIGITS[b >> 4] + DIGITS[b & 0xf]; //$NON-NLS-1$ }
/** * Converts a byte array into a string of lower case hex chars. * * @param bs * A byte array * @param off * The index of the first byte to read * @param length * The number of bytes to read. * @return the string of hex chars. */ public static String bytesToHex(byte[] bs, int off, int length) { if (bs == null) { return null; } if (bs.length <= off || bs.length < off + length) { throw new IllegalArgumentException(); } StringBuilder sb = new StringBuilder(length * 2); bytesToHexAppend(bs, off, length, sb); return sb.toString(); }
@Deprecated public static void appendHex(StringBuilder builder, int b) { assertByte(b); builder.append(DIGITS[b >> 4]); builder.append(DIGITS[b & 0xf]); }
@Override public String toString() { return MessageFormat.format("Message[type={0}, priority={1}, data={3}]", type, priority, HexUtil.bytesToHex(data)); }
@Override protected byte[] convert(String value) { return HexUtil.hexToBytes(value); }
@Override public String toString() { return MessageFormat.format("Message[type={0}, priority={1}, data={3}]", type, priority, HexUtil.bytesToHex(data)); }
public static byte[] hexToBytes(String s, int off) { byte[] bs = new byte[off + (1 + s.length()) / 2]; hexToBytes(s, bs, off); return bs; }
@Override public String toString() { return MessageFormat.format("{0}[id={1}, size={2}]", getClass().getSimpleName(), HexUtil.bytesToHex(id), size); } }
@Override public Object getResultSetValue(ResultSet resultSet) throws SQLException { String str = resultSet.getString(getField().getName()); if (str == null) { return null; } int pos = str.indexOf('-'); byte[] id = HexUtil.hexToBytes(str.substring(0, pos)); long size = Long.parseLong(str.substring(pos + 1)); return CDOLobUtil.createClob(id, size); }
public static String createDurableLockingID(int bytes) { byte[] buffer = new byte[bytes]; Random random = new Random(System.currentTimeMillis()); random.nextBytes(buffer); return HexUtil.bytesToHex(buffer); } }
@Override public Object getResultSetValue(ResultSet resultSet) throws SQLException { String str = resultSet.getString(getField().getName()); if (str == null) { return null; } int pos = str.indexOf('-'); byte[] id = HexUtil.hexToBytes(str.substring(0, pos)); long size = Long.parseLong(str.substring(pos + 1)); return CDOLobUtil.createBlob(id, size); }
public synchronized void queryLobs(List<byte[]> ids) { for (Iterator<byte[]> it = ids.iterator(); it.hasNext();) { byte[] id = it.next(); String key = HexUtil.bytesToHex(id); if (!lobs.containsKey(key)) { it.remove(); } } }
blobChar = null; byte[] firstByte = HexUtil.hexToBytes(new String(firstChars)); blob.write(firstByte, 0, 1); byte[] buf = HexUtil.hexToBytes(new String(ch)); blob.write(buf);
public synchronized void writeClob(byte[] id, long size, Reader reader) throws IOException { CharArrayWriter out = new CharArrayWriter(); IOUtil.copyCharacter(reader, out, size); lobs.put(HexUtil.bytesToHex(id), out.toCharArray()); }
protected Object value(Attributes attributes) { String type = attributes.getValue(FEATURE_TYPE); if (TYPE_BLOB.equals(type)) { byte[] id = HexUtil.hexToBytes(attributes.getValue(FEATURE_ID)); long size = Long.parseLong(attributes.getValue(FEATURE_SIZE)); return CDOLobUtil.createBlob(id, size); } if (TYPE_CLOB.equals(type)) { byte[] id = HexUtil.hexToBytes(attributes.getValue(FEATURE_ID)); long size = Long.parseLong(attributes.getValue(FEATURE_SIZE)); return CDOLobUtil.createClob(id, size); } if (TYPE_FEATURE_MAP.equals(type)) { String innerFeatureName = attributes.getValue(FEATURE_INNER_FEATURE); EStructuralFeature innerFeature = revision.getEClass().getEStructuralFeature(innerFeatureName); String innerType = attributes.getValue(FEATURE_INNER_TYPE); Object innerValue = value(attributes, innerType); return CDORevisionUtil.createFeatureMapEntry(innerFeature, innerValue); } return value(attributes, type); }
public File getCharacterFile(byte[] id) { return new File(getFolder(), HexUtil.bytesToHex(id) + ".clob"); }
byte[] id = HexUtil.hexToBytes(entry.getKey()); Object lob = entry.getValue(); if (lob instanceof byte[])