5212 |
12 Jan 10 |
nicklas |
1 |
/** |
5212 |
12 Jan 10 |
nicklas |
$Id$ |
5212 |
12 Jan 10 |
nicklas |
3 |
|
5212 |
12 Jan 10 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
5212 |
12 Jan 10 |
nicklas |
5 |
|
5212 |
12 Jan 10 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5212 |
12 Jan 10 |
nicklas |
Available at http://base.thep.lu.se/ |
5212 |
12 Jan 10 |
nicklas |
8 |
|
5212 |
12 Jan 10 |
nicklas |
BASE is free software; you can redistribute it and/or |
5212 |
12 Jan 10 |
nicklas |
modify it under the terms of the GNU General Public License |
5212 |
12 Jan 10 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5212 |
12 Jan 10 |
nicklas |
of the License, or (at your option) any later version. |
5212 |
12 Jan 10 |
nicklas |
13 |
|
5212 |
12 Jan 10 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5212 |
12 Jan 10 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5212 |
12 Jan 10 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5212 |
12 Jan 10 |
nicklas |
GNU General Public License for more details. |
5212 |
12 Jan 10 |
nicklas |
18 |
|
5212 |
12 Jan 10 |
nicklas |
You should have received a copy of the GNU General Public License |
5212 |
12 Jan 10 |
nicklas |
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 |
File name generator implementation that uses the suggested file name. |
5212 |
12 Jan 10 |
nicklas |
The implementation returns the suggested file name after making sure |
5212 |
12 Jan 10 |
nicklas |
that it is unique. Non-unique suggestions are transformed with a simple |
5212 |
12 Jan 10 |
nicklas |
algorithm that adds a sequence number to the file name. Eg. if the file |
5212 |
12 Jan 10 |
nicklas |
name 'example.txt' is suggested three times, this generator will return |
5212 |
12 Jan 10 |
nicklas |
'example.txt', 'example-2.txt', 'example-3.txt'. |
5212 |
12 Jan 10 |
nicklas |
31 |
|
5212 |
12 Jan 10 |
nicklas |
@author Nicklas |
5212 |
12 Jan 10 |
nicklas |
@version 2.15 |
5212 |
12 Jan 10 |
nicklas |
@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 |
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 |
} |