Package com.helger.commons.codec
Interface IByteArrayStreamDecoder
- All Superinterfaces:
IByteArrayDecoder,IDecoder<byte[],byte[]>
- All Known Subinterfaces:
IByteArrayCodec
- All Known Implementing Classes:
ASCII85Codec,ASCIIHexCodec,Base16Codec,Base32Codec,Base64Codec,FlateCodec,GZIPCodec,IdentityByteArrayCodec,LZWCodec,QuotedPrintableCodec,RunLengthCodec,URLCodec
- 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 decoder of bytes, based on streams.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(byte[] aEncodedBuffer, int nOfs, int nLen, OutputStream aOS) Decode (part of) a byte array.default voiddecode(byte[] aEncodedBuffer, OutputStream aOS) Decode a byte array.default byte[]getDecoded(byte[] aEncodedBuffer, int nOfs, int nLen) Decode a byte array.default StringgetDecodedAsString(byte[] aEncodedBuffer, int nOfs, int nLen, Charset aCharset) default StringgetDecodedAsString(byte[] aEncodedBuffer, Charset aCharset) default StringgetDecodedAsString(String sEncoded, Charset aCharset) Decode the passed string.default StringgetDecodedAsString(String sEncoded, Charset aEncodedCharset, Charset aDecodedCharset) Decode the passed string.Methods inherited from interface com.helger.commons.codec.IByteArrayDecoder
getDecoded, getDecoded, getMaximumDecodedLength
-
Method Details
-
decode
Decode a byte array.- Parameters:
aEncodedBuffer- The byte array to be decoded. May benull.aOS- The output stream to write to. May not benulland is NOT closed afterwards!- Throws:
DecodeException- in case something goes wrong- Since:
- 9.0.0
-
decode
void decode(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull @WillNotClose OutputStream aOS) Decode (part of) a byte array.- Parameters:
aEncodedBuffer- The byte array to be decoded. May benull.nOfs- Offset into the byte array to start from.nLen- Number of bytes starting from offset to consider.aOS- The output stream to write to. May not benulland is NOT closed afterwards!- Throws:
DecodeException- in case something goes wrong
-
getDecoded
@Nullable @ReturnsMutableCopy default byte[] getDecoded(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen) Decode a byte array.- Specified by:
getDecodedin interfaceIByteArrayDecoder- Parameters:
aEncodedBuffer- The byte array to be decoded. May benull.nOfs- Offset into the byte array to start from.nLen- Number of bytes starting from offset to consider.- Returns:
- The decoded byte array or
nullif the parameter wasnull. - Throws:
DecodeException- in case something goes wrong
-
getDecodedAsString
-
getDecodedAsString
@Nullable default String getDecodedAsString(@Nullable byte[] aEncodedBuffer, @Nonnegative int nOfs, @Nonnegative int nLen, @Nonnull Charset aCharset) -
getDecodedAsString
Decode the passed string.- Parameters:
sEncoded- The string to be decoded. May benull.aCharset- The charset to be used for encoding AND decoding. May not benull.- Returns:
nullif the input string isnull.- Throws:
DecodeException- in case something goes wrong
-
getDecodedAsString
@Nullable default String getDecodedAsString(@Nullable String sEncoded, @Nonnull Charset aEncodedCharset, @Nonnull Charset aDecodedCharset) Decode the passed string.- Parameters:
sEncoded- The string to be decoded. May benull.aEncodedCharset- The charset to be used for the encoded string. May not benull.aDecodedCharset- The charset to be used for the decoded result string. May not benull.- Returns:
nullif the input string isnull.- Throws:
DecodeException- in case something goes wrong- Since:
- 9.3.6
-