Package com.helger.http
Class RFC1945Helper
java.lang.Object
com.helger.http.RFC1945Helper
HTTP string helper. Based on RFC 1945 (HTTP/1.0) http://tools.ietf.org/html/rfc1945
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final charComment start characterstatic final charComment end characterstatic final intMaximum index (inclusive)static final intMinimum index (inclusive)static final charQuoted text start characterstatic final charQuoted text end character -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringgetQuotedTextString(@Nullable String sStr) Wrap the passed string in double-quote characters to form a quoted-text value.static booleanisAlphaChar(int n) Check if the passed value is an alpha character (A-Z or a-z).static booleanisChar(int n) Check if the passed value is a valid CHAR as defined in RFC 1945.static booleanisComment(char @Nullable [] aChars) Check if the passed character array represents a valid comment as defined in RFC 1945.static booleanCheck if the passed string represents a valid comment as defined in RFC 1945.static booleanisCommentChar(int n) Check if the passed value is a valid comment character as defined in RFC 1945.static booleanisControlChar(int n) Check if the passed value is a control character (CTL).static booleanisCRChar(int n) Check if the passed value is a carriage return character (CR).static booleanisDigitChar(int n) Check if the passed value is a digit character (0-9).static booleanisExtraChar(int n) Check if the passed value is an extra character as defined in RFC 1945.static booleanisHexChar(int n) Check if the passed value is a hexadecimal character (0-9, A-F, a-f).static booleanisHexNotEmpty(char @Nullable [] aChars) Check if the passed character array is non-empty and consists only of hex characters.static booleanisHexNotEmpty(@Nullable String sStr) Check if the passed string is non-empty and consists only of hex characters.static booleanisLFChar(int n) Check if the passed value is a line feed character (LF).static booleanisLinearWhitespaceChar(int n) Check if the passed value is a linear whitespace character (LWS), which includes CR, LF, SP and HT.static booleanisLowerAlphaChar(int n) Check if the passed value is a lower-case alpha character (a-z).static booleanisLowerHexChar(int n) Check if the passed value is a lower-case hexadecimal character (0-9, a-f).static booleanisLowerHexNotEmpty(char @Nullable [] aChars) Check if the passed character array is non-empty and consists only of lower-case hex characters.static booleanisLowerHexNotEmpty(@Nullable String sStr) Check if the passed string is non-empty and consists only of lower-case hex characters.static booleanisNationalChar(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).static booleanisNonTokenChar(int n) Check if the passed value is a non-token character (separator).static booleanisOctet(int n) Check if the passed value is a valid OCTET as defined in RFC 1945.static booleanisQuoteChar(int n) Check if the passed value is a double-quote character.static booleanisQuotedText(char @Nullable [] aChars) Check if the passed character array represents a valid quoted-text as defined in RFC 1945.static booleanisQuotedText(@Nullable String sStr) Check if the passed string represents a valid quoted-text as defined in RFC 1945.static booleanisQuotedTextChar(int n) Check if the passed value is a valid quoted-text character as defined in RFC 1945.static booleanisQuotedTextContent(char @Nullable [] aChars) Check if the passed character array consists only of valid quoted-text content characters (without the enclosing double-quotes).static booleanisQuotedTextContent(@Nullable String sStr) Check if the passed string consists only of valid quoted-text content characters (without the enclosing double-quotes).static booleanisReservedChar(int n) Check if the passed value is a reserved character as defined in RFC 1945.static booleanisSafeChar(int n) Check if the passed value is a safe character as defined in RFC 1945.static booleanisSpaceChar(int n) Check if the passed value is a space character (SP).static booleanisTabChar(int n) Check if the passed value is a horizontal tab character (HT).static booleanisTextChar(int n) Check if the passed value is a valid TEXT character as defined in RFC 1945.static booleanisToken(char @Nullable [] aChars) Check if the passed character array represents a valid token as defined in RFC 1945.static booleanCheck if the passed string represents a valid token as defined in RFC 1945.static booleanisTokenChar(int n) Check if the passed value is a valid token character as defined in RFC 1945.static booleanisUnreservedChar(int n) Check if the passed value is an unreserved character as defined in RFC 1945 (ALPHA, DIGIT, safe, extra, or national).static booleanisUnsafeChar(int n) Check if the passed value is an unsafe character as defined in RFC 1945.static booleanisUpperAlphaChar(int n) Check if the passed value is an upper-case alpha character (A-Z).static booleanisWord(char @Nullable [] aChars) Check if the passed character array is a valid word (either a token or a quoted-text).static booleanCheck if the passed string is a valid word (either a token or a quoted-text).
-
Field Details
-
MIN_INDEX
public static final int MIN_INDEXMinimum index (inclusive)- See Also:
-
MAX_INDEX
public static final int MAX_INDEXMaximum index (inclusive)- See Also:
-
COMMENT_BEGIN
public static final char COMMENT_BEGINComment start character- See Also:
-
COMMENT_END
public static final char COMMENT_ENDComment end character- See Also:
-
QUOTEDTEXT_BEGIN
public static final char QUOTEDTEXT_BEGINQuoted text start character- See Also:
-
QUOTEDTEXT_END
public static final char QUOTEDTEXT_ENDQuoted text end character- See Also:
-
CHAR_TAB
public static final int CHAR_TAB- See Also:
-
CHAR_LF
public static final int CHAR_LF- See Also:
-
CHAR_CR
public static final int CHAR_CR- See Also:
-
CHAR_SPACE
public static final int CHAR_SPACE- See Also:
-
-
Method Details
-
isChar
public static boolean isChar(int n) Check if the passed value is a valid CHAR as defined in RFC 1945. -
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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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 benull.- Returns:
trueif the array is non-empty and all characters are hex characters.
-
isHexNotEmpty
Check if the passed string is non-empty and consists only of hex characters.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif 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:
trueif 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 benull.- Returns:
trueif the array is non-empty and all characters are lower-case hex characters.
-
isLowerHexNotEmpty
Check if the passed string is non-empty and consists only of lower-case hex characters.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif 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:
trueif 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:
trueif 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 benull.- Returns:
trueif the array is non-empty and all characters are valid token characters.
-
isToken
Check if the passed string represents a valid token as defined in RFC 1945.- Parameters:
sStr- The string to check. May benull.- Returns:
trueif 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:
trueif 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:
trueif 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 benull.- Returns:
trueif the array represents a valid comment.
-
isComment
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 benull.- Returns:
trueif 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:
trueif 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 benull.- Returns:
trueif the array represents a valid quoted-text.
-
isQuotedText
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 benull.- Returns:
trueif the string represents a valid quoted-text.
-
getQuotedTextString
Wrap the passed string in double-quote characters to form a quoted-text value.- Parameters:
sStr- The string to quote. May benull.- Returns:
- The quoted string or
nullif the input wasnull.
-
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 benull.- Returns:
trueif all characters are valid quoted-text content characters.
-
isQuotedTextContent
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 benull.- Returns:
trueif 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 benull.- Returns:
trueif the array is a valid word.
-
isWord
Check if the passed string is a valid word (either a token or a quoted-text).- Parameters:
sStr- The string to check. May benull.- Returns:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif the value is an unreserved character.
-