<commit_before>//
// TiffSaver.java
//

/*
OME Bio-Formats package for reading and converting biological file formats.
Copyright (C) 2005-@year@ UW-Madison LOCI and Glencoe Software, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.formats.tiff;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;

import loci.common.ByteArrayHandle;
import loci.common.RandomAccessInputStream;
import loci.common.RandomAccessOutputStream;
import loci.formats.FormatException;
import loci.formats.FormatTools;
import loci.formats.codec.CodecOptions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Parses TIFF data from an input source.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/bio-formats/src/loci/formats/tiff/TiffSaver.java">Trac</a>,
 * <a href="http://git.openmicroscopy.org/?p=bioformats.git;a=blob;f=components/bio-formats/src/loci/formats/tiff/TiffSaver.java;hb=HEAD">Gitweb</a></dd></dl>
 *
 * @author <NAME> ctrueden at wisc.edu
 * @author <NAME> egkjellman at wisc.edu
 * @author <NAME> melissa at glencoesoftware.com
 * @author <NAME> at blackcat.ca
 */
public class TiffSaver {

  // -- Constructor --

  private static final Logger LOGGER = LoggerFactory.getLogger(TiffSaver.class);

  // -- Fields --

  /** Output stream to use when saving TIFF data. */
  protected RandomAccessOutputStream out;

  /** Output filename. */
  protected String filename;

  /** Output bytes. */
  protected ByteArrayHandle bytes;

  /** Whether or not to write BigTIFF data. */
  private boolean bigTiff = false;
  private boolean sequentialWrite = false;

  /** The codec options if set. */
  private CodecOptions options;

  // -- Constructors --

  /**
   * Constructs a new TIFF saver from the given output source.
   * @param out Output stream to save TIFF data to.
   * @param filename Filename of the output stream that we may use to create
   * extra input or output streams as required.
   */
  public TiffSaver(RandomAccessOutputStream out, String filename) {
    if (out == null) {
      throw new IllegalArgumentException(
          "Output stream expected to be not-null");
    }
    if (filename == null) {
      throw new IllegalArgumentException(
          "Filename expected to be not null");
    }
    this.out = out;
    this.filename = filename;
  }

  /**<commit_msg>Re-add the TiffSaver(String) constructor.<commit_after>//
// TiffSaver.java
//

/*
OME Bio-Formats package for reading and converting biological file formats.
Copyright (C) 2005-@year@ UW-Madison LOCI and Glencoe Software, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package loci.formats.tiff;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;

import loci.common.ByteArrayHandle;
import loci.common.RandomAccessInputStream;
import loci.common.RandomAccessOutputStream;
import loci.formats.FormatException;
import loci.formats.FormatTools;
import loci.formats.codec.CodecOptions;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Parses TIFF data from an input source.
 *
 * <dl><dt><b>Source code:</b></dt>
 * <dd><a href="http://trac.openmicroscopy.org.uk/ome/browser/bioformats.git/components/bio-formats/src/loci/formats/tiff/TiffSaver.java">Trac</a>,
 * <a href="http://git.openmicroscopy.org/?p=bioformats.git;a=blob;f=components/bio-formats/src/loci/formats/tiff/TiffSaver.java;hb=HEAD">Gitweb</a></dd></dl>
 *
 * @author <NAME> ctrueden at wisc.edu
 * @author <NAME> egkjellman at wisc.edu
 * @author <NAME> melissa at glencoesoftware.com
 * @author <NAME> callan at blackcat.ca
 */
public class TiffSaver {

  // -- Constructor --

  private static final Logger LOGGER = LoggerFactory.getLogger(TiffSaver.class);

  // -- Fields --

  /** Output stream to use when saving TIFF data. */
  protected RandomAccessOutputStream out;

  /** Output filename. */
  protected String filename;

  /** Output bytes. */
  protected ByteArrayHandle bytes;

  /** Whether or not to write BigTIFF data. */
  private boolean bigTiff = false;
  private boolean sequentialWrite = false;

  /** The codec options if set. */
  private CodecOptions options;

  // -- Constructors --

  /**
   * Constructs a new TIFF saver from the given filename.
   * @param filename Filename of the output stream that we may use to create
   * extra input or output streams as required.
   */
  public TiffSaver(String filename) throws IOException {
    this(new RandomAccessOutputStream(filename), filename);
  }

  /**
   * Constructs a new TIFF saver from the given output source.
   * @param out Output stream to save TIFF data to.
   * @param filename Filename of the output stream that we may use to create
   * extra input or output streams as required.
   */
  public TiffSaver(RandomAccessOutputStream out, String filename) {
    if (out == null) {
      throw new IllegalArgumentException(
          "Output stream expected to be not-null");
    }
    if (filename == null) {
      throw new IllegalArgumentException(
          "Filename expected to be not null");
    }
    this.out = out;
    this.filename = filename;
  }

  /**
{'fraction_non_alphanumeric': 0.09898477157360407, 'fraction_numerical': 0.006270528515974918, 'mean_word_length': 3.751063829787234, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7587597', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1946, 'n_words': 693}