/*
 * 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: Byte.h,v 1.15 2003/01/11 10:39:17 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_LANG_BYTE_H
# define INCLUDE_JAKELIB2_LANG_BYTE_H

# include "Number.h"

namespace jakelib {
  namespace lang {

    /**
     * @brief An instance of this class encapsulates a single \c jbyte value.
     * Some class methods provide functions to convert strings to jbytes 
     * and vice versa.
     *
     * @class Byte
     * @version $Id: Byte.h,v 1.15 2003/01/11 10:39:17 florian Exp $
     * @author Florian 'Overflo' Wolff (florian@donuz.de)
     * @todo \c decode is not yet implemented
     */
    class Byte : public Number, Comparable
      {
      private:
	jbyte value;

      public:
	Byte(jbyte value);

	Byte(String* s);

	JAKELIB_DECLARE_CLASS(Byte);
  
	/**
	 * @brief Returns a hashcode for the integer value. 
	 *
	 * @return hash code
	 */
	int hashCode();
  
	/**
	 * @brief Returns the string representation of the Byte value.
	 *
	 * @return String representation
	 */
	String* toString();
  
	/**
	 * @brief Returns the string representation of the given jbyte value.
	 *
	 * @param value Byte value.
	 * @return String representation
	 */
	static String* toString(jbyte value);
  
	/**
	 * Returns the string representation of the given jbyte value.
	 *
	 * @param value Byte value.
	 * @param radix The radix (Character::MIN_RADIX .. Character::MAX_RADIX)
	 * @return String representation
	 */
	static String* toString(jbyte value, int radix);
  
	/**
	 * @brief Compares this object to the specified object.
	 *
	 * The result is <code>true</code> if and only if the argument is not
	 * <code>null</code> and is an <code>Byte</code> object that contains
	 * the same <code>jbyte</code> value as this object.
	 *
	 * @param   obj   the object to compare with.
	 * @return  <code>true</code> if the objects are the same;
	 *          <code>false</code> otherwise.
	 */
	jboolean equals(Object* obj);
    
	/**
	 * @brief Returns the number represented by this object converted to <tt>jbyte</tt>.
	 */
	jbyte byteValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jdouble</tt>.
	 */
	jdouble doubleValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jfloat</tt>.
	 */
	jfloat floatValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jint</tt>.
	 */
	jint intValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jlong</tt>.
	 */
	jlong longValue();

	/**
	 * @brief Returns the number represented by this object converted to <tt>jshort</tt>.
	 */
	jshort shortValue();

	static Byte* valueOf(String* str, int radix);
	static Byte* valueOf(String* str);

	static jbyte parseByte(String* str);
	static jbyte parseByte(String* str, int radix);
  
	int compareTo(Byte* obj);
	int compareTo(Object* obj);

/* 	static Byte decode(String* str); */

	static const jbyte MAX_VALUE;
	static const jbyte MIN_VALUE;
      };

  }
}


#endif

