// -*- c++ -*-

/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: DateFormat.h,v 1.3 2003/09/20 12:38:02 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_TEXT_DATEFORMAT_H
# define INCLUDE_JAKELIB2_TEXT_DATEFORMAT_H

#include "Format.h"
#include "../util/Date.h"

namespace jakelib {
  namespace text  {
    class Format;

    /**
     * This abstract class is a class for date/time formatting.
     * All subclasses have the ability to format given Dates (Date -> String) and
     * in the other direction parse given Strings (String -> Date).
     *
     * @class DateFormat
     * @version $Id: DateFormat.h,v 1.3 2003/09/20 12:38:02 florian Exp $
     * @author Heiko Feldker (heikofkr@cs.tu-berlin.de)
     */

    class DateFormat : public jakelib::text::Format
    {
    public:
	/** Available format-styles, default: MEDIUM. */
	typedef enum {
	    FULL=0, 
	    LONG=1, 
	    MEDIUM=2, 
	    SHORT=3, 
	    DEFAULT=MEDIUM
	} DateStyle;
	
	/**
	 * This method formats a \c Date into a \c String.
	 * 
	 * @param date The \c Date to format.
	 *
	 * @return The formatted \c String.
	 */
	virtual jakelib::lang::String* format(jakelib::util::Date *date); 

	/**
	 * This method formats an \c Object into a \c StringBuffer.
	 * All created text is appended to the given StringBuffer.
         * For more information about the FieldPosition,
	 * please refer to the original Java-API doc.
	 *
	 * @param obj The \c Object to format. This has to be a date!
	 * @param sbuf The \c StringBuffer to append the formatted date to. 
	 * @param fp The \c FieldPosition to use. 
	 *
	 * @return The formatted \c StringBuffer.
	 */
	virtual jakelib::lang::StringBuffer* format(jakelib::lang::Object *obj,
                                                    jakelib::lang::StringBuffer *sbuf, 
						    jakelib::text::FieldPosition *fp);

	/** abstract! */
	virtual jakelib::lang::StringBuffer* format(jakelib::util::Date *date,
                                                    jakelib::lang::StringBuffer *sbuf, 
						    jakelib::text::FieldPosition *fp) = 0;
	
    protected:
	/**
	 * Initialization (construction) of a new DateFormat object. 
	 */
	DateFormat();
	
    private:
	JAKELIB_DECLARE_CLASS(DateFormat);
    };

    JAKELIB_DECLARE_ARRAY(DateFormat);
  }
}
#endif


