Package org.tmatesoft.svn.core.io.diff
Class SVNDeltaGenerator
java.lang.Object
org.tmatesoft.svn.core.io.diff.SVNDeltaGenerator
public class SVNDeltaGenerator
extends java.lang.Object
The SVNDeltaGenerator is intended for generating diff windows of
fixed size having a target version of a file against a source one.
File contents are provided as two streams - source and target ones, or just
target if delta is generated against empty contents.
The generator uses X-Delta algorithm for generating all kinds of deltas.
- Since:
- 1.2
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private byte[]
private byte[]
private SVNDeltaAlgorithm
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a generator that will produce diff windows of 100Kbytes contents length.SVNDeltaGenerator
(int maximumDiffWindowSize) Creates a generator that will produce diff windows of a specified contents length. -
Method Summary
Modifier and TypeMethodDescriptionprivate int
readToBuffer
(java.io.InputStream is, byte[] buffer) void
sendDelta
(java.lang.String path, byte[] source, int sourceLength, long sourceOffset, byte[] target, int targetLength, ISVNDeltaConsumer consumer) Generates a series of diff windows of fixed size comparingtargetLength
of target bytes (read fromtarget
stream) againstsourceLength
of source bytes (read fromsource
stream at offsetsourceOffset
), and sends produced windows to the providedconsumer
.void
sendDelta
(java.lang.String path, byte[] target, int targetLength, ISVNDeltaConsumer consumer) Generates a series of diff windows of fixed size comparing target bytes (read fromtarget
stream) against an empty file, and sends produced windows to the provided consumer.private void
sendDelta
(java.lang.String path, long sourceOffset, byte[] source, int sourceLength, byte[] target, int targetLength, ISVNDeltaConsumer consumer) java.lang.String
sendDelta
(java.lang.String path, java.io.InputStream source, long sourceOffset, java.io.InputStream target, ISVNDeltaConsumer consumer, boolean computeChecksum) Generates a series of diff windows of fixed size comparing target bytes (read fromtarget
stream) against source bytes (read fromsource
stream), and sends produced windows to the provided consumer.java.lang.String
sendDelta
(java.lang.String path, java.io.InputStream target, ISVNDeltaConsumer consumer, boolean computeChecksum) Generates a series of diff windows of fixed size comparing target bytes (fromtarget
stream) against an empty file and sends produced windows to the provided consumer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
myXDelta
-
mySourceBuffer
private byte[] mySourceBuffer -
myTargetBuffer
private byte[] myTargetBuffer -
myMaximumBufferSize
private int myMaximumBufferSize
-
-
Constructor Details
-
SVNDeltaGenerator
public SVNDeltaGenerator()Creates a generator that will produce diff windows of 100Kbytes contents length. That is, after applying of such a window you get 100 Kbytes of file contents.- See Also:
-
SVNDeltaGenerator
public SVNDeltaGenerator(int maximumDiffWindowSize) Creates a generator that will produce diff windows of a specified contents length.- Parameters:
maximumDiffWindowSize
- a maximum size of a file contents chunk that a single applied diff window would produce
-
-
Method Details
-
sendDelta
public java.lang.String sendDelta(java.lang.String path, java.io.InputStream target, ISVNDeltaConsumer consumer, boolean computeChecksum) throws SVNException Generates a series of diff windows of fixed size comparing target bytes (fromtarget
stream) against an empty file and sends produced windows to the provided consumer.consumer
'stextDeltaChunk()
method is called to receive and process generated windows. Now new data comes within a window, so the output stream is either ignored (if it's null) or immediately closed (if it's not null).If
computeChecksum
is true, the return value will be a strig containing a hex representation of the MD5 digest computed for the target contents.- Parameters:
path
- a file repository pathtarget
- an input stream to read target bytes fromconsumer
- a diff windows consumercomputeChecksum
- true to compute a checksum- Returns:
- if
computeChecksum
is true, a string representing a hex form of the MD5 checksum computed for the target contents; otherwise null - Throws:
SVNException
-
sendDelta
public java.lang.String sendDelta(java.lang.String path, java.io.InputStream source, long sourceOffset, java.io.InputStream target, ISVNDeltaConsumer consumer, boolean computeChecksum) throws SVNException Generates a series of diff windows of fixed size comparing target bytes (read fromtarget
stream) against source bytes (read fromsource
stream), and sends produced windows to the provided consumer.consumer
'stextDeltaChunk()
method is called to receive and process generated windows. Now new data comes within a window, so the output stream is either ignored (if it's null) or immediately closed (if it's not null).If
computeChecksum
is true, the return value will be a strig containing a hex representation of the MD5 digest computed for the target contents.- Parameters:
path
- a file repository pathsource
- an input stream to read source bytes fromsourceOffset
- an offset of the source view in the givensource
streamtarget
- an input stream to read target bytes fromconsumer
- a diff windows consumercomputeChecksum
- true to compute a checksum- Returns:
- if
computeChecksum
is true, a string representing a hex form of the MD5 checksum computed for the target contents; otherwise null - Throws:
SVNException
-
sendDelta
public void sendDelta(java.lang.String path, byte[] target, int targetLength, ISVNDeltaConsumer consumer) throws SVNException Generates a series of diff windows of fixed size comparing target bytes (read fromtarget
stream) against an empty file, and sends produced windows to the provided consumer. This is identical tosendDelta(path, null, 0, 0, target, targetLength, consumer)
.- Parameters:
path
- a file repository pathtarget
- an input byte array to read target bytes fromtargetLength
-consumer
- a diff windows consumer- Throws:
SVNException
-
sendDelta
public void sendDelta(java.lang.String path, byte[] source, int sourceLength, long sourceOffset, byte[] target, int targetLength, ISVNDeltaConsumer consumer) throws SVNException Generates a series of diff windows of fixed size comparingtargetLength
of target bytes (read fromtarget
stream) againstsourceLength
of source bytes (read fromsource
stream at offsetsourceOffset
), and sends produced windows to the providedconsumer
. Size of the produced windows is set in a constructor of this delta generator.consumer
'stextDeltaChunk()
method is called to receive and process generated windows. Now new data comes within a window, so the output stream is either ignored (if it's null) or immediately closed (if it's not null).- Parameters:
path
- a file repository pathsource
- an input stream to read source bytes fromsourceLength
- the size of the source viewsourceOffset
- an offset of the source view in the givensource
streamtarget
- an input stream to read target bytes fromtargetLength
- the size of the target viewconsumer
- a diff windows consumer- Throws:
SVNException
-
sendDelta
private void sendDelta(java.lang.String path, long sourceOffset, byte[] source, int sourceLength, byte[] target, int targetLength, ISVNDeltaConsumer consumer) throws SVNException - Throws:
SVNException
-
readToBuffer
private int readToBuffer(java.io.InputStream is, byte[] buffer) throws java.io.IOException - Throws:
java.io.IOException
-