Class UsAsciiUtil


  • public class UsAsciiUtil
    extends java.lang.Object
    Utility methods to help in US-ASCII testing.
    Author:
    Daniel Sagenschneider
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.nio.charset.Charset US_ASCII
      US-ASCII Charset.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertEquals​(java.lang.String expected, byte[] actual)
      Asserts the US-ASCII content matches the expected String.
      static void assertEquals​(java.lang.String message, java.lang.String expected, byte[] actual)
      Asserts the US-ASCII content matches the expected String.
      static char convertToChar​(byte asciiChar)
      Converts the input US-ASCII character to a char.
      static byte[] convertToHttp​(byte[] ascii)
      Ensures that CR characters are followed by a LF.
      static byte[] convertToHttp​(java.lang.String text)
      Convenience method to convert to US-ASCII and HTTP form.
      static java.lang.String convertToString​(byte[] ascii)
      Converts the input US-ASCII to String.
      static byte convertToUsAscii​(char character)
      Converts the input character into US-ASCII character.
      static byte[] convertToUsAscii​(java.lang.String text)
      Converts the input text into US-ASCII format.
      • Methods inherited from class java.lang.Object

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

      • US_ASCII

        public static final java.nio.charset.Charset US_ASCII
        US-ASCII Charset.
    • Method Detail

      • assertEquals

        public static void assertEquals​(java.lang.String message,
                                        java.lang.String expected,
                                        byte[] actual)
        Asserts the US-ASCII content matches the expected String.
        Parameters:
        message - Message.
        expected - Expected text.
        actual - Actual US-ASCII text.
      • assertEquals

        public static void assertEquals​(java.lang.String expected,
                                        byte[] actual)
        Asserts the US-ASCII content matches the expected String.
        Parameters:
        expected - Expected text.
        actual - Actual US-ASCII text.
      • convertToUsAscii

        public static byte[] convertToUsAscii​(java.lang.String text)
        Converts the input text into US-ASCII format.
        Parameters:
        text - Text.
        Returns:
        Text in US-ASCII format.
      • convertToHttp

        public static byte[] convertToHttp​(java.lang.String text)
        Convenience method to convert to US-ASCII and HTTP form.
        Parameters:
        text - Text.
        Returns:
        HTTP.
      • convertToHttp

        public static byte[] convertToHttp​(byte[] ascii)
        Ensures that CR characters are followed by a LF.
        Parameters:
        ascii - Ascii content.
        Returns:
        HTTP.
      • convertToString

        public static java.lang.String convertToString​(byte[] ascii)
        Converts the input US-ASCII to String.
        Parameters:
        ascii - US-ASCII.
        Returns:
        US-ASCII characters as a String.
      • convertToChar

        public static char convertToChar​(byte asciiChar)
        Converts the input US-ASCII character to a char.
        Parameters:
        asciiChar - US-ASCII character.
        Returns:
        char.
      • convertToUsAscii

        public static byte convertToUsAscii​(char character)
        Converts the input character into US-ASCII character.
        Parameters:
        character - Character.
        Returns:
        US-ASCII character.