Class RFC1945Helper

java.lang.Object
com.helger.http.RFC1945Helper

@Immutable public final class RFC1945Helper extends Object
HTTP string helper. Based on RFC 1945 (HTTP/1.0) http://tools.ietf.org/html/rfc1945
Author:
Philip Helger
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final char
    Comment start character
    static final char
    Comment end character
    static final int
    Maximum index (inclusive)
    static final int
    Minimum index (inclusive)
    static final char
    Quoted text start character
    static final char
    Quoted text end character
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable String
    getQuotedTextString(@Nullable String sStr)
    Wrap the passed string in double-quote characters to form a quoted-text value.
    static boolean
    isAlphaChar(int n)
    Check if the passed value is an alpha character (A-Z or a-z).
    static boolean
    isChar(int n)
    Check if the passed value is a valid CHAR as defined in RFC 1945.
    static boolean
    isComment(char @Nullable [] aChars)
    Check if the passed character array represents a valid comment as defined in RFC 1945.
    static boolean
    isComment(@Nullable String sStr)
    Check if the passed string represents a valid comment as defined in RFC 1945.
    static boolean
    Check if the passed value is a valid comment character as defined in RFC 1945.
    static boolean
    Check if the passed value is a control character (CTL).
    static boolean
    isCRChar(int n)
    Check if the passed value is a carriage return character (CR).
    static boolean
    isDigitChar(int n)
    Check if the passed value is a digit character (0-9).
    static boolean
    isExtraChar(int n)
    Check if the passed value is an extra character as defined in RFC 1945.
    static boolean
    isHexChar(int n)
    Check if the passed value is a hexadecimal character (0-9, A-F, a-f).
    static boolean
    isHexNotEmpty(char @Nullable [] aChars)
    Check if the passed character array is non-empty and consists only of hex characters.
    static boolean
    isHexNotEmpty(@Nullable String sStr)
    Check if the passed string is non-empty and consists only of hex characters.
    static boolean
    isLFChar(int n)
    Check if the passed value is a line feed character (LF).
    static boolean
    Check if the passed value is a linear whitespace character (LWS), which includes CR, LF, SP and HT.
    static boolean
    Check if the passed value is a lower-case alpha character (a-z).
    static boolean
    Check if the passed value is a lower-case hexadecimal character (0-9, a-f).
    static boolean
    isLowerHexNotEmpty(char @Nullable [] aChars)
    Check if the passed character array is non-empty and consists only of lower-case hex characters.
    static boolean
    isLowerHexNotEmpty(@Nullable String sStr)
    Check if the passed string is non-empty and consists only of lower-case hex characters.
    static boolean
    Check if the passed value is a national character as defined in RFC 1945 (any OCTET excluding ALPHA, DIGIT, reserved, extra, safe, and unsafe).
    static boolean
    Check if the passed value is a non-token character (separator).
    static boolean
    isOctet(int n)
    Check if the passed value is a valid OCTET as defined in RFC 1945.
    static boolean
    isQuoteChar(int n)
    Check if the passed value is a double-quote character.
    static boolean
    isQuotedText(char @Nullable [] aChars)
    Check if the passed character array represents a valid quoted-text as defined in RFC 1945.
    static boolean
    isQuotedText(@Nullable String sStr)
    Check if the passed string represents a valid quoted-text as defined in RFC 1945.
    static boolean
    Check if the passed value is a valid quoted-text character as defined in RFC 1945.
    static boolean
    isQuotedTextContent(char @Nullable [] aChars)
    Check if the passed character array consists only of valid quoted-text content characters (without the enclosing double-quotes).
    static boolean
    isQuotedTextContent(@Nullable String sStr)
    Check if the passed string consists only of valid quoted-text content characters (without the enclosing double-quotes).
    static boolean
    Check if the passed value is a reserved character as defined in RFC 1945.
    static boolean
    isSafeChar(int n)
    Check if the passed value is a safe character as defined in RFC 1945.
    static boolean
    isSpaceChar(int n)
    Check if the passed value is a space character (SP).
    static boolean
    isTabChar(int n)
    Check if the passed value is a horizontal tab character (HT).
    static boolean
    isTextChar(int n)
    Check if the passed value is a valid TEXT character as defined in RFC 1945.
    static boolean
    isToken(char @Nullable [] aChars)
    Check if the passed character array represents a valid token as defined in RFC 1945.
    static boolean
    isToken(@Nullable String sStr)
    Check if the passed string represents a valid token as defined in RFC 1945.
    static boolean
    isTokenChar(int n)
    Check if the passed value is a valid token character as defined in RFC 1945.
    static boolean
    Check if the passed value is an unreserved character as defined in RFC 1945 (ALPHA, DIGIT, safe, extra, or national).
    static boolean
    isUnsafeChar(int n)
    Check if the passed value is an unsafe character as defined in RFC 1945.
    static boolean
    Check if the passed value is an upper-case alpha character (A-Z).
    static boolean
    isWord(char @Nullable [] aChars)
    Check if the passed character array is a valid word (either a token or a quoted-text).
    static boolean
    isWord(@Nullable String sStr)
    Check if the passed string is a valid word (either a token or a quoted-text).

    Methods inherited from class java.lang.Object

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

  • Method Details

    • isChar

      public static boolean isChar(int n)
      Check if the passed value is a valid CHAR as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is in the range MIN_INDEX to MAX_INDEX.
    • isOctet

      public static boolean isOctet(int n)
      Check if the passed value is a valid OCTET as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is in the range 0 to 255.
    • isUpperAlphaChar

      public static boolean isUpperAlphaChar(int n)
      Check if the passed value is an upper-case alpha character (A-Z).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is an upper-case alpha character.
    • isLowerAlphaChar

      public static boolean isLowerAlphaChar(int n)
      Check if the passed value is a lower-case alpha character (a-z).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a lower-case alpha character.
    • isAlphaChar

      public static boolean isAlphaChar(int n)
      Check if the passed value is an alpha character (A-Z or a-z).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is an alpha character.
    • isDigitChar

      public static boolean isDigitChar(int n)
      Check if the passed value is a digit character (0-9).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a digit character.
    • isControlChar

      public static boolean isControlChar(int n)
      Check if the passed value is a control character (CTL).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a control character.
    • isCRChar

      public static boolean isCRChar(int n)
      Check if the passed value is a carriage return character (CR).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a CR character.
    • isLFChar

      public static boolean isLFChar(int n)
      Check if the passed value is a line feed character (LF).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a LF character.
    • isSpaceChar

      public static boolean isSpaceChar(int n)
      Check if the passed value is a space character (SP).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a space character.
    • isTabChar

      public static boolean isTabChar(int n)
      Check if the passed value is a horizontal tab character (HT).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a tab character.
    • isLinearWhitespaceChar

      public static boolean isLinearWhitespaceChar(int n)
      Check if the passed value is a linear whitespace character (LWS), which includes CR, LF, SP and HT.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a linear whitespace character.
    • isQuoteChar

      public static boolean isQuoteChar(int n)
      Check if the passed value is a double-quote character.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a double-quote character.
    • isHexChar

      public static boolean isHexChar(int n)
      Check if the passed value is a hexadecimal character (0-9, A-F, a-f).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a hex character.
    • isHexNotEmpty

      public static boolean isHexNotEmpty(char @Nullable [] aChars)
      Check if the passed character array is non-empty and consists only of hex characters.
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array is non-empty and all characters are hex characters.
    • isHexNotEmpty

      public static boolean isHexNotEmpty(@Nullable String sStr)
      Check if the passed string is non-empty and consists only of hex characters.
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string is non-empty and all characters are hex characters.
    • isLowerHexChar

      public static boolean isLowerHexChar(int n)
      Check if the passed value is a lower-case hexadecimal character (0-9, a-f).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a lower-case hex character.
    • isLowerHexNotEmpty

      public static boolean isLowerHexNotEmpty(char @Nullable [] aChars)
      Check if the passed character array is non-empty and consists only of lower-case hex characters.
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array is non-empty and all characters are lower-case hex characters.
    • isLowerHexNotEmpty

      public static boolean isLowerHexNotEmpty(@Nullable String sStr)
      Check if the passed string is non-empty and consists only of lower-case hex characters.
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string is non-empty and all characters are lower-case hex characters.
    • isNonTokenChar

      public static boolean isNonTokenChar(int n)
      Check if the passed value is a non-token character (separator).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a non-token character.
    • isTokenChar

      public static boolean isTokenChar(int n)
      Check if the passed value is a valid token character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a valid token character.
    • isToken

      public static boolean isToken(char @Nullable [] aChars)
      Check if the passed character array represents a valid token as defined in RFC 1945.
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array is non-empty and all characters are valid token characters.
    • isToken

      public static boolean isToken(@Nullable String sStr)
      Check if the passed string represents a valid token as defined in RFC 1945.
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string is non-empty and all characters are valid token characters.
    • isTextChar

      public static boolean isTextChar(int n)
      Check if the passed value is a valid TEXT character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a valid TEXT character.
    • isCommentChar

      public static boolean isCommentChar(int n)
      Check if the passed value is a valid comment character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a valid comment character.
    • isComment

      public static boolean isComment(char @Nullable [] aChars)
      Check if the passed character array represents a valid comment as defined in RFC 1945. A comment is enclosed in parentheses.
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array represents a valid comment.
    • isComment

      public static boolean isComment(@Nullable String sStr)
      Check if the passed string represents a valid comment as defined in RFC 1945. A comment is enclosed in parentheses.
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string represents a valid comment.
    • isQuotedTextChar

      public static boolean isQuotedTextChar(int n)
      Check if the passed value is a valid quoted-text character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a valid quoted-text character.
    • isQuotedText

      public static boolean isQuotedText(char @Nullable [] aChars)
      Check if the passed character array represents a valid quoted-text as defined in RFC 1945. Quoted text is enclosed in double-quote characters.
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array represents a valid quoted-text.
    • isQuotedText

      public static boolean isQuotedText(@Nullable String sStr)
      Check if the passed string represents a valid quoted-text as defined in RFC 1945. Quoted text is enclosed in double-quote characters.
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string represents a valid quoted-text.
    • getQuotedTextString

      public static @Nullable String getQuotedTextString(@Nullable String sStr)
      Wrap the passed string in double-quote characters to form a quoted-text value.
      Parameters:
      sStr - The string to quote. May be null.
      Returns:
      The quoted string or null if the input was null.
    • isQuotedTextContent

      public static boolean isQuotedTextContent(char @Nullable [] aChars)
      Check if the passed character array consists only of valid quoted-text content characters (without the enclosing double-quotes).
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if all characters are valid quoted-text content characters.
    • isQuotedTextContent

      public static boolean isQuotedTextContent(@Nullable String sStr)
      Check if the passed string consists only of valid quoted-text content characters (without the enclosing double-quotes).
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if all characters are valid quoted-text content characters.
    • isWord

      public static boolean isWord(char @Nullable [] aChars)
      Check if the passed character array is a valid word (either a token or a quoted-text).
      Parameters:
      aChars - The character array to check. May be null.
      Returns:
      true if the array is a valid word.
    • isWord

      public static boolean isWord(@Nullable String sStr)
      Check if the passed string is a valid word (either a token or a quoted-text).
      Parameters:
      sStr - The string to check. May be null.
      Returns:
      true if the string is a valid word.
    • isReservedChar

      public static boolean isReservedChar(int n)
      Check if the passed value is a reserved character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a reserved character.
    • isExtraChar

      public static boolean isExtraChar(int n)
      Check if the passed value is an extra character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is an extra character.
    • isSafeChar

      public static boolean isSafeChar(int n)
      Check if the passed value is a safe character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a safe character.
    • isUnsafeChar

      public static boolean isUnsafeChar(int n)
      Check if the passed value is an unsafe character as defined in RFC 1945.
      Parameters:
      n - The value to check.
      Returns:
      true if the value is an unsafe character.
    • isNationalChar

      public static boolean isNationalChar(int n)
      Check if the passed value is a national character as defined in RFC 1945 (any OCTET excluding ALPHA, DIGIT, reserved, extra, safe, and unsafe).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is a national character.
    • isUnreservedChar

      public static boolean isUnreservedChar(int n)
      Check if the passed value is an unreserved character as defined in RFC 1945 (ALPHA, DIGIT, safe, extra, or national).
      Parameters:
      n - The value to check.
      Returns:
      true if the value is an unreserved character.