Package com.linkedin.alpini.base.misc
Enum HeaderUtils
- java.lang.Object
-
- java.lang.Enum<HeaderUtils>
-
- com.linkedin.alpini.base.misc.HeaderUtils
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<HeaderUtils>
public enum HeaderUtils extends java.lang.Enum<HeaderUtils>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HeaderUtils.ContentType
-
Enum Constant Summary
Enum Constants Enum Constant Description SINGLETON
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
HTTP_DATE_FORMAT
static java.lang.String
HTTP_DATE_GMT_TIMEZONE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringBuilder
appendHex(java.lang.StringBuilder sb, int c)
static java.lang.String
buildContentType(java.lang.String type, java.lang.String subType, java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> parameters)
static java.lang.String
buildContentType(java.lang.String type, java.lang.String subType, java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> parameters)
static java.lang.CharSequence
cleanHeaderValue(java.lang.CharSequence value)
Checks to ensure that a provided header value may be used as-is or returns a new string which has been appropiately filtered.static java.lang.CharSequence
cleanStatusMessage(java.lang.CharSequence value)
Cleans the status message and if no cleanup is required, returns the same String object.static java.lang.StringBuilder
escapeDelimiters(java.lang.StringBuilder buffer, java.lang.CharSequence text)
static java.lang.String
formatDate(java.util.Date date)
static boolean
isProhibitedCharacter(int c)
Check if the character is prohibited in a HTTP header value.static boolean
isQuotableParam(java.lang.String value)
From RFC1341, a quoted value may contain any character except control characters or '"'.static java.util.UUID
nameUUIDFromBytes(byte[] name)
Static factory to retrieve a type 4 (pseudo-random)UUID
based on the specified byte array after transformation with the Jenkins hash function.static HeaderUtils.ContentType
parseContentType(java.lang.String contentType)
static java.util.UUID
randomWeakUUID()
Static factory to retrieve a type 4 (pseudo randomly generated) UUID.static java.lang.CharSequence
sanitizeHeaderValue(java.lang.CharSequence value)
Builds a new String, filtering out values and performing fixup to provide a value which may be set as a HTTP header value.static java.lang.CharSequence
sanitizeStatusMessage(java.lang.CharSequence value)
Builds a new String, filtering out non-ASCII characters which are likely to cause problems.static HeaderUtils
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static HeaderUtils[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SINGLETON
public static final HeaderUtils SINGLETON
-
-
Field Detail
-
HTTP_DATE_FORMAT
public static final java.lang.String HTTP_DATE_FORMAT
- See Also:
- Constant Field Values
-
HTTP_DATE_GMT_TIMEZONE
public static final java.lang.String HTTP_DATE_GMT_TIMEZONE
- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static HeaderUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HeaderUtils c : HeaderUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HeaderUtils valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
isQuotableParam
public static boolean isQuotableParam(java.lang.String value)
From RFC1341, a quoted value may contain any character except control characters or '"'.
-
buildContentType
public static java.lang.String buildContentType(java.lang.String type, java.lang.String subType, java.util.Collection<java.util.Map.Entry<java.lang.String,java.lang.String>> parameters)
-
buildContentType
public static java.lang.String buildContentType(java.lang.String type, java.lang.String subType, java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> parameters)
-
parseContentType
public static HeaderUtils.ContentType parseContentType(java.lang.String contentType)
-
formatDate
public static java.lang.String formatDate(java.util.Date date)
-
sanitizeStatusMessage
@Nonnull public static java.lang.CharSequence sanitizeStatusMessage(@Nonnull java.lang.CharSequence value)
Builds a new String, filtering out non-ASCII characters which are likely to cause problems.- Parameters:
value
- Status message.- Returns:
- filtered message.
-
cleanStatusMessage
@Nonnull public static java.lang.CharSequence cleanStatusMessage(java.lang.CharSequence value)
Cleans the status message and if no cleanup is required, returns the same String object.- Parameters:
value
- Status message.- Returns:
- filtered message.
-
isProhibitedCharacter
public static boolean isProhibitedCharacter(int c)
Check if the character is prohibited in a HTTP header value.
-
appendHex
@Nonnull public static java.lang.StringBuilder appendHex(@Nonnull java.lang.StringBuilder sb, int c)
-
sanitizeHeaderValue
@Nonnull public static java.lang.CharSequence sanitizeHeaderValue(@Nonnull java.lang.CharSequence value)
Builds a new String, filtering out values and performing fixup to provide a value which may be set as a HTTP header value. The implementation of this method is based upon the value validation code in Netty 3.7.1- Parameters:
value
- header value.- Returns:
- filtered value.
-
cleanHeaderValue
@Nonnull public static java.lang.CharSequence cleanHeaderValue(java.lang.CharSequence value)
Checks to ensure that a provided header value may be used as-is or returns a new string which has been appropiately filtered. The implementation of this method is based upon the value validation code in Netty 3.7.1- Parameters:
value
- header value.- Returns:
- filtered value.
-
escapeDelimiters
public static java.lang.StringBuilder escapeDelimiters(java.lang.StringBuilder buffer, java.lang.CharSequence text)
-
randomWeakUUID
public static java.util.UUID randomWeakUUID()
Static factory to retrieve a type 4 (pseudo randomly generated) UUID. TheUUID
is generated using a cryptographically weak pseudo random number generator - theThreadLocalRandom
generator.- Returns:
- A randomly generated
UUID
-
nameUUIDFromBytes
public static java.util.UUID nameUUIDFromBytes(byte[] name)
Static factory to retrieve a type 4 (pseudo-random)UUID
based on the specified byte array after transformation with the Jenkins hash function.- Parameters:
name
- A byte array to be used to construct aUUID
- Returns:
- A
UUID
generated from the specified array
-
-