Example usage for io.netty.util.internal StringUtil toHexString

List of usage examples for io.netty.util.internal StringUtil toHexString

Introduction

In this page you can find the example usage for io.netty.util.internal StringUtil toHexString.

Prototype

public static String toHexString(byte[] src) 

Source Link

Document

Converts the specified byte array into a hexadecimal value.

Usage

From source file:io.vertx.ext.shell.command.base.BusTail.java

License:Open Source License

@Override
public void process(CommandProcess process) {
    EventBus eb = process.vertx().eventBus();
    List<MessageConsumer<Object>> consumers = addresses.stream().map(address -> {
        Handler<Message<Object>> handler = msg -> {
            Object body = msg.body();
            String bodyString;/*from w  w  w.ja v a  2  s  . c  om*/
            if (body instanceof Buffer) {
                bodyString = StringUtil.toHexString(((Buffer) body).getBytes());
            } else {
                bodyString = String.valueOf(body);
            }
            if (verbose) {
                process.write(address + ":" + "\n");
                process.write("Reply address: " + msg.replyAddress() + "\n");
                MultiMap headers = msg.headers();
                for (String header : headers.names()) {
                    process.write("Header " + header + ":" + headers.getAll(header) + "\n");
                }
                process.write(bodyString + "\n");
            } else {
                process.write(address + ":" + bodyString + "\n");
            }
        };
        return local ? eb.localConsumer(address, handler) : eb.consumer(address, handler);
    }).collect(Collectors.toList());
    process.interruptHandler(done -> {
        process.end();
    });
    process.endHandler(done -> {
        consumers.forEach(MessageConsumer::unregister);
    });
}