4925 |
08 May 09 |
nicklas |
1 |
/** |
4925 |
08 May 09 |
nicklas |
$Id$ |
4925 |
08 May 09 |
nicklas |
3 |
|
4925 |
08 May 09 |
nicklas |
Copyright (C) 2009 Nicklas Nordborg |
4925 |
08 May 09 |
nicklas |
5 |
|
4925 |
08 May 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4925 |
08 May 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4925 |
08 May 09 |
nicklas |
8 |
|
4925 |
08 May 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4925 |
08 May 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4925 |
08 May 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4925 |
08 May 09 |
nicklas |
of the License, or (at your option) any later version. |
4925 |
08 May 09 |
nicklas |
13 |
|
4925 |
08 May 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4925 |
08 May 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4925 |
08 May 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4925 |
08 May 09 |
nicklas |
GNU General Public License for more details. |
4925 |
08 May 09 |
nicklas |
18 |
|
4925 |
08 May 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4925 |
08 May 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4925 |
08 May 09 |
nicklas |
21 |
*/ |
4925 |
08 May 09 |
nicklas |
22 |
package net.sf.basedb.util.export.spotdata; |
4925 |
08 May 09 |
nicklas |
23 |
|
4925 |
08 May 09 |
nicklas |
24 |
import net.sf.basedb.util.formatter.Formatter; |
4925 |
08 May 09 |
nicklas |
25 |
|
4925 |
08 May 09 |
nicklas |
26 |
/** |
4925 |
08 May 09 |
nicklas |
Formatter implementation that formats an exportable field |
4925 |
08 May 09 |
nicklas |
by returning the column title. See {@link ExportableField#getTitle()}. |
4925 |
08 May 09 |
nicklas |
<p> |
4925 |
08 May 09 |
nicklas |
Note! Do not confuse this formatter with the formatter returned |
4925 |
08 May 09 |
nicklas |
from {@link ExportableField#getFormatter()}. That formatter is about |
4925 |
08 May 09 |
nicklas |
formatting the exported values, while this formatter is about |
4925 |
08 May 09 |
nicklas |
formatting the column header. |
4925 |
08 May 09 |
nicklas |
34 |
|
4925 |
08 May 09 |
nicklas |
@author Nicklas |
4925 |
08 May 09 |
nicklas |
@version 2.12 |
4925 |
08 May 09 |
nicklas |
@base.modified $Date$ |
4925 |
08 May 09 |
nicklas |
38 |
*/ |
4925 |
08 May 09 |
nicklas |
39 |
public class ExportableFieldFormatter |
4925 |
08 May 09 |
nicklas |
40 |
implements Formatter<ExportableField> |
4925 |
08 May 09 |
nicklas |
41 |
{ |
4925 |
08 May 09 |
nicklas |
42 |
|
4925 |
08 May 09 |
nicklas |
43 |
private String nullValue = ""; |
4925 |
08 May 09 |
nicklas |
44 |
|
4925 |
08 May 09 |
nicklas |
45 |
/** |
4925 |
08 May 09 |
nicklas |
Create a new formatter. Null values are formatted as an empty string. |
4925 |
08 May 09 |
nicklas |
47 |
*/ |
4925 |
08 May 09 |
nicklas |
48 |
public ExportableFieldFormatter() |
4925 |
08 May 09 |
nicklas |
49 |
{} |
4925 |
08 May 09 |
nicklas |
50 |
|
4925 |
08 May 09 |
nicklas |
51 |
/** |
4925 |
08 May 09 |
nicklas |
Create a new formatter. |
4925 |
08 May 09 |
nicklas |
@param nullValue The string to return if a null item is |
4925 |
08 May 09 |
nicklas |
passed to {@link #format(ExportableField)} |
4925 |
08 May 09 |
nicklas |
55 |
*/ |
4925 |
08 May 09 |
nicklas |
56 |
public ExportableFieldFormatter(String nullValue) |
4925 |
08 May 09 |
nicklas |
57 |
{ |
4925 |
08 May 09 |
nicklas |
58 |
this.nullValue = nullValue; |
4925 |
08 May 09 |
nicklas |
59 |
} |
4925 |
08 May 09 |
nicklas |
60 |
|
4925 |
08 May 09 |
nicklas |
61 |
|
4925 |
08 May 09 |
nicklas |
62 |
/* |
4925 |
08 May 09 |
nicklas |
From the Formatter interface |
4925 |
08 May 09 |
nicklas |
64 |
------------------------------------------- |
4925 |
08 May 09 |
nicklas |
65 |
*/ |
4925 |
08 May 09 |
nicklas |
66 |
@Override |
4925 |
08 May 09 |
nicklas |
67 |
public String format(ExportableField value) |
4925 |
08 May 09 |
nicklas |
68 |
{ |
4925 |
08 May 09 |
nicklas |
69 |
return value == null ? nullValue : value.getTitle(); |
4925 |
08 May 09 |
nicklas |
70 |
} |
4925 |
08 May 09 |
nicklas |
71 |
/** |
4925 |
08 May 09 |
nicklas |
@throws UnsupportedOperationException Always |
4925 |
08 May 09 |
nicklas |
73 |
*/ |
4925 |
08 May 09 |
nicklas |
74 |
@Override |
4925 |
08 May 09 |
nicklas |
75 |
public ExportableField parseString(String value) |
4925 |
08 May 09 |
nicklas |
76 |
{ |
4925 |
08 May 09 |
nicklas |
77 |
throw new UnsupportedOperationException("parseString: " + value); |
4925 |
08 May 09 |
nicklas |
78 |
} |
4925 |
08 May 09 |
nicklas |
79 |
// ------------------------------------------- |
4925 |
08 May 09 |
nicklas |
80 |
|
4925 |
08 May 09 |
nicklas |
81 |
} |