Class ByteToTextEncoding.IdFormatter

  • All Implemented Interfaces:
    ByteToTextEncoding
    Enclosing interface:
    ByteToTextEncoding

    public static final class ByteToTextEncoding.IdFormatter
    extends Object
    implements ByteToTextEncoding
    ID formatting decorator. Wrap an existing ByteToTextEncoding instance to add simple formatting capabilities.

    A call can set the interval and separator. An id will be formatted similar to:

         xxxx-yyyyyy-xxxx-yyyyyy-xx
     

    where - is the separator and the interval is 4. Note that every other id part will have length interval+2 to improve readability.

    • Method Detail

      • wrap

        public static ByteToTextEncoding.IdFormatter wrap​(ByteToTextEncoding byteToTextEncoding)
        Create new formatter instance with default separator and interval.
        Parameters:
        byteToTextEncoding - to wrap
        Returns:
        formatted byteToTextEncoding
      • wrap

        public static ByteToTextEncoding.IdFormatter wrap​(ByteToTextEncoding byteToTextEncoding,
                                                          int interval)
        Create new formatter instance.
        Parameters:
        byteToTextEncoding - to wrap
        interval - of the single parts of the id. E.g. 4 looks like this: xxxx-yyyyyy-xxxxx-...
        Returns:
        formatted byteToTextEncoding
      • wrap

        public static ByteToTextEncoding.IdFormatter wrap​(ByteToTextEncoding byteToTextEncoding,
                                                          int interval,
                                                          String separator)
        Create new formatter instance.
        Parameters:
        byteToTextEncoding - to wrap
        interval - of the single parts of the id. E.g. 4 looks like this: xxxx-yyyyyy-xxxxx-...
        separator - between the id parts; be aware not to use a character used in the encoding alphabet
        Returns:
        formatted byteToTextEncoding
      • encode

        public String encode​(byte[] bytes)
        Description copied from interface: ByteToTextEncoding
        Encode given byte array to printable text
        Specified by:
        encode in interface ByteToTextEncoding
        Parameters:
        bytes - to mask
        Returns:
        printable text