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.arc; 019 020import java.io.File; 021 022/** 023 * Simple ARC file naming implementation used for writing to a single file only. 024 * Ignores sequenceNr and bCompressed method arguments. 025 * 026 * @author nicl 027 */ 028public class ArcFileNamingSingleFile implements ArcFileNaming { 029 030 /** File name to use. */ 031 protected String filename; 032 033 /** 034 * Construct a new instance with the filename to return. 035 * @param filename filename to return 036 */ 037 public ArcFileNamingSingleFile(String filename) { 038 if (filename == null) { 039 throw new IllegalArgumentException("filename argument null"); 040 } 041 this.filename = filename; 042 } 043 044 /** 045 * Construct a new instance with the file whose filename to return. 046 * @param file file whose filename to return 047 */ 048 public ArcFileNamingSingleFile(File file) { 049 if (file == null) { 050 throw new IllegalArgumentException("file argument null"); 051 } 052 filename = file.getName(); 053 } 054 055 @Override 056 public boolean supportMultipleFiles() { 057 return false; 058 } 059 060 /** 061 * Just returns the filename used to construct this object. Ignores sequenceNr and bCompressed arguments. 062 * @param sequenceNr sequence number to use 063 * @param bCompressed is the file compressed or not 064 * @return the file name to use 065 */ 066 public String getFilename(int sequenceNr, boolean bCompressed) { 067 return filename; 068 } 069 070}