org.apache.directory.mavibot.btree.util

## Class Strings

- java.lang.Object
- - org.apache.directory.mavibot.btree.util.Strings

-     public final class Strings
      extends Object

  Various string manipulation methods that are more efficient then chaining string operations: all is done in the same buffer without creating a bunch of string objects.
  Author:
    Apache Directory Project

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static byte[]` | `EMPTY_BYTES` A empty byte array

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Strings()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `dumpByte(byte octet)` Helper function that dump a byte in hex form
    `static String` | `dumpBytes(byte[] buffer)` Helper function that dump an array of bytes in hex form
    `static char` | `dumpHex(byte hex)` Helper function that returns a char from an hex
    `static String` | `dumpHexPairs(byte[] buffer)` Helper function that dump an array of bytes in hex pair form, without '0x' and space chars
    `static byte[]` | `getBytesUtf8(String string)` Return UTF-8 encoded byte[] representation of a String
    `static byte[]` | `getBytesUtf8Ascii(String string)` When the string to convert to bytes is pure ascii, this is a faster method than the getBytesUtf8.
    `static boolean` | `isEmpty(byte[] bytes)` Checks if a bytes array is empty or null.
    `static boolean` | `isEmpty(String str)` Checks if a String is empty ("") or null.
    `static String` | `listToString(List<?> list)` Utility method that return a String representation of a list
    `static String` | `listToString(List<?> list, String tabs)` Utility method that return a String representation of a list
    `static String` | `mapToString(Map<?,?> map)` Utility method that return a String representation of a map.
    `static String` | `mapToString(Map<?,?> map, String tabs)` Utility method that return a String representation of a map.
    `static String` | `setToString(Set<?> set)` Utility method that return a String representation of a set
    `static byte[]` | `toByteArray(String hexString)` Get byte array from hex string
    `static String` | `toHexString(byte[] res)` Gets a hex string from byte array.
    `static String` | `utf8ToString(byte[] bytes)` Return an UTF-8 encoded String
    `static String` | `utf8ToString(byte[] bytes, int length)` Return an UTF-8 encoded String
    `static String` | `utf8ToString(byte[] bytes, int start, int length)` Return an UTF-8 encoded String
    `static String` | `utf8ToString(ByteBuffer bytes)` Return an UTF-8 encoded String

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### EMPTY_BYTES

          public static final byte[] EMPTY_BYTES

      A empty byte array

  - ### Constructor Detail

    - #### Strings

          public Strings()

  - ### Method Detail

    - #### dumpBytes

          public static String dumpBytes(byte[] buffer)

      Helper function that dump an array of bytes in hex form
      Parameters:
        `buffer` - The bytes array to dump
      Returns:
        A string representation of the array of bytes

    - #### dumpByte

          public static String dumpByte(byte octet)

      Helper function that dump a byte in hex form
      Parameters:
        `octet` - The byte to dump
      Returns:
        A string representation of the byte

    - #### dumpHex

          public static char dumpHex(byte hex)

      Helper function that returns a char from an hex
      Parameters:
        `hex` - The hex to dump
      Returns:
        A char representation of the hex

    - #### dumpHexPairs

          public static String dumpHexPairs(byte[] buffer)

      Helper function that dump an array of bytes in hex pair form, without '0x' and space chars
      Parameters:
        `buffer` - The bytes array to dump
      Returns:
        A string representation of the array of bytes

    - #### toHexString

          public static String toHexString(byte[] res)

      Gets a hex string from byte array.
      Parameters:
        `res` - the byte array
      Returns:
        the hex string representing the binary values in the array

    - #### toByteArray

          public static byte[] toByteArray(String hexString)

      Get byte array from hex string
      Parameters:
        `hexString` - the hex string to convert to a byte array
      Returns:
        the byte form of the hex string.

    - #### utf8ToString

          public static String utf8ToString(byte[] bytes)

      Return an UTF-8 encoded String
      Parameters:
        `bytes` - The byte array to be transformed to a String
      Returns:
        A String.

    - #### utf8ToString

          public static String utf8ToString(ByteBuffer bytes)

      Return an UTF-8 encoded String
      Parameters:
        `bytes` - The byte array to be transformed to a String
      Returns:
        A String.

    - #### utf8ToString

          public static String utf8ToString(byte[] bytes,
                            int length)

      Return an UTF-8 encoded String
      Parameters:
        `bytes` - The byte array to be transformed to a String
        `length` - The length of the byte array to be converted
      Returns:
        A String.

    - #### utf8ToString

          public static String utf8ToString(byte[] bytes,
                            int start,
                            int length)

      Return an UTF-8 encoded String
      Parameters:
        `bytes` - The byte array to be transformed to a String
        `start` - the starting position in the byte array
        `length` - The length of the byte array to be converted
      Returns:
        A String.

    - #### isEmpty

          public static boolean isEmpty(String str)

      Checks if a String is empty ("") or null.

            StringUtils.isEmpty(null)      = true
            StringUtils.isEmpty("")        = true
            StringUtils.isEmpty(" ")       = false
            StringUtils.isEmpty("bob")     = false
            StringUtils.isEmpty("  bob  ") = false

      NOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().

      Parameters:
        `str` - the String to check, may be null
      Returns:
        `true` if the String is empty or null

    - #### isEmpty

          public static boolean isEmpty(byte[] bytes)

      Checks if a bytes array is empty or null.
      Parameters:
        `bytes` - The bytes array to check, may be null
      Returns:
        `true` if the bytes array is empty or null

    - #### getBytesUtf8

          public static byte[] getBytesUtf8(String string)

      Return UTF-8 encoded byte[] representation of a String
      Parameters:
        `string` - The string to be transformed to a byte array
      Returns:
        The transformed byte array

    - #### getBytesUtf8Ascii

          public static byte[] getBytesUtf8Ascii(String string)

      When the string to convert to bytes is pure ascii, this is a faster method than the getBytesUtf8. Otherwise, it's slower.
      Parameters:
        `string` - The string to convert to byte[]
      Returns:
        The bytes

    - #### listToString

          public static String listToString(List<?> list)

      Utility method that return a String representation of a list
      Parameters:
        `list` - The list to transform to a string
      Returns:
        A csv string

    - #### setToString

          public static String setToString(Set<?> set)

      Utility method that return a String representation of a set
      Parameters:
        `set` - The set to transform to a string
      Returns:
        A csv string

    - #### listToString

          public static String listToString(List<?> list,
                            String tabs)

      Utility method that return a String representation of a list
      Parameters:
        `list` - The list to transform to a string
        `tabs` - The tabs to add in ffront of the elements
      Returns:
        A csv string

    - #### mapToString

          public static String mapToString(Map<?,?> map)

      Utility method that return a String representation of a map. The elements will be represented as "key = value"
      Parameters:
        `map` - The map to transform to a string
      Returns:
        A csv string

    - #### mapToString

          public static String mapToString(Map<?,?> map,
                           String tabs)

      Utility method that return a String representation of a map. The elements will be represented as "key = value"
      Parameters:
        `map` - The map to transform to a string
        `tabs` - The tabs to add in ffront of the elements
      Returns:
        A csv string

Copyright © 2012–2015 Apache Mavibot Project Parent. All rights reserved.