/*
 * 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: Boolean.h,v 1.15 2003/08/27 15:38:13 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_LANG_BOOLEAN_H
# define INCLUDE_JAKELIB2_LANG_BOOLEAN_H

namespace jakelib {
  namespace lang {

    /**
     * @brief  An instance of this class encapsulates a single \c jboolean value.
     * Methods are provided to convert strings to \c Boolean and vice versa.
     *
     * @class Boolean
     * @version $Id: Boolean.h,v 1.15 2003/08/27 15:38:13 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     */
    class Boolean : public Object
      {
      private:
	/** @brief The actual value of this \c Boolean */
	jboolean value;

      public:
	/** @brief An instance of \c Boolean with the value \c true */
	static Boolean* TRUE_VALUE;

	/** @brief An instance of \c Boolean with the value \c true */
	static Boolean* FALSE_VALUE;

	/**
	 * @brief Constructs a new \c Boolean with the given jboolean value.
	 *
	 * @param value The jboolean value (\c true or \c false).
	 */
	Boolean(jboolean value);

	/**
	 * @brief Constructs a new \c Boolean from a given \c String.
	 *
	 *  If \c str equals '\c true'
	 * (case is ignored) the new \c Boolean will have the value 
	 * \c true. Otherwise it will be \c false.
	 *
	 * @param str The string to be converted to \c Boolean
	 */
	Boolean(String* str);

	/**
	 * @brief Returns the jboolean value this instance represents.
	 */
	jboolean booleanValue();

	/**
	 * @brief Converts a \c String to \c Boolean.
	 *
	 * If \c str equals '\c true'
	 * (case is ignored) the new \c Boolean will have the value 
	 * \c true. Otherwise it will be \c false.
	 */
	static Boolean* valueOf(String* str);

	/**
	 * @brief Returns a \c String representation of this \c Boolean.
	 *
	 * If the boolean value is \c true '\c true' is returned, otherwise
	 * '\c false'.
	 */
	String* toString();

	/**
	 * @brief Returns a \c String representation of the given boolean value.
	 *
	 * If the boolean value is \c true '\c true' is returned, otherwise
	 * '\c false'.
	 */
	static String* toString(jboolean value);

	/**
	 * @brief Returns a hash code for this \c Boolean.
	 */
	int hashCode();

	/**
	 * @brief Compares this \c Boolean to the given \c Object.
	 *
	 * Returns \c true if and only if the given \c Object 
	 * is an instance of \c Boolean and has the same jboolean
	 * value.
	 */
	jboolean equals(Object* obj);

	/**
	 * @brief Converts the given \c String to the primitive type jboolean.
	 *
	 * If \c str equals '\c true'
	 * (case is ignored) \c true is returned. Otherwise \c false will
	 * be returned.
	 */
	static jboolean toBoolean(String* str);

	/**
	 * @brief Converts the given string to the primitive type jboolean.
	 *
	 * If \c str equals '\c true'
	 * (case is ignored) \c true is returned. Otherwise \c false will
	 * be returned.
	 */
	static jboolean toBoolean(const char* str);

        /**
         * @brief Called by \c Object::initJakelib2().
         * Do not use otherwise.
         */
        static void initBooleanClass();

	JAKELIB_DECLARE_CLASS(Boolean);
      };
  }
}

#endif

