sb.append("NULL-value"); } else if (theValue instanceof byte[]) { sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte[]) theValue, 2), 150) + ")");
/** * from {@link java.io.DataInput} interface */ @Override public String readLine() throws IOException { return ByteUtil.readLine(this); }
public static boolean equals(final byte[] left, final byte[] right, final int rightOffset, final int rightLength) { if (left == right) return true; if (left == null || right == null) return false; if (left.length != rightLength) return false; if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { return equalsUnsafe(left, right, rightOffset, rightLength); } else { return equalsSafe(left, right, rightOffset, rightLength); } }
public static void debugFrame(Logger logger, String message, ByteBuf byteIn) { if (logger.isTraceEnabled()) { int location = byteIn.readerIndex(); // debugging byte[] frame = new byte[byteIn.writerIndex()]; byteIn.readBytes(frame); try { logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); } catch (Exception e) { logger.warn(e.getMessage(), e); } byteIn.readerIndex(location); } }
/** * Returns {@code true} if the {@link SimpleString} encoded content into {@code bytes} is equals to {@code s}, * {@code false} otherwise. * <p> * It assumes that the {@code bytes} content is read using {@link SimpleString#readSimpleString(ByteBuf, int)} ie starting right after the * length field. */ public static boolean equals(final byte[] bytes, final ByteBuf byteBuf, final int offset, final int length) { if (bytes.length != length) return false; if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { if ((offset + length) > byteBuf.writerIndex()) { throw new IndexOutOfBoundsException(); } if (byteBuf.hasArray()) { return equals(bytes, byteBuf.array(), byteBuf.arrayOffset() + offset, length); } else if (byteBuf.hasMemoryAddress()) { return equalsOffHeap(bytes, byteBuf.memoryAddress(), offset, length); } } return equalsOnHeap(bytes, byteBuf, offset, length); }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
/** * Returns {@code true} if the {@link SimpleString} encoded content into {@code bytes} is equals to {@code s}, * {@code false} otherwise. * <p> * It assumes that the {@code bytes} content is read using {@link SimpleString#readSimpleString(ByteBuf, int)} ie starting right after the * length field. */ public boolean equals(final ByteBuf byteBuf, final int offset, final int length) { return ByteUtil.equals(data, byteBuf, offset, length); }
private ActiveMQBuffer inflate(ActiveMQBuffer buffer) throws DataFormatException { int bytesToRead = buffer.readableBytes(); Inflater inflater = new Inflater(); inflater.setInput(ByteUtil.getActiveArray(buffer.readBytes(bytesToRead).toByteBuffer())); //get the real size of large message long sizeBody = getLongProperty(Message.HDR_LARGE_BODY_SIZE); byte[] data = new byte[(int) sizeBody]; inflater.inflate(data); inflater.end(); ActiveMQBuffer qbuff = ActiveMQBuffers.wrappedBuffer(data); qbuff.resetReaderIndex(); qbuff.resetWriterIndex(); qbuff.writeBytes(data); buffer = qbuff; return buffer; }
private String describeID(byte[] duplicateID, long id) { if (id != 0) { return ByteUtil.bytesToHex(duplicateID, 4) + ", simpleString=" + ByteUtil.toSimpleString(duplicateID); } else { return ByteUtil.bytesToHex(duplicateID, 4) + ", simpleString=" + ByteUtil.toSimpleString(duplicateID) + ", id=" + id; } }
/** * Returns {@code true} if the {@link SimpleString} encoded content into {@code bytes} is equals to {@code s}, * {@code false} otherwise. * <p> * It assumes that the {@code bytes} content is read using {@link SimpleString#readSimpleString(ByteBuf, int)} ie starting right after the * length field. */ public static boolean equals(final byte[] bytes, final ByteBuf byteBuf, final int offset, final int length) { if (bytes.length != length) return false; if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { if ((offset + length) > byteBuf.writerIndex()) { throw new IndexOutOfBoundsException(); } if (byteBuf.hasArray()) { return equals(bytes, byteBuf.array(), byteBuf.arrayOffset() + offset, length); } else if (byteBuf.hasMemoryAddress()) { return equalsOffHeap(bytes, byteBuf.memoryAddress(), offset, length); } } return equalsOnHeap(bytes, byteBuf, offset, length); }
public static void debugFrame(Logger logger, String message, ByteBuf byteIn) { if (logger.isTraceEnabled()) { int location = byteIn.readerIndex(); // debugging byte[] frame = new byte[byteIn.writerIndex()]; byteIn.readBytes(frame); try { logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); } catch (Exception e) { logger.warn(e.getMessage(), e); } byteIn.readerIndex(location); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
@Override public boolean equals(final Object other) { if (this == other) { return true; } if (other instanceof SimpleString) { SimpleString s = (SimpleString) other; return ByteUtil.equals(data, s.data); } else { return false; } }
final byte[] body = ByteUtil.getActiveArray(qbuff.readBytes(bytesToRead).toByteBuffer());
sb.append("NULL-value"); } else if (theValue instanceof byte[]) { sb.append("[" + ByteUtil.maxString(ByteUtil.bytesToHex((byte[]) theValue, 2), 150) + ")");
public static boolean equals(final byte[] left, final byte[] right, final int rightOffset, final int rightLength) { if (left == right) return true; if (left == null || right == null) return false; if (left.length != rightLength) return false; if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { return equalsUnsafe(left, right, rightOffset, rightLength); } else { return equalsSafe(left, right, rightOffset, rightLength); } }
/** * Returns {@code true} if the {@link SimpleString} encoded content into {@code bytes} is equals to {@code s}, * {@code false} otherwise. * <p> * It assumes that the {@code bytes} content is read using {@link SimpleString#readSimpleString(ByteBuf, int)} ie starting right after the * length field. */ public static boolean equals(final byte[] bytes, final ByteBuf byteBuf, final int offset, final int length) { if (bytes.length != length) return false; if (PlatformDependent.isUnaligned() && PlatformDependent.hasUnsafe()) { if ((offset + length) > byteBuf.writerIndex()) { throw new IndexOutOfBoundsException(); } if (byteBuf.hasArray()) { return equals(bytes, byteBuf.array(), byteBuf.arrayOffset() + offset, length); } else if (byteBuf.hasMemoryAddress()) { return equalsOffHeap(bytes, byteBuf.memoryAddress(), offset, length); } } return equalsOnHeap(bytes, byteBuf, offset, length); }
public static void debugFrame(Logger logger, String message, ByteBuf byteIn) { if (logger.isTraceEnabled()) { int location = byteIn.readerIndex(); // debugging byte[] frame = new byte[byteIn.writerIndex()]; byteIn.readBytes(frame); try { logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); } catch (Exception e) { logger.warn(e.getMessage(), e); } byteIn.readerIndex(location); } }
@Override public String encode(String secret) throws Exception { char[] chars = secret.toCharArray(); byte[] salt = getSalt(); StringBuilder builder = new StringBuilder(); builder.append(iterations).append(SEPARATOR).append(ByteUtil.bytesToHex(salt)).append(SEPARATOR); PBEKeySpec spec = new PBEKeySpec(chars, salt, iterations, keyLength); byte[] hash = skf.generateSecret(spec).getEncoded(); String hexValue = ByteUtil.bytesToHex(hash); builder.append(hexValue); return builder.toString(); }
/** * from {@link java.io.DataInput} interface */ @Override public String readLine() throws IOException { return ByteUtil.readLine(this); }