// -*- 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: ChoiceFormat.h,v 1.9 2003/09/13 10:29:03 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_TEXT_CHOICEFORMAT_H
# define INCLUDE_JAKELIB2_TEXT_CHOICEFORMAT_H

#include "NumberFormat.h"

namespace jakelib {
  namespace text  {
    class NumberFormat;

    class ChoiceFormat : public jakelib::text::NumberFormat
    {
    public:

      ChoiceFormat(jakelib::lang::String* newPattern);

      ChoiceFormat(jdoubles* choiceLimits, jakelib::lang::Strings* choiceFormats);

      virtual void applyPattern(jakelib::lang::String* newPattern);

      virtual jboolean equals(jakelib::lang::Object* obj);

      virtual jakelib::lang::StringBuffer* format(jlong number,
                                                  jakelib::lang::StringBuffer *sbuf,
                                                  jakelib::text::FieldPosition* fp);

      virtual jakelib::lang::StringBuffer* format(jdouble number,
                                                  jakelib::lang::StringBuffer *sbuf,
                                                  jakelib::text::FieldPosition* fp);

      virtual jakelib::lang::Objects* getFormats();

      virtual jdoubles* getLimits();

      virtual jint hashCode();

      static  jdouble nextDouble(jdouble d);

      static  jdouble nextDouble(jdouble d, jboolean next);

      virtual jakelib::lang::Number* parse(jakelib::lang::String* str,
                                           jakelib::text::ParsePosition* pos);

      static jdouble previousDouble(jdouble d);

      virtual void setChoices(jdoubles* choiceLimits, jakelib::lang::Strings* choiceFormats);

      virtual jakelib::lang::String* toPattern();

    private:

      void quoteString(jakelib::lang::StringBuffer* dest, jakelib::lang::String* text);

      jakelib::lang::Strings* choiceFormats;

      jdoubles* choiceLimits;

      static const jint mantissaBits;

      static const jint exponentBits;

      static const jlong serialVersionUID;

      JAKELIB_DECLARE_CLASS(ChoiceFormat);
    };

    JAKELIB_DECLARE_ARRAY(ChoiceFormat);
  }
}
#endif


