1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.codec.binary;
19
20 import java.io.InputStream;
21
22 /**
23 * Provides <a href="https://datatracker.ietf.org/doc/html/rfc9285">RFC 9285 Base45</a> decoding in a streaming fashion (unlimited size).
24 *
25 * @see Base45
26 * @see <a href="https://datatracker.ietf.org/doc/html/rfc9285">RFC 9285 – The Base45 Data Encoding</a>
27 * @since 1.23.0
28 */
29 public class Base45InputStream extends BaseNCodecInputStream<Base45, Base45InputStream, Base45InputStream.Builder> {
30
31 /**
32 * Builds instances of Base45InputStream.
33 */
34 public static class Builder extends BaseNCodecInputStream.AbstracBuilder<Base45InputStream, Base45, Builder> {
35
36 /**
37 * Constructs a new instance.
38 */
39 public Builder() {
40 // empty
41 }
42
43 @Override
44 public Base45InputStream get() {
45 return new Base45InputStream(this);
46 }
47
48 @Override
49 protected Base45 newBaseNCodec() {
50 return new Base45();
51 }
52 }
53
54 /**
55 * Constructs a new Builder.
56 *
57 * @return A new Builder.
58 */
59 public static Builder builder() {
60 return new Builder();
61 }
62
63 private Base45InputStream(final Builder builder) {
64 super(builder);
65 }
66
67 /**
68 * Constructs a Base45InputStream such that all data read is Base45-decoded from the original provided InputStream.
69 *
70 * @param inputStream InputStream to wrap.
71 */
72 public Base45InputStream(final InputStream inputStream) {
73 super(builder().setInputStream(inputStream));
74 }
75 }