@@ -0,0 +1,1986 @@
+import com.k13n.soliton.RobustSolitonGenerator;%0Aimport java.util.Random;%0Aimport java.util.Arrays;%0Aimport java.util.BitSet;%0Aimport java.nio.ByteBuffer;%0A%0Apublic final class Encoder %7B%0A%0A  public interface Callback %7B%0A    public boolean call(Encoder encoder, int d, byte data%5B%5D);%0A  %7D%0A%0A  private static final double DEFAULT_C = 0.3333;%0A%0A  private final int packetSize;%0A  private final int nPackets;%0A  private final Random uniformRNG;%0A  private final RobustSolitonGenerator solitonRNG;%0A  private final ByteBuffer buffer;%0A  private final long seed;%0A%0A  public Encoder(byte%5B%5D data, int packetSize, double failureProbability) %7B%0A    this(data, packetSize, failureProbability, DEFAULT_C);%0A  %7D%0A%0A  public Encoder(byte%5B%5D data, int packetSize, double failureProbability, double c) %7B%0A    this.packetSize = packetSize;%0A    this.seed = (long)(Math.random() * 1024 * 5);%0A    this.nPackets = (int)Math.ceil(data.length / packetSize);%0A    this.uniformRNG = new Random(this.seed);%0A    this.solitonRNG = new RobustSolitonGenerator(nPackets, c, failureProbability);%0A%0A    this.buffer = ByteBuffer.wrap(Arrays.copyOf(data, nPackets * packetSize),%0A                                  0, nPackets * packetSize);%0A  %7D%0A%0A  public long getSeed() %7B%0A    return this.seed;%0A  %7D%0A%0A  public int getNPackets() %7B%0A    return this.nPackets;%0A  %7D%0A%0A  public void encode(Callback callback) %7B%0A    boolean abort = false;%0A    while(!abort) %7B%0A      try %7B%0A%0A        int d = solitonRNG.next();%0A        BitSet xorSet = null;%0A%0A        for(int i = 0; i %3C d; i++)%0A        %7B%0A          int pos = uniformRNG.nextInt(this.nPackets) * this.packetSize;%0A          this.buffer.position(pos);%0A          BitSet bitSet = BitSet.valueOf(this.buffer).get(0, this.packetSize);%0A          if(xorSet == null)%0A            xorSet = bitSet;%0A          else%0A            xorSet.xor(bitSet);%0A        %7D%0A%0A        abort = callback.call(this, d, xorSet.toByteArray());%0A%0A%0A      %7D catch(Exception e) %7B%0A        /* FIXME*/%0A        e.printStackTrace();%0A      %7D%0A%0A%0A    %7D%0A      %0A%0A  %7D%0A%7D%0A

Add preliminary encoder implementation