class FixedLengthStringCodec implements Codec<String> {

    public void encode(String value, BitChannel channel, Resolver resolver) throws IOException {
        int size = sizeExpr.eval(resolver);
        ByteBuffer bytebuffer = ByteBuffer.allocate(size);
        encoder.encode(CharBuffer.wrap(value), bytebuffer, true);

        if (bytebuffer.position() < size) { // pad with 0's
            bytebuffer.put(new byte[size - bytebuffer.position()]);
        }
        bytebuffer.flip(); // switch to reading
        
        byte[] bytes = new byte[size];
        bytebuffer.get(bytes);
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = byteConverter.revert(bytes[i]);
        }
        //assert (size <= bytes.length); //No longer needed
        channel.write(bytes, 0, size);
    }

    public  FixedLengthStringCodec(Charset encoding,
                                  Expression<Integer, Resolver> sizeExpr, String match,
                                  BoundString.ByteConverter byteConverter);

}