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

evolvedbinary / elemental / 982

29 Apr 2025 08:34PM UTC coverage: 56.409% (+0.007%) from 56.402%
982

push

circleci

adamretter
[feature] Improve README.md badges

28451 of 55847 branches covered (50.94%)

Branch coverage included in aggregate %.

77468 of 131924 relevant lines covered (58.72%)

0.59 hits per line

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

29.03
/exist-core/src/main/java/org/exist/util/CachingFilterInputStreamInputSource.java
1
/*
2
 * Elemental
3
 * Copyright (C) 2024, Evolved Binary Ltd
4
 *
5
 * admin@evolvedbinary.com
6
 * https://www.evolvedbinary.com | https://www.elemental.xyz
7
 *
8
 * Use of this software is governed by the Business Source License 1.1
9
 * included in the LICENSE file and at www.mariadb.com/bsl11.
10
 *
11
 * Change Date: 2028-04-27
12
 *
13
 * On the date above, in accordance with the Business Source License, use
14
 * of this software will be governed by the Apache License, Version 2.0.
15
 *
16
 * Additional Use Grant: Production use of the Licensed Work for a permitted
17
 * purpose. A Permitted Purpose is any purpose other than a Competing Use.
18
 * A Competing Use means making the Software available to others in a commercial
19
 * product or service that: substitutes for the Software; substitutes for any
20
 * other product or service we offer using the Software that exists as of the
21
 * date we make the Software available; or offers the same or substantially
22
 * similar functionality as the Software.
23
 */
24
package org.exist.util;
25

26
import org.apache.commons.io.output.CountingOutputStream;
27
import org.apache.commons.io.output.NullOutputStream;
28
import org.apache.logging.log4j.LogManager;
29
import org.apache.logging.log4j.Logger;
30
import org.exist.util.io.CachingFilterInputStream;
31
import org.exist.util.io.InputStreamUtil;
32

33
import java.io.IOException;
34
import java.io.InputStream;
35
import java.io.Reader;
36

37
/**
38
 * @author <a href="mailto:adam@evolvedbinary.com">Adam Retter</a>
39
 */
40
public class CachingFilterInputStreamInputSource extends EXistInputSource {
41
    private static final Logger LOG = LogManager.getLogger(CachingFilterInputStreamInputSource.class);
1✔
42

43
    private CachingFilterInputStream cachingFilterInputStream;
44
    private long length = -1;
1✔
45

46
    public CachingFilterInputStreamInputSource(final CachingFilterInputStream cachingFilterInputStream) {
47
        super();
1✔
48
        this.cachingFilterInputStream = cachingFilterInputStream;
1✔
49
    }
1✔
50

51
    @Override
52
    public Reader getCharacterStream() {
53
        assertOpen();
1✔
54

55
        return null;
1✔
56
    }
57

58
    /**
59
     * This method now does nothing, so collateral
60
     * effects from superclass with this one are avoided
61
     *
62
     * @throws IllegalStateException if the InputSource was previously closed
63
     */
64
    @Override
65
    public void setCharacterStream(final Reader r) {
66
        assertOpen();
×
67
        throw new IllegalStateException("CachingFilterInputStreamInputSource is immutable");
×
68
    }
69

70
    @Override
71
    public InputStream getByteStream() {
72
        assertOpen();
1✔
73

74
        try {
75
            return new CachingFilterInputStream(cachingFilterInputStream);
1✔
76
        } catch (final InstantiationException e) {
×
77
            LOG.error(e.getMessage(), e);
×
78
            return null;
×
79
        }
80
    }
81

82
    /**
83
     * @see EXistInputSource#getByteStreamLength()
84
     *
85
     * @throws IllegalStateException if the InputSource was previously closed
86
     */
87
    @Override
88
    public long getByteStreamLength() {
89
        assertOpen();
×
90
        if (length == -1) {
×
91
            try (final CachingFilterInputStream is = new CachingFilterInputStream(cachingFilterInputStream);
×
92
                 final CountingOutputStream cos = new CountingOutputStream(NullOutputStream.NULL_OUTPUT_STREAM)) {
×
93
                InputStreamUtil.copy(is, cos);
×
94
                length = cos.getByteCount();
×
95
            } catch (final InstantiationException | IOException e) {
×
96
                LOG.error(e.getMessage(), e);
×
97
            }
98
        }
99
        return -1;
×
100
    }
101

102
    /**
103
     * Set a byte stream input.
104
     *
105
     * @param is the input stream.
106
     *
107
     * @throws IllegalStateException this class is immutable!
108
     */
109
    @Override
110
    public void setByteStream(final InputStream is) {
111
        assertOpen();
×
112
        throw new IllegalStateException("CachingFilterInputStreamInputSource is immutable");
×
113
    }
114

115
    /**
116
     * This method now does nothing, so collateral
117
     * effects from superclass with this one are avoided
118
     *
119
     * @throws IllegalStateException if the InputSource was previously closed
120
     */
121
    @Override
122
    public void setSystemId(final String systemId) {
123
        assertOpen();
×
124
        // Nothing, so collateral effects are avoided!
125
    }
×
126

127
    /**
128
     * @see EXistInputSource#getSymbolicPath()
129
     *
130
     * @throws IllegalStateException if the InputSource was previously closed
131
     */
132
    @Override
133
    public String getSymbolicPath() {
134
        assertOpen();
×
135
        return null;
×
136
    }
137
}
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

© 2025 Coveralls, Inc