src/core/net/sf/basedb/util/formatter/Formatter.java

Code
Comments
Other
Rev Date Author Line
2733 16 Oct 06 nicklas 1 /**
2733 16 Oct 06 nicklas 2   $Id$
2733 16 Oct 06 nicklas 3
3675 16 Aug 07 jari 4   Copyright (C) 2006 Nicklas Nordborg
2733 16 Oct 06 nicklas 5
2733 16 Oct 06 nicklas 6   This file is part of BASE - BioArray Software Environment.
2733 16 Oct 06 nicklas 7   Available at http://base.thep.lu.se/
2733 16 Oct 06 nicklas 8
2733 16 Oct 06 nicklas 9   BASE is free software; you can redistribute it and/or
2733 16 Oct 06 nicklas 10   modify it under the terms of the GNU General Public License
4479 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
2733 16 Oct 06 nicklas 12   of the License, or (at your option) any later version.
2733 16 Oct 06 nicklas 13
2733 16 Oct 06 nicklas 14   BASE is distributed in the hope that it will be useful,
2733 16 Oct 06 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
2733 16 Oct 06 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2733 16 Oct 06 nicklas 17   GNU General Public License for more details.
2733 16 Oct 06 nicklas 18
2733 16 Oct 06 nicklas 19   You should have received a copy of the GNU General Public License
4515 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
2733 16 Oct 06 nicklas 21 */
2942 22 Nov 06 nicklas 22 package net.sf.basedb.util.formatter;
2733 16 Oct 06 nicklas 23
2733 16 Oct 06 nicklas 24 /**
2733 16 Oct 06 nicklas 25    A <code>Formatter</code> formats an object to a string suitable for
2942 22 Nov 06 nicklas 26    output in a client application. The formatter may optionally also do
2942 22 Nov 06 nicklas 27    the reverse, ie. parse a string to an object.
2733 16 Oct 06 nicklas 28
2733 16 Oct 06 nicklas 29   @author nicklas
2733 16 Oct 06 nicklas 30   @version 2.0
2733 16 Oct 06 nicklas 31   @base.modified $Date$
2733 16 Oct 06 nicklas 32 */
2733 16 Oct 06 nicklas 33 public interface Formatter<T>
2733 16 Oct 06 nicklas 34 {
2733 16 Oct 06 nicklas 35
2733 16 Oct 06 nicklas 36   /**
2733 16 Oct 06 nicklas 37     Format a value by converting it to a string.
2733 16 Oct 06 nicklas 38     @param value The value to format
2733 16 Oct 06 nicklas 39     @return A formatted string
2733 16 Oct 06 nicklas 40   */
2733 16 Oct 06 nicklas 41   public String format(T value);
2733 16 Oct 06 nicklas 42
2942 22 Nov 06 nicklas 43   /**
5432 29 Sep 10 nicklas 44     Parse a string and return a value of the correct type. A null
5432 29 Sep 10 nicklas 45     input string should (unless otherwise documented by a specific
5432 29 Sep 10 nicklas 46     formatter implementation) be allowed and may return null or
5432 29 Sep 10 nicklas 47     any other "default" value.
5432 29 Sep 10 nicklas 48     
2942 22 Nov 06 nicklas 49     @param value The string to parse
2942 22 Nov 06 nicklas 50     @return An object
2942 22 Nov 06 nicklas 51     @since 2.2
2942 22 Nov 06 nicklas 52   */
2942 22 Nov 06 nicklas 53   public T parseString(String value);
2942 22 Nov 06 nicklas 54   
2733 16 Oct 06 nicklas 55 }