private byte[] encode(final RevisionCodecData codecData,final Diff diff) throws UnsupportedEncodingException, EncodingException {
  this.data=new BitWriter(codecData.totalSizeInBits());
  encodeCodecData(codecData);
  DiffPart part;
  Iterator<DiffPart> partIt=diff.iterator();
  while (partIt.hasNext()) {
    part=partIt.next();
switch (part.getAction()) {
case FULL_REVISION_UNCOMPRESSED:
      encodeFullRevisionUncompressed(part);
    break;
case INSERT:
  encodeInsert(part);
break;
case DELETE:
encodeDelete(part);
break;
case REPLACE:
encodeReplace(part);
break;
case CUT:
encodeCut(part);
break;
case PASTE:
encodePaste(part);
break;
default :
throw new RuntimeException();
}
}
return data.toByteArray();
}

private byte [ ] encode ( final RevisionCodecData codecData , final Diff diff ) throws UnsupportedEncodingException , EncodingException { this . data = new BitWriter ( codecData . totalSizeInBits ( ) ) ; encodeCodecData ( codecData ) ; DiffPart part ; Iterator < DiffPart > partIt = diff . iterator ( ) ; while ( partIt . hasNext ( ) ) { part = partIt . next ( ) ; switch ( part . getAction ( ) ) { case FULL_REVISION_UNCOMPRESSED : encodeFullRevisionUncompressed ( part ) ; break ; case INSERT : encodeInsert ( part ) ; break ; case DELETE : encodeDelete ( part ) ; break ; case REPLACE : encodeReplace ( part ) ; break ; case CUT : encodeCut ( part ) ; break ; case PASTE : encodePaste ( part ) ; break ; default : throw new RuntimeException ( ) ; } } return data . toByteArray ( ) ; }
creates the binary encoding of the diff while using the codec information .
