public String buildRevision(final String previousRevision){
  HashMap<String,String> bufferMap=new HashMap<String,String>();
  StringBuilder output=new StringBuilder();
  if (previousRevision != null) {
    output.append(previousRevision);
  }
  int size=parts.size();
  DiffPart part;
  for (int i=0; i < size; i++) {
    part=parts.get(i);
switch (part.getAction()) {
case FULL_REVISION_UNCOMPRESSED:
      output=new StringBuilder();
    output.insert(0,part.getText());
  break;
case INSERT:
output.insert(part.getStart(),part.getText());
break;
case DELETE:
output.delete(part.getStart(),part.getEnd());
break;
case REPLACE:
output.replace(part.getStart(),part.getEnd(),part.getText());
break;
case CUT:
bufferMap.put(part.getText(),output.substring(part.getStart(),part.getEnd()));
output.delete(part.getStart(),part.getEnd());
break;
case PASTE:
output.insert(part.getStart(),bufferMap.remove(part.getText()));
break;
default :
throw new RuntimeException("UNKNOWN PART ACTION");
}
}
return output.toString();
}

public String buildRevision ( final String previousRevision ) { HashMap < String , String > bufferMap = new HashMap < String , String > ( ) ; StringBuilder output = new StringBuilder ( ) ; if ( previousRevision != null ) { output . append ( previousRevision ) ; } int size = parts . size ( ) ; DiffPart part ; for ( int i = 0 ; i < size ; i ++ ) { part = parts . get ( i ) ; switch ( part . getAction ( ) ) { case FULL_REVISION_UNCOMPRESSED : output = new StringBuilder ( ) ; output . insert ( 0 , part . getText ( ) ) ; break ; case INSERT : output . insert ( part . getStart ( ) , part . getText ( ) ) ; break ; case DELETE : output . delete ( part . getStart ( ) , part . getEnd ( ) ) ; break ; case REPLACE : output . replace ( part . getStart ( ) , part . getEnd ( ) , part . getText ( ) ) ; break ; case CUT : bufferMap . put ( part . getText ( ) , output . substring ( part . getStart ( ) , part . getEnd ( ) ) ) ; output . delete ( part . getStart ( ) , part . getEnd ( ) ) ; break ; case PASTE : output . insert ( part . getStart ( ) , bufferMap . remove ( part . getText ( ) ) ) ; break ; default : throw new RuntimeException ( "UNKNOWN PART ACTION" ) ; } } return output . toString ( ) ; }
builds the current revision .
