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 * http://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.logging.log4j.io.internal; 019 020import java.io.BufferedInputStream; 021import java.io.IOException; 022import java.io.InputStream; 023import java.nio.charset.Charset; 024 025import org.apache.logging.log4j.Level; 026import org.apache.logging.log4j.Marker; 027import org.apache.logging.log4j.io.LoggerInputStream; 028import org.apache.logging.log4j.spi.ExtendedLogger; 029 030/** 031 * Internal class that exists primiarly to allow location calculations to work. 032 * @since 2.12 033 */ 034public class InternalBufferedInputStream extends BufferedInputStream { 035 private static final String FQCN = InternalBufferedInputStream.class.getName(); 036 037 public InternalBufferedInputStream(final InputStream in, final Charset charset, final ExtendedLogger logger, 038 final String fqcn, final Level level, final Marker marker) { 039 super(new InternalInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker)); 040 } 041 042 public InternalBufferedInputStream(final InputStream in, final Charset charset, final int size, 043 final ExtendedLogger logger, final String fqcn, final Level level, 044 final Marker marker) { 045 super(new InternalInputStream(in, charset, logger, fqcn == null ? FQCN : fqcn, level, marker), size); 046 } 047 048 @Override 049 public void close() throws IOException { 050 super.close(); 051 } 052 053 @Override 054 public synchronized int read() throws IOException { 055 return super.read(); 056 } 057 058 @Override 059 public int read(final byte[] b) throws IOException { 060 return super.read(b, 0, b.length); 061 } 062 063 @Override 064 public synchronized int read(final byte[] b, final int off, final int len) throws IOException { 065 return super.read(b, off, len); 066 } 067 068 @Override 069 public String toString() { 070 return "{stream=" + this.in + '}'; 071 } 072}