• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ehrmann / vcdiff-java / 26

18 Apr 2026 05:11PM UTC coverage: 83.839% (+0.2%) from 83.679%
26

push

circleci

ehrmann
Fix Coveralls integration

663 of 814 branches covered (81.45%)

1603 of 1912 relevant lines covered (83.84%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/core/src/main/java/com/davidehrmann/vcdiff/VCDiffEncoderBuilder.java
1
// Copyright 2016 David Ehrmann
2
// Author: David Ehrmann
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
//      http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//
16
// Definition of an abstract class that describes the interface between the
17
// encoding engine (which finds the best string matches between the source and
18
// target data) and the code table writer.  The code table writer is passed a
19
// series of add, copy, and run instructions and produces an output file in the
20
// desired format.
21

22
package com.davidehrmann.vcdiff;
23

24
import com.davidehrmann.vcdiff.engine.HashedDictionary;
25
import com.davidehrmann.vcdiff.engine.VCDiffCodeTableWriterImpl;
26
import com.davidehrmann.vcdiff.engine.VCDiffStreamingEncoderImpl;
27
import com.davidehrmann.vcdiff.io.VCDiffOutputStream;
28

29
import java.io.OutputStream;
30
import java.util.EnumSet;
31

32
public class VCDiffEncoderBuilder {
33

34
    protected boolean interleaved = false;
1✔
35
    protected boolean checksum = false;
1✔
36
    protected boolean targetMatches = true;
1✔
37
    protected byte[] dictionary = null;
1✔
38

39
    protected VCDiffEncoderBuilder() {
1✔
40

41
    }
1✔
42

43
    public synchronized VCDiffEncoderBuilder withChecksum(boolean checksum) {
44
        this.checksum = checksum;
1✔
45
        return this;
1✔
46
    }
47

48
    public synchronized VCDiffEncoderBuilder withInterleaving(boolean interleaved) {
49
        this.interleaved = interleaved;
1✔
50
        return this;
1✔
51
    }
52

53
    public synchronized VCDiffEncoderBuilder withDictionary(byte[] dictionary) {
54
        this.dictionary = dictionary;
1✔
55
        return this;
1✔
56
    }
57

58
    public synchronized VCDiffEncoderBuilder withTargetMatches(boolean targetMatches) {
59
        this.targetMatches = targetMatches;
1✔
60
        return this;
1✔
61
    }
62

63
    public synchronized VCDiffStreamingEncoder<OutputStream> buildStreaming() {
64
        if (dictionary == null) {
1!
65
            throw new IllegalArgumentException("dictionary not set");
×
66
        }
67

68
        EnumSet<VCDiffFormatExtension> formatFlags = EnumSet.noneOf(VCDiffFormatExtension.class);
1✔
69
        if (interleaved) {
1✔
70
            formatFlags.add(VCDiffFormatExtension.GOOGLE_INTERLEAVED);
1✔
71
        }
72
        if (checksum) {
1✔
73
            formatFlags.add(VCDiffFormatExtension.GOOGLE_CHECKSUM);
1✔
74
        }
75

76
        VCDiffCodeTableWriter<OutputStream> coder = new VCDiffCodeTableWriterImpl(interleaved);
1✔
77

78
        return new VCDiffStreamingEncoderImpl<OutputStream>(
1✔
79
                coder,
80
                new HashedDictionary(dictionary),
81
                formatFlags,
82
                targetMatches
83
        );
84
    }
85

86
    public VCDiffOutputStream buildOutputStream(OutputStream out) {
87
        return new VCDiffOutputStream(out, buildStreaming());
×
88
    }
89

90
    public VCDiffEncoder<OutputStream> buildSimple() {
91
        return new VCDiffEncoder<OutputStream>(buildStreaming());
1✔
92
    }
93

94
    public static VCDiffEncoderBuilder builder() {
95
        return new VCDiffEncoderBuilder();
1✔
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc