Class StreamBufferByteSequence

  • All Implemented Interfaces:
    java.lang.CharSequence, ByteSequence

    public class StreamBufferByteSequence
    extends java.lang.Object
    implements ByteSequence, java.lang.CharSequence
    ByteSequence reading from StreamBuffer instances.
    Author:
    Daniel Sagenschneider
    • Field Summary

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendStreamBuffer​(StreamBuffer<java.nio.ByteBuffer> buffer, int offset, int length)
      Appends a StreamBuffer to this ByteSequence.
      byte byteAt​(int index)
      Obtains the byte at the index.
      char charAt​(int index)  
      <T extends java.lang.Throwable>
      StreamBufferByteSequence
      decodeUri​(java.util.function.Function<java.lang.String,​T> invalidDecodeExceptionFactory)
      Decodes the URI.
      java.lang.CharSequence getHttpCharSequence()
      Obtains this ByteSequence as a CharSequence for HTTP Character values.
      int length()
      Obtains the number of byte values in the ByteSequence.
      <T extends java.lang.Throwable>
      StreamBufferByteSequence
      removeQuotes​(java.util.function.Supplier<T> invalidValueExceptionFactory)
      Removes surrounding HTTP quotes.
      static void setMaxByteLength​(int length)
      Specifies the maximum byte length of any ByteSequence.
      java.lang.CharSequence subSequence​(int start, int end)  
      java.lang.String toHttpString()
      Obtains this ByteSequence decoded to a HTTP String.
      <T extends java.lang.Throwable>
      long
      toLong​(java.util.function.Function<java.lang.Character,​T> invalidDigitExceptionFactory)
      Obtains this ByteSequence as a long value.
      <T extends java.lang.Throwable>
      java.lang.String
      toString​(java.nio.charset.Charset charset, java.util.function.Function<java.nio.charset.CoderResult,​T> invalidValueExceptionFactory)
      Obtains this ByteSequence as a String for the particular Charset.
      <T extends java.lang.Throwable>
      java.lang.String
      toUriString​(java.util.function.Function<java.nio.charset.CoderResult,​T> invalidValueExceptionFactory)
      Obtains this ByteSequence decoded to a URI String.
      StreamBufferByteSequence trim()
      Trims this ByteSequence of outer HTTP spaces and tabs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints, toString
    • Method Detail

      • setMaxByteLength

        public static void setMaxByteLength​(int length)
        Specifies the maximum byte length of any ByteSequence.
        Parameters:
        length - Maximum byte length of any ByteSequence.
      • removeQuotes

        public <T extends java.lang.Throwable> StreamBufferByteSequence removeQuotes​(java.util.function.Supplier<T> invalidValueExceptionFactory)
                                                                              throws T extends java.lang.Throwable
        Removes surrounding HTTP quotes.
        Type Parameters:
        T - Invalid value Exception type.
        Parameters:
        invalidValueExceptionFactory - Supplier of the invalid value Exception.
        Returns:
        this.
        Throws:
        T - Invalid value Exception.
        T extends java.lang.Throwable
      • getHttpCharSequence

        public java.lang.CharSequence getHttpCharSequence()

        Obtains this ByteSequence as a CharSequence for HTTP Character values.

        This is for use with NonMaterialisedHttpHeader comparing on the name.

        Returns:
        CharSequence for HTTP Character values of this ByteSequence.
      • toHttpString

        public java.lang.String toHttpString()
        Obtains this ByteSequence decoded to a HTTP String.
        Returns:
        ByteSequence decoded to a HTTP String.
      • decodeUri

        public <T extends java.lang.Throwable> StreamBufferByteSequence decodeUri​(java.util.function.Function<java.lang.String,​T> invalidDecodeExceptionFactory)
                                                                           throws T extends java.lang.Throwable
        Decodes the URI.
        Type Parameters:
        T - Invalid decode Exception type.
        Parameters:
        invalidDecodeExceptionFactory - Function to create an invalid encoding Throwable.
        Returns:
        this.
        Throws:
        T - If invalid encoding.
        T extends java.lang.Throwable
      • toUriString

        public <T extends java.lang.Throwable> java.lang.String toUriString​(java.util.function.Function<java.nio.charset.CoderResult,​T> invalidValueExceptionFactory)
                                                                     throws T extends java.lang.Throwable
        Obtains this ByteSequence decoded to a URI String.
        Type Parameters:
        T - Invalid value Exception type.
        Parameters:
        invalidValueExceptionFactory - Factory to create the Exception should the ByteSequence not be valid for the URI.
        Returns:
        ByteSequence decoded to a URI String.
        Throws:
        T - If invalid ByteSequence for the URI.
        T extends java.lang.Throwable
      • toString

        public <T extends java.lang.Throwable> java.lang.String toString​(java.nio.charset.Charset charset,
                                                                         java.util.function.Function<java.nio.charset.CoderResult,​T> invalidValueExceptionFactory)
                                                                  throws T extends java.lang.Throwable
        Obtains this ByteSequence as a String for the particular Charset.
        Type Parameters:
        T - Invalid value Exception type.
        Parameters:
        charset - Charset for the decoding the StreamBuffer data.
        invalidValueExceptionFactory - Factory to create the Exception should the ByteSequence not be valid for the Charset.
        Returns:
        String value for the StreamBuffer values.
        Throws:
        T - If invalid ByteSequence for Charset.
        T extends java.lang.Throwable
      • toLong

        public <T extends java.lang.Throwable> long toLong​(java.util.function.Function<java.lang.Character,​T> invalidDigitExceptionFactory)
                                                    throws T extends java.lang.Throwable
        Obtains this ByteSequence as a long value.
        Type Parameters:
        T - Invalid digit Exception type.
        Parameters:
        invalidDigitExceptionFactory - Function to create an Throwable should there be an invalid HTTP digit.
        Returns:
        long value.
        Throws:
        T - If invalid value to convert to long.
        T extends java.lang.Throwable
      • byteAt

        public byte byteAt​(int index)
        Description copied from interface: ByteSequence
        Obtains the byte at the index.
        Specified by:
        byteAt in interface ByteSequence
        Parameters:
        index - Index of the byte.
        Returns:
        byte at the index.
      • length

        public int length()
        Description copied from interface: ByteSequence
        Obtains the number of byte values in the ByteSequence.
        Specified by:
        length in interface ByteSequence
        Specified by:
        length in interface java.lang.CharSequence
        Returns:
        Number of byte values in the ByteSequence.
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Specified by:
        subSequence in interface java.lang.CharSequence