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

pgpainless / pgpainless / #1072

05 Jan 2026 10:21PM UTC coverage: 85.206% (+0.3%) from 84.93%
#1072

push

github

vanitasvitae
Remove workaround removing key flags when overriding, since BC now removes other flag instances on its own

6756 of 7929 relevant lines covered (85.21%)

0.85 hits per line

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

66.67
/pgpainless-core/src/main/kotlin/org/pgpainless/algorithm/StreamEncoding.kt
1
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package org.pgpainless.algorithm
6

7
/**
8
 * Enumeration of possible encoding formats of the content of the literal data packet.
9
 *
10
 * See [RFC4880: Literal Data Packet](https://tools.ietf.org/html/rfc4880#section-5.9)
11
 */
12
enum class StreamEncoding(val code: Char) {
1✔
13

14
    /** The Literal packet contains binary data. */
15
    BINARY('b'),
1✔
16

17
    /**
18
     * The Literal packet contains text data, and thus may need line ends converted to local form,
19
     * or other text-mode changes.
20
     */
21
    TEXT('t'),
1✔
22

23
    /** Indication that the implementation believes that the literal data contains UTF-8 text. */
24
    UTF8('u'),
1✔
25

26
    /**
27
     * Early versions of PGP also defined a value of 'l' as a 'local' mode for machine-local
28
     * conversions. RFC 1991 [RFC1991] incorrectly stated this local mode flag as '1' (ASCII numeral
29
     * one). Both of these local modes are deprecated.
30
     */
31
    @Deprecated("LOCAL is deprecated.") LOCAL('l'),
1✔
32
    ;
33

34
    companion object {
35
        /**
36
         * Return the [StreamEncoding] corresponding to the provided code identifier. If no matching
37
         * encoding is found, return null.
38
         *
39
         * @param code identifier
40
         * @return encoding enum
41
         */
42
        @JvmStatic
43
        fun fromCode(code: Int): StreamEncoding? {
44
            return values().firstOrNull { it.code == code.toChar() }
1✔
45
                ?: if (code == 1) return LOCAL else null
×
46
        }
47

48
        /**
49
         * Return the [StreamEncoding] corresponding to the provided code identifier. If no matching
50
         * encoding is found, throw a [NoSuchElementException].
51
         *
52
         * @param code identifier
53
         * @return encoding enum
54
         * @throws NoSuchElementException in case of an unmatched identifier
55
         */
56
        @JvmStatic
57
        fun requireFromCode(code: Int): StreamEncoding {
58
            return fromCode(code)
×
59
                ?: throw NoSuchElementException("No StreamEncoding found for code $code")
×
60
        }
61
    }
62
}
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