src/core/net/sf/basedb/util/bfs/SuggestedFilenameGenerator.java

Code
Comments
Other
Rev Date Author Line
5212 12 Jan 10 nicklas 1 /**
5212 12 Jan 10 nicklas 2   $Id$
5212 12 Jan 10 nicklas 3
5212 12 Jan 10 nicklas 4   Copyright (C) 2009 Nicklas Nordborg
5212 12 Jan 10 nicklas 5
5212 12 Jan 10 nicklas 6   This file is part of BASE - BioArray Software Environment.
5212 12 Jan 10 nicklas 7   Available at http://base.thep.lu.se/
5212 12 Jan 10 nicklas 8
5212 12 Jan 10 nicklas 9   BASE is free software; you can redistribute it and/or
5212 12 Jan 10 nicklas 10   modify it under the terms of the GNU General Public License
5212 12 Jan 10 nicklas 11   as published by the Free Software Foundation; either version 3
5212 12 Jan 10 nicklas 12   of the License, or (at your option) any later version.
5212 12 Jan 10 nicklas 13
5212 12 Jan 10 nicklas 14   BASE is distributed in the hope that it will be useful,
5212 12 Jan 10 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
5212 12 Jan 10 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5212 12 Jan 10 nicklas 17   GNU General Public License for more details.
5212 12 Jan 10 nicklas 18
5212 12 Jan 10 nicklas 19   You should have received a copy of the GNU General Public License
5212 12 Jan 10 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
5212 12 Jan 10 nicklas 21 */
5212 12 Jan 10 nicklas 22 package net.sf.basedb.util.bfs;
5212 12 Jan 10 nicklas 23
5212 12 Jan 10 nicklas 24 /**
5212 12 Jan 10 nicklas 25   File name generator implementation that uses the suggested file name.
5212 12 Jan 10 nicklas 26   The implementation returns the suggested file name after making sure 
5212 12 Jan 10 nicklas 27   that it is unique. Non-unique suggestions are transformed with a simple
5212 12 Jan 10 nicklas 28   algorithm that adds a sequence number to the file name. Eg. if the file
5212 12 Jan 10 nicklas 29   name 'example.txt' is suggested three times, this generator will return
5212 12 Jan 10 nicklas 30   'example.txt', 'example-2.txt', 'example-3.txt'.
5212 12 Jan 10 nicklas 31
5212 12 Jan 10 nicklas 32   @author Nicklas
5212 12 Jan 10 nicklas 33   @version 2.15
5212 12 Jan 10 nicklas 34   @base.modified $Date$
5212 12 Jan 10 nicklas 35 */
5212 12 Jan 10 nicklas 36 public class SuggestedFilenameGenerator
5212 12 Jan 10 nicklas 37   extends AbstractFilenameGenerator<Object>
5212 12 Jan 10 nicklas 38 {
5212 12 Jan 10 nicklas 39
5212 12 Jan 10 nicklas 40   public SuggestedFilenameGenerator()
5212 12 Jan 10 nicklas 41   {}
5212 12 Jan 10 nicklas 42   
5212 12 Jan 10 nicklas 43   /*
5212 12 Jan 10 nicklas 44     From the FilenameGenerator interface
5212 12 Jan 10 nicklas 45     ------------------------------------
5212 12 Jan 10 nicklas 46   */
5212 12 Jan 10 nicklas 47   @Override
5212 12 Jan 10 nicklas 48   public String getNextFilename(Object owner, String suggestedFilename)
5212 12 Jan 10 nicklas 49   {
5212 12 Jan 10 nicklas 50     return makeUnique(suggestedFilename);
5212 12 Jan 10 nicklas 51   }
5212 12 Jan 10 nicklas 52   // -----------------------------------  
5212 12 Jan 10 nicklas 53 }