Class ToStringUtils


  • public final class ToStringUtils
    extends java.lang.Object
    Helper methods to ease implementing Object.toString().
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static char[] HEX  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ToStringUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void byteArray​(java.lang.StringBuilder buffer, byte[] bytes)  
      static java.lang.String bytesRefToString​(byte[] b)  
      static java.lang.String bytesRefToString​(BytesRef b)
      Builds a String with both textual representation of the BytesRef data and the bytes hex values.
      static java.lang.String bytesRefToString​(BytesRefBuilder b)  
      static java.lang.String longHex​(long x)
      Unlike Long.toHexString(long) returns a String with a "0x" prefix and all the leading zeros.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HEX

        private static final char[] HEX
    • Constructor Detail

      • ToStringUtils

        private ToStringUtils()
    • Method Detail

      • byteArray

        public static void byteArray​(java.lang.StringBuilder buffer,
                                     byte[] bytes)
      • longHex

        public static java.lang.String longHex​(long x)
        Unlike Long.toHexString(long) returns a String with a "0x" prefix and all the leading zeros.
      • bytesRefToString

        public static java.lang.String bytesRefToString​(BytesRef b)
        Builds a String with both textual representation of the BytesRef data and the bytes hex values. For example: "hello [68 65 6c 6c 6f]". If the content is not a valid UTF-8 sequence, only the bytes hex values are returned, as per BytesRef.toString().
      • bytesRefToString

        public static java.lang.String bytesRefToString​(BytesRefBuilder b)
      • bytesRefToString

        public static java.lang.String bytesRefToString​(byte[] b)