moka.lang
Class Long

java.lang.Object
  |
  +--moka.lang.Object
        |
        +--moka.lang.Long

public class Long
extends Object

The Long class wraps a value of the primitive type long in an object. An object of type long contains a single field whose type is long.

In addition, this class provides several methods for converting an long to a String and a String to an long, as well as other constants and methods useful when dealing with an long.

Since:
MDK1.0a

Field Summary
static long MAX_VALUE
          A constant holding the maximum value a long can have, 263-1.
static long MIN_VALUE
          A constant holding the minimum value a long can have, -263.
 
Constructor Summary
Long(long value)
          Constructs a newly allocated Long object that represents the primitive long argument.
Long(moka.lang.String s)
          Constructs a newly allocated Long object that represents the value represented by the string.
 
Method Summary
 byte byteValue()
          Returns the value of this Long as a byte.
 double doubleValue()
          Returns the value of this Long as a double.
 boolean equals(moka.lang.Object obj)
          Compares this object to the specified object.
 int intValue()
          Returns the value of this Long as an int.
static boolean isLong(moka.lang.String str)
          Checks if the specified string is a decimal representation of a long integer.
 long longValue()
          Returns the value of this Long as an long.
static long parseLong(moka.lang.String s)
          Parses the string argument as a signed decimal long.
 short shortValue()
          Returns the value of this Long as a short.
 moka.lang.String toString()
          Returns a String object representing this Long's value.
 
Methods inherited from class moka.lang.Object
finalize, getClassName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final long MIN_VALUE
A constant holding the minimum value a long can have, -263.


MAX_VALUE

public static final long MAX_VALUE
A constant holding the maximum value a long can have, 263-1.

Constructor Detail

Long

public Long(long value)
Constructs a newly allocated Long object that represents the primitive long argument.

Parameters:
value - the value to be represented by the long.

Long

public Long(moka.lang.String s)
Constructs a newly allocated Long object that represents the value represented by the string. The string is converted to an long in exactly the manner used by the parseLong method.

Parameters:
s - the String to be converted to an Long.
Method Detail

toString

public moka.lang.String toString()
Returns a String object representing this Long's value. The value is converted to signed decimal representation and returned as a string, exactly as if the long value were given as an argument to the valueOf method of String.

Overrides:
toString in class Object
Returns:
a string representation of the value of this object.

equals

public boolean equals(moka.lang.Object obj)
Compares this object to the specified object. The result is true if and only if the argument is not null and is an Long object that contains the same long value as this object.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with.
Returns:
true if the objects are the same; false otherwise.

longValue

public long longValue()
Returns the value of this Long as an long.


parseLong

public static long parseLong(moka.lang.String s)
Parses the string argument as a signed decimal long. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned. The string argument is finalized before the method returns.

Parameters:
s - a String containing the long representation to be parsed
Returns:
the long value represented by the argument in decimal.

intValue

public int intValue()
Returns the value of this Long as an int. This may involve rounding or truncation.

Returns:
the numeric value represented by this object after conversion to type int.

doubleValue

public double doubleValue()
Returns the value of this Long as a double. This may involve rounding.

Returns:
the numeric value represented by this object after conversion to type double.

byteValue

public byte byteValue()
Returns the value of this Long as a byte. This may involve rounding or truncation.

Returns:
the numeric value represented by this object after conversion to type byte.

shortValue

public short shortValue()
Returns the value of this Long as a short. This may involve rounding or truncation.

Returns:
the numeric value represented by this object after conversion to type short.

isLong

public static boolean isLong(moka.lang.String str)
Checks if the specified string is a decimal representation of a long integer.

Parameters:
str - The string to verify
Returns:
true if the specified string is a decimal representation of a long integer, false otherwize.