decode method
Decodes the input string using the codec's specific algorithm.
input
The encoded string to be decoded.
Returns the decoded plain text string.
Throws ArgumentError if the input is invalid for this codec. Throws FormatException if decoding fails due to format issues.
Implementation
@override
String decode(String input) {
if (input.isEmpty) {
throw ArgumentError('Input cannot be empty');
}
String result = input;
// Apply codecs in reverse order for decoding
for (int i = codecs.length - 1; i >= 0; i--) {
try {
result = codecs[i].decode(result);
} catch (e) {
throw FormatException(
'Failed at codec ${codecs[i].name} (step ${codecs.length - i}): $e');
}
}
return result;
}