Class HttpCodecUtils


  • public class HttpCodecUtils
    extends java.lang.Object
    General HttpCodec utility methods.
    Author:
    Alexey Stashok
    • Constructor Detail

      • HttpCodecUtils

        public HttpCodecUtils()
    • Method Detail

      • findSpace

        public static int findSpace​(Buffer input,
                                    int offset,
                                    int packetLimit)
      • findSpace

        public static int findSpace​(byte[] input,
                                    int offset,
                                    int end,
                                    int packetLimit)
      • skipSpaces

        public static int skipSpaces​(Buffer input,
                                     int offset,
                                     int packetLimit)
      • skipSpaces

        public static int skipSpaces​(byte[] input,
                                     int offset,
                                     int end,
                                     int packetLimit)
      • indexOf

        public static int indexOf​(Buffer input,
                                  int offset,
                                  byte b,
                                  int packetLimit)
      • getLongAsBuffer

        public static Buffer getLongAsBuffer​(MemoryManager memoryManager,
                                             long length)
      • put

        public static Buffer put​(MemoryManager memoryManager,
                                 Buffer dstBuffer,
                                 byte[] tempBuffer,
                                 java.lang.String s)
      • isNotSpaceAndTab

        public static boolean isNotSpaceAndTab​(byte b)
      • isSpaceOrTab

        public static boolean isSpaceOrTab​(byte b)
      • toCheckedByteArray

        public static byte[] toCheckedByteArray​(java.lang.CharSequence s)
        Converts the a CharSequence to a byte array, eliminating all the unprintable US-ASCII symbols by replacing them with spaces (' ').
        Parameters:
        s - CharSequence
        Returns:
        a converted byte array, where all the char sequence's unprintable US-ASCII symbols have been replaced with spaces (' ')
      • toCheckedByteArray

        public static byte[] toCheckedByteArray​(java.lang.CharSequence s,
                                                byte[] dstArray,
                                                int arrayOffs)
        Serializes the passed CharSequence into a passed byte array starting from a given offset. All the unprintable US-ASCII symbols will be replaced with spaces (' ').
        Parameters:
        s - CharSequence
        dstArray - the byte array to be used to convert the CharSequence into
        arrayOffs - the offset in the byte array, where the serialization will be started
        Returns:
        the passed dstArray
        Throws:
        java.lang.IllegalArgumentException - if there is no enough space in the dstArray to serialize the CharSequence
      • isNonPrintableUsAscii

        public static boolean isNonPrintableUsAscii​(int ub)
        Returns true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE].
        Parameters:
        ub - the symbol code to check
        Returns:
        true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE]