00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _DECAF_LANG_SHORT_H_
00019 #define _DECAF_LANG_SHORT_H_
00020
00021 #include <decaf/util/Config.h>
00022 #include <decaf/lang/Number.h>
00023 #include <decaf/lang/Comparable.h>
00024 #include <decaf/lang/exceptions/NumberFormatException.h>
00025 #include <string>
00026
00027 namespace decaf{
00028 namespace lang{
00029
00030 class DECAF_API Short : public Number,
00031 public Comparable<Short>,
00032 public Comparable<short> {
00033 private:
00034
00035
00036 short value;
00037
00038 public:
00039
00041 static const int SIZE;
00042
00044 static const short MAX_VALUE;
00045
00047 static const short MIN_VALUE;
00048
00049 public:
00050
00054 Short( short value );
00055
00062 Short( const std::string& value );
00063
00064 virtual ~Short() {}
00065
00074 virtual int compareTo( const Short& s ) const;
00075
00079 bool equals( const Short& s ) const {
00080 return this->value == s.value;
00081 }
00082
00088 virtual bool operator==( const Short& s ) const {
00089 return this->value == s.value;
00090 }
00091
00098 virtual bool operator<( const Short& s ) const {
00099 return this->value < s.value;
00100 }
00101
00110 virtual int compareTo( const short& s ) const;
00111
00115 bool equals( const short& s ) const {
00116 return this->value == s;
00117 }
00118
00124 virtual bool operator==( const short& s ) const {
00125 return this->value == s;
00126 }
00127
00134 virtual bool operator<( const short& s ) const {
00135 return this->value < s;
00136 }
00137
00141 std::string toString() const;
00142
00147 virtual double doubleValue() const {
00148 return (double)this->value;
00149 }
00150
00155 virtual float floatValue() const {
00156 return (float)this->value;
00157 }
00158
00163 virtual unsigned char byteValue() const {
00164 return (unsigned char)this->value;
00165 }
00166
00171 virtual short shortValue() const {
00172 return this->value;
00173 }
00174
00179 virtual int intValue() const {
00180 return (int)this->value;
00181 }
00182
00187 virtual long long longValue() const {
00188 return (long long)this->value;
00189 }
00190
00191 public:
00192
00196 static std::string toString( short value );
00197
00213 static Short decode( const std::string& value );
00214
00221 static short reverseBytes( short value );
00222
00246 static short parseShort( const std::string& s, int radix );
00247
00260 static short parseShort( const std::string& s );
00261
00267 static Short valueOf( short value );
00268
00279 static Short valueOf( const std::string& value );
00280
00293 static Short valueOf( const std::string& value, int radix );
00294
00295 };
00296
00297 }}
00298
00299 #endif