Package com.helger.commons.codec
Interface ICharArrayStreamEncoder
- All Superinterfaces:
ICharArrayEncoder,IEncoder<char[],char[]>
- All Known Subinterfaces:
ICharArrayCodec
- All Known Implementing Classes:
RFC2616Codec
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface for a single encoder of chars, based on reader/writer.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionvoidEncode (part of) a char array to anWriter.default voidEncode a char array to aWriter.default char[]getEncoded(char[] aDecodedBuffer) Encode a char array.default char[]getEncoded(char[] aDecodedBuffer, int nOfs, int nLen) Encode a char array.default char[]getEncoded(String sDecoded) Encode the passed string.default StringgetEncodedAsString(char[] aDecodedBuf) default StringgetEncodedAsString(char[] aDecodedBuf, int nOfs, int nLen) default StringgetEncodedAsString(String sDecoded) Encode the passed string and return the result as a String.default intgetMaximumEncodedLength(int nDecodedLen) Get the maximum encoded length based on the provided decoded length.
-
Method Details
-
getMaximumEncodedLength
Description copied from interface:ICharArrayEncoderGet 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- Parameters:
nDecodedLen- The decoded length. Always ≥ 0.- Returns:
- The maximum encoded length. Always ≥ 0.
-
encode
Encode a char array to aWriter.- Parameters:
aDecodedBuffer- The char array to be encoded. May benull.aWriter- The writer to write to. May not benulland is NOT closed afterwards!- Throws:
EncodeException- In case something goes wrong- Since:
- 9.0.0
-
encode
void encode(@Nullable char[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull @WillNotClose Writer aWriter) Encode (part of) a char array to anWriter.- 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!- Throws:
EncodeException- In case something goes wrong
-
getEncoded
Encode a char array.- Specified by:
getEncodedin interfaceICharArrayEncoder- Specified by:
getEncodedin interfaceIEncoder<char[],char[]> - Parameters:
aDecodedBuffer- The char array to be encoded. May benull.- Returns:
- The encoded char array or
nullif the parameter wasnull. - Throws:
EncodeException- In case something goes wrong
-
getEncoded
@Nullable @ReturnsMutableCopy default char[] getEncoded(@Nullable char[] aDecodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen) Encode a char array.- Specified by:
getEncodedin interfaceICharArrayEncoder- 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.- Returns:
- The encoded char array or
nullif the parameter wasnull. - Throws:
EncodeException- In case something goes wrong
-
getEncoded
Encode the passed string.- Specified by:
getEncodedin interfaceICharArrayEncoder- Parameters:
sDecoded- The string to be encoded. May benull.- Returns:
nullif the input string isnull.- Throws:
EncodeException- In case something goes wrong
-
getEncodedAsString
-
getEncodedAsString
@Nullable default String getEncodedAsString(@Nullable char[] aDecodedBuf, @Nonnegative int nOfs, @Nonnegative int nLen) -
getEncodedAsString
Encode the passed string and return the result as a String.- Parameters:
sDecoded- The string to be encoded. May benull.- Returns:
nullif the input string isnull.- Throws:
EncodeException- In case something goes wrong
-