public void add ( final Revision rev ) { int revIndex = rev . getRevisionCounter ( ) ; if ( this . mapping . containsKey ( revIndex ) ) { revIndex = this . mapping . get ( revIndex ) ; } // System.out.println("Store " + rev.getRevisionCounter() + " with " + // revIndex); ChronoFullRevision cfr = this . fullRevStorage . get ( rev . getRevisionCounter ( ) ) ; ChronoStorageBlock block = new ChronoStorageBlock ( cfr , revIndex , rev ) ; cfr . add ( block ) ; if ( revIndex < revisionIndex ) { // System.out.println("Revision has already been processed: " + // revIndex); block . setDelivered ( true ) ; return ; } clean ( ) ; if ( this . storage . containsKey ( revIndex ) ) { // throw new IllegalArgumentException(revisionIndex + // "- Object already contained: " + revIndex); return ; } storage . put ( revIndex , block ) ; size += block . length ( ) ; if ( first == null ) { first = block ; last = block ; } else { ChronoStorageBlock previous = null , current = first ; do { if ( revIndex < current . getRevisionIndex ( ) ) { block . setIndexPrev ( previous ) ; block . setIndexNext ( current ) ; if ( previous != null ) { previous . setIndexNext ( block ) ; } current . setIndexPrev ( block ) ; if ( current == first ) { this . first = block ; } return ; } previous = current ; current = current . getIndexNext ( ) ; } while ( current != null ) ; // Add to end of list previous . setIndexNext ( block ) ; block . setIndexPrev ( previous ) ; this . last = block ; } }
Adds a revision to the chrono storage .