Class Asn1StringUtils

java.lang.Object
org.apache.directory.api.asn1.util.Asn1StringUtils

public final class Asn1StringUtils extends Object
Little helper class for the asn1 package.
Author:
Apache Directory Project
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte[]
    The empty byte[]
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    Transform a string to an array of ASCII bytes, where the byte array will contain only values in [0, 127].
    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 String
    dumpBytes(byte[] buffer, int start, int length)
    Helper function that dump an array of bytes in hex form
    static byte[]
    Return UTF-8 encoded byte[] representation of a String

    Methods inherited from class Object

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

    • EMPTY_BYTES

      public static final byte[] EMPTY_BYTES
      The empty byte[]
  • Method Details

    • 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
    • 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
    • dumpBytes

      public static String dumpBytes(byte[] buffer, int start, int length)
      Helper function that dump an array of bytes in hex form
      Parameters:
      buffer - The bytes array to dump
      start - The starting point in the buffer
      length - The number of bytes to print
      Returns:
      A string representation of the array of bytes
    • 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
    • asciiStringToByte

      public static byte[] asciiStringToByte(String string)
      Transform a string to an array of ASCII bytes, where the byte array will contain only values in [0, 127].
      Parameters:
      string - The byte array to transform
      Returns:
      The resulting string