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;
021
022/**
023 * Simple WARC file naming implementation used for writing to a single file only.
024 *
025 * @author nicl
026 */
027public class WarcFileNamingSingleFile implements WarcFileNaming {
028
029    /** File name to use. */
030    protected String filename;
031
032    /**
033     * Construct a new instance with the filename to return.
034     * @param filename filename to return
035     */
036    public WarcFileNamingSingleFile(String filename) {
037        if (filename == null) {
038            throw new IllegalArgumentException("filename argument null");
039        }
040        this.filename = filename;
041    }
042
043    /**
044     * Construct a new instance with the file whose filename to return.
045     * @param file file whose filename to return
046     */
047    public WarcFileNamingSingleFile(File file) {
048        if (file == null) {
049            throw new IllegalArgumentException("file argument null");
050        }
051        filename = file.getName();
052    }
053
054    @Override
055    public boolean supportMultipleFiles() {
056        return false;
057    }
058
059    @Override
060    public String getFilename(int sequenceNr, boolean bCompressed) {
061        return filename;
062    }
063
064}