001/**
002 * Java Web Archive Toolkit - Software to read and validate ARC, WARC
003 * and GZip files. (http://jwat.org/)
004 * Copyright 2011-2012 Netarkivet.dk (http://netarkivet.dk/)
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jwat.warc;
019
020import java.io.File;
021import java.util.LinkedHashMap;
022import java.util.Map;
023
024/**
025 * General configuration of <code>WarcFileWriter</code>.
026 *
027 * @author nicl
028 */
029public class WarcFileWriterConfig {
030
031    /** Standard/default max file size. */
032    public static final long DEFAULT_MAX_FILE_SIZE = 1073741824L;
033
034    /** Target directory in which to write ARC file(s). */
035    protected File targetDir;
036
037    /** Compress archive(s). */
038    protected boolean bCompression;
039
040    /** Max file size used to determine when to close the current ARC file and start writing to the next one. */
041    protected Long maxFileSize = DEFAULT_MAX_FILE_SIZE;
042
043    /** Overwrite existing file(s). */
044    public boolean bOverwrite;
045
046    /** Array of metadata. */
047    protected LinkedHashMap<String, Map.Entry<String, String>> metadata = new LinkedHashMap<String, Map.Entry<String, String>>();
048
049    /**
050     * Construct instance with largely default values, except the targetDir which is null.
051     */
052    public WarcFileWriterConfig() {
053    }
054
055    /**
056     * Construct an instance with custom values.
057     * @param targetDir target directory in which to write WARC file(s)
058     * @param bCompression compress archive(s)
059     * @param maxFileSize max file size to determine when to move on to a fresh WARC file
060     * @param bOverwrite overwrite existing file(s)
061     */
062    public WarcFileWriterConfig(File targetDir, boolean bCompression, long maxFileSize, boolean bOverwrite) {
063        this.targetDir = targetDir;
064        this.bCompression = bCompression;
065        this.maxFileSize = maxFileSize;
066        this.bOverwrite = bOverwrite;
067    }
068
069    /*
070    public void addMetadata(String key, String value) {
071        metadata.put( key, new SimpleEntry<String, String>(key, value) );
072    }
073    */
074
075}