JavaSVN Home

org.tmatesoft.svn.core
Class SVNAnnotationGenerator

java.lang.Object
  extended byorg.tmatesoft.svn.core.SVNAnnotationGenerator
All Implemented Interfaces:
ISVNFileRevisionHandler

public class SVNAnnotationGenerator
extends Object
implements ISVNFileRevisionHandler

The SVNAnnotationGenerator class is used to annotate files - that is to place author and revision information in-line for the specified file.

Since SVNAnnotationGenerator implements ISVNFileRevisionHandler, it is merely passed to a getFileRevisions() method of SVNRepository. After that you handle the resultant annotated file line-by-line providing an ISVNAnnotateHandler implementation to the reportAnnotations() method:

 import org.tmatesoft.svn.core.SVNAnnotationGenerator;
 import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
 import org.tmatesoft.svn.core.io.SVNRepository;
 import org.tmatesoft.svn.core.wc.SVNAnnotateHandler;
 ...
 
     File tmpFile;
     SVNRepository repos;
     ISVNAnnotateHandler annotateHandler;
     ISVNEventHandler cancelHandler;
     long startRev = 0;
     long endRev = 150;
     ...
     
     SVNAnnotationGenerator generator = new SVNAnnotationGenerator(path, tmpFile, cancelHandler);
     try {
         repos.getFileRevisions("", startRev, endRev, generator);
         generator.reportAnnotations(annotateHandler, null);
     } finally {
         generator.dispose();
     }
 ...

Version:
1.0
Author:
TMate Software Ltd.

Constructor Summary
SVNAnnotationGenerator(String path, File tmpDirectory, long startRevision, ISVNEventHandler cancelBaton)
          Constructs an annotation generator object.
 
Method Summary
 void applyTextDelta(String token)
          Starts deltas applying for a given file name or path (denoted by token).
 void closeRevision(String token)
          Performs final handling for the processed file revision (when all deltas are applied and fulltext is got).
 void dispose()
          Finalizes an annotation operation releasing resources involved by this generator.
 void openRevision(SVNFileRevision fileRevision)
          Handles a file revision info.
 void reportAnnotations(ISVNAnnotateHandler handler, String inputEncoding)
          Dispatches file lines along with author & revision info to the provided annotation handler.
 OutputStream textDeltaChunk(String token, SVNDiffWindow diffWindow)
          Handles a next diff window for a file (represented by a token) and returns an output stream to write instructions and new text data for the window.
 void textDeltaEnd(String token)
          Finilazes collecting deltas (diff windows) for a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVNAnnotationGenerator

public SVNAnnotationGenerator(String path,
                              File tmpDirectory,
                              long startRevision,
                              ISVNEventHandler cancelBaton)
Constructs an annotation generator object. A user may want to have a chance to interrupt an operation - so, cancelBaton's ISVNEventHandler.checkCancelled() method is used for this purpose.

Parameters:
path - a file path (relative to a repository location)
tmpDirectory - a revision to stop at
startRevision - a start revision to begin annotation with
cancelBaton - a baton which is used to check if an operation is cancelled
Method Detail

openRevision

public void openRevision(SVNFileRevision fileRevision)
                  throws SVNException
Description copied from interface: ISVNFileRevisionHandler
Handles a file revision info.

Specified by:
openRevision in interface ISVNFileRevisionHandler
Parameters:
fileRevision - a SVNFileRevision object representing file revision information
Throws:
SVNException
See Also:
SVNFileRevision

closeRevision

public void closeRevision(String token)
                   throws SVNException
Description copied from interface: ISVNFileRevisionHandler
Performs final handling for the processed file revision (when all deltas are applied and fulltext is got).

Specified by:
closeRevision in interface ISVNFileRevisionHandler
Parameters:
token - a file token (name or path)
Throws:
SVNException

applyTextDelta

public void applyTextDelta(String token)
                    throws SVNException
Description copied from interface: ISVNFileRevisionHandler
Starts deltas applying for a given file name or path (denoted by token).

Specified by:
applyTextDelta in interface ISVNFileRevisionHandler
Parameters:
token - a file token
Throws:
SVNException

textDeltaChunk

public OutputStream textDeltaChunk(String token,
                                   SVNDiffWindow diffWindow)
                            throws SVNException
Description copied from interface: ISVNFileRevisionHandler
Handles a next diff window for a file (represented by a token) and returns an output stream to write instructions and new text data for the window.

Specified by:
textDeltaChunk in interface ISVNFileRevisionHandler
Parameters:
token - a file path or name (or anything an implementor would like to use for his own implementation)
diffWindow - a diff window representing a delta chunk
Returns:
an output stream where instructions and new text data for diffWindow will be written
Throws:
SVNException

textDeltaEnd

public void textDeltaEnd(String token)
                  throws SVNException
Description copied from interface: ISVNFileRevisionHandler
Finilazes collecting deltas (diff windows) for a file. This method is called just when all the diff windows for a file were handled. It may be here where the collected deltas are applied.

Specified by:
textDeltaEnd in interface ISVNFileRevisionHandler
Parameters:
token - defines a path or a name (or anything an implementor would like to use for his own implementation) of the file for which finalizing steps should be performed
Throws:
SVNException

reportAnnotations

public void reportAnnotations(ISVNAnnotateHandler handler,
                              String inputEncoding)
                       throws SVNException
Dispatches file lines along with author & revision info to the provided annotation handler.

Parameters:
handler - an annotation handler that processes file lines with author & revision info
inputEncoding - a desired character set (encoding) of text lines
Throws:
SVNException

dispose

public void dispose()
Finalizes an annotation operation releasing resources involved by this generator. Should be called after reportAnnotations().


JavaSVN Home

Copyright © 2004-2006 TMate Software Ltd. All Rights Reserved.