<commit_before>/*
 * Copyright (C) 2014-2021 <NAME> (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.helger.web.fileupload.io;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.state.ICloseable;

/**
 * An input stream, which limits its data size. This stream is used, if the
 * content length is unknown.
 */
public abstract class AbstractLimitedInputStream extends FilterInputStream implements ICloseable
{
  /**
   * The maximum size of an item, in bytes.
   */
  private final long m_nSizeMax;
  /**
   * The current number of bytes.
   */
  private long m_nCount;
  /**
   * Whether this stream is already closed.
   */
  private boolean m_bClosed;

  /**
   * Creates a new instance.
   *
   * @param aIS
   *        The input stream, which shall be limited.<commit_msg>Changed base class<commit_after>/*
 * Copyright (C) 2014-2021 <NAME> (www.helger.com)
 * philip[at]helger[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.helger.web.fileupload.io;

import java.io.IOException;
import java.io.InputStream;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.io.stream.WrappedInputStream;
import com.helger.commons.state.ICloseable;

/**
 * An input stream, which limits its data size. This stream is used, if the
 * content length is unknown.
 */
public abstract class AbstractLimitedInputStream extends WrappedInputStream implements ICloseable
{
  /**
   * The maximum size of an item, in bytes.
   */
  private final long m_nSizeMax;
  /**
   * The current number of bytes.
   */
  private long m_nCount;
  /**
   * Whether this stream is already closed.
   */
  private boolean m_bClosed;

  /**
   * Creates a new instance.
   *
   * @param aIS
   *        The input stream, which shall be limited.
{'fraction_non_alphanumeric': 0.08840673575129533, 'fraction_numerical': 0.007772020725388601, 'mean_word_length': 3.529325513196481, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7491025', 'n_tokens_mistral': 881, 'n_tokens_neox': 864, 'n_words': 339}