001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * https://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.codec.binary; 019 020import java.io.InputStream; 021 022/** 023 * Provides <a href="https://datatracker.ietf.org/doc/html/rfc9285">RFC 9285 Base45</a> decoding in a streaming fashion (unlimited size). 024 * 025 * @see Base45 026 * @see <a href="https://datatracker.ietf.org/doc/html/rfc9285">RFC 9285 – The Base45 Data Encoding</a> 027 * @since 1.23.0 028 */ 029public class Base45InputStream extends BaseNCodecInputStream<Base45, Base45InputStream, Base45InputStream.Builder> { 030 031 /** 032 * Builds instances of Base45InputStream. 033 */ 034 public static class Builder extends BaseNCodecInputStream.AbstracBuilder<Base45InputStream, Base45, Builder> { 035 036 /** 037 * Constructs a new instance. 038 */ 039 public Builder() { 040 // empty 041 } 042 043 @Override 044 public Base45InputStream get() { 045 return new Base45InputStream(this); 046 } 047 048 @Override 049 protected Base45 newBaseNCodec() { 050 return new Base45(); 051 } 052 } 053 054 /** 055 * Constructs a new Builder. 056 * 057 * @return A new Builder. 058 */ 059 public static Builder builder() { 060 return new Builder(); 061 } 062 063 private Base45InputStream(final Builder builder) { 064 super(builder); 065 } 066 067 /** 068 * Constructs a Base45InputStream such that all data read is Base45-decoded from the original provided InputStream. 069 * 070 * @param inputStream InputStream to wrap. 071 */ 072 public Base45InputStream(final InputStream inputStream) { 073 super(builder().setInputStream(inputStream)); 074 } 075}