Package com.helger.base.codec.impl
Class RFC2616Codec
java.lang.Object
com.helger.base.codec.impl.RFC2616Codec
- All Implemented Interfaces:
ICharArrayCodec,ICharArrayDecoder,ICharArrayEncoder,ICharArrayStreamDecoder,ICharArrayStreamEncoder,ICodec<char[]>,IDecoder<char[],,char[]> IEncoder<char[],char[]>
Codec for RFC 2616 (HTTP/1.1) HTTP header values.
- Since:
- 9.3.6
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDecode (part of) a char array.voidEncode (part of) a char array to anWriter.intgetMaximumDecodedLength(int nEncodedLen) Get the maximum decoded length based on the provided encoded length.intgetMaximumEncodedLength(int nDecodedLen) Get the maximum encoded length based on the provided decoded length.static booleanisMaybeEncoded(char @Nullable [] s) Check if the passed char array looks like it might be RFC 2616 encoded (starts and ends with a double quote character).static booleanisMaybeEncoded(@Nullable String s) Check if the passed string looks like it might be RFC 2616 encoded (starts and ends with a double quote character).static booleanisToken(char @Nullable [] aChars) Check if the passed char array is a valid RFC 2616 token.static booleanCheck if the passed string is a valid RFC 2616 token (i.e. contains no non-token characters).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.base.codec.ICharArrayDecoder
getDecoded, getDecodedMethods inherited from interface com.helger.base.codec.ICharArrayStreamDecoder
decode, getDecoded, getDecodedAsString, getDecodedAsString, getDecodedAsStringMethods inherited from interface com.helger.base.codec.ICharArrayStreamEncoder
encode, getEncoded, getEncoded, getEncoded, getEncodedAsString, getEncodedAsString, getEncodedAsString
-
Constructor Details
-
RFC2616Codec
public RFC2616Codec()Constructor.
-
-
Method Details
-
isToken
Check if the passed string is a valid RFC 2616 token (i.e. contains no non-token characters).- Parameters:
s- The string to check. May benull.- Returns:
trueif the string is a valid token,falseotherwise.
-
isToken
public static boolean isToken(char @Nullable [] aChars) Check if the passed char array is a valid RFC 2616 token.- Parameters:
aChars- The char array to check. May benull.- Returns:
trueif the char array is a valid token,falseotherwise.
-
isMaybeEncoded
Check if the passed string looks like it might be RFC 2616 encoded (starts and ends with a double quote character).- Parameters:
s- The string to check. May benull.- Returns:
trueif the string might be encoded,falseotherwise.
-
isMaybeEncoded
public static boolean isMaybeEncoded(char @Nullable [] s) Check if the passed char array looks like it might be RFC 2616 encoded (starts and ends with a double quote character).- Parameters:
s- The char array to check. May benull.- Returns:
trueif the char array might be encoded,falseotherwise.
-
getMaximumEncodedLength
@Nonnegative public int getMaximumEncodedLength(@Nonnegative int nDecodedLen) Description copied from interface:ICharArrayStreamEncoderGet the maximum encoded length based on the provided decoded length. This is purely for performance reasons. The name of the method would be better called "getMaximumEncodedLength".- Specified by:
getMaximumEncodedLengthin interfaceICharArrayEncoder- Specified by:
getMaximumEncodedLengthin interfaceICharArrayStreamEncoder- Parameters:
nDecodedLen- The decoded length. Always ≥ 0.- Returns:
- The maximum encoded length. Always ≥ 0.
-
encode
public void encode(char @Nullable [] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull Writer aWriter) Encode (part of) a char array to anWriter.- Specified by:
encodein interfaceICharArrayStreamEncoder- Parameters:
aDecodedBuffer- The char array to be encoded. May benull.nOfs- Offset into the char array to start from.nLen- Number of chars starting from offset to consider.aWriter- The writer to write to. May not benulland is NOT closed afterwards!
-
getMaximumDecodedLength
@Nonnegative public int getMaximumDecodedLength(@Nonnegative int nEncodedLen) Description copied from interface:ICharArrayDecoderGet the maximum decoded length based on the provided encoded length. This is purely for performance reasons.- Specified by:
getMaximumDecodedLengthin interfaceICharArrayDecoder- Parameters:
nEncodedLen- The encoded length. Always ≥ 0.- Returns:
- The maximum decoded length. Always ≥ 0.
-
decode
public void decode(char @Nullable [] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @WillNotClose @NonNull Writer aWriter) Decode (part of) a char array.- Specified by:
decodein interfaceICharArrayStreamDecoder- Parameters:
aEncodedBuffer- The char array to be decoded. May benull.nOfs- Offset into the char array to start from.nLen- Number of chars starting from offset to consider.aWriter- The writer to write to. May not benulland is NOT closed afterwards!
-