Back to index

plt-scheme  4.2.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Package Attributes | Private Attributes | Static Private Attributes
java.lang.Short Class Reference

Instances of class Short represent primitive short values. More...

Inheritance diagram for java.lang.Short:
Inheritance graph
[legend]
Collaboration diagram for java.lang.Short:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Short (short value)
 Create a Short object representing the value of the short argument.
 Short (String s)
 Create a Short object representing the value of the argument after conversion to a short.
byte byteValue ()
 Return the value of this Short as a byte.
short shortValue ()
 Return the value of this Short.
int intValue ()
 Return the value of this Short as an int.
long longValue ()
 Return the value of this Short as a long.
float floatValue ()
 Return the value of this Short as a float.
double doubleValue ()
 Return the value of this Short as a double.
String toString ()
 Converts the Short value to a String and assumes a radix of 10.
int hashCode ()
 Return a hashcode representing this Object.
boolean equals (Object obj)
 Returns true if obj is an instance of Short and represents the same short value.
int compareTo (Short s)
 Compare two Shorts numerically by comparing their short values.
int compareTo (Object o)
 Behaves like compareTo(Short) unless the Object is not a Short.

Static Public Member Functions

static String toString (short s)
 Converts the short to a String and assumes a radix of 10.
static short parseShort (String s)
 Converts the specified String into a short.
static short parseShort (String s, int radix)
 Converts the specified String into a short using the specified radix (base).
static Short valueOf (String s, int radix)
 Creates a new Short object using the String and specified radix (base).
static Short valueOf (String s)
 Creates a new Short object using the String, assuming a radix of 10.
static Short decode (String s)
 Convert the specified String into a Short.

Static Public Attributes

static final short MIN_VALUE = (short) -32768
 The minimum value a short can represent is -32768 (or -215).
static final short MAX_VALUE = (short) 32767
 The minimum value a short can represent is 32767 (or 215).

Static Package Attributes

static final char[] digits
 Table for calculating digits, used in Character, Long, and Integer.

Private Attributes

final short value
 The primitive type short is represented by this Class object.

Static Private Attributes

static final long serialVersionUID = 7515723908773894738L
 Compatible with JDK 1.1+.

Detailed Description

Instances of class Short represent primitive short values.

Additionally, this class provides various helper functions and variables related to shorts.

Author:
Paul Fisher
John Keiser
Eric Blake ebb9@.nosp@m.emai.nosp@m.l.byu.nosp@m..edu
Since:
1.1 updated to 1.4

Definition at line 54 of file Short.java.


Constructor & Destructor Documentation

java.lang.Short.Short ( short  value) [inline]

Create a Short object representing the value of the short argument.

Parameters:
valuethe value to use

Definition at line 92 of file Short.java.

  {
    this.value = value;
  }

Here is the caller graph for this function:

java.lang.Short.Short ( String  s) [inline]

Create a Short object representing the value of the argument after conversion to a short.

Parameters:
sthe string to convert
Exceptions:
NumberFormatExceptionif the String cannot be parsed

Definition at line 104 of file Short.java.

  {
    value = parseShort(s, 10);
  }

Here is the call graph for this function:


Member Function Documentation

Return the value of this Short as a byte.

Returns:
the byte value

Reimplemented from java.lang.Number.

Definition at line 235 of file Short.java.

  {
    return (byte) value;
  }

Compare two Shorts numerically by comparing their short values.

The result is positive if the first is greater, negative if the second is greater, and 0 if the two are equal.

Parameters:
sthe Short to compare
Returns:
the comparison
Since:
1.2

Definition at line 333 of file Short.java.

  {
    return value - s.value;
  }

Here is the caller graph for this function:

int java.lang.Short.compareTo ( Object  o) [inline]

Behaves like compareTo(Short) unless the Object is not a Short.

Parameters:
othe object to compare
Returns:
the comparison
Exceptions:
ClassCastExceptionif the argument is not a Short
See also:
compareTo(Short)
Comparable
Since:
1.2

Definition at line 349 of file Short.java.

  {
    return compareTo((Short)o);
  }

Here is the call graph for this function:

static Short java.lang.Short.decode ( String  s) [inline, static]

Convert the specified String into a Short.

The String may represent decimal, hexadecimal, or octal numbers.

The extended BNF grammar is as follows:

 DecodableString:
      ( [ - ] DecimalNumber )
    | ( [ - ] ( 0x | 0X
              | # ) HexDigit { HexDigit } )
    | ( [ - ] 0 { OctalDigit } )
 DecimalNumber:
        DecimalDigit except '0' { DecimalDigit }
 DecimalDigit:
        Character.digit(d, 10) has value 0 to 9
 OctalDigit:
        Character.digit(d, 8) has value 0 to 7
 DecimalDigit:
        Character.digit(d, 16) has value 0 to 15
 

Finally, the value must be in the range MIN_VALUE to MAX_VALUE, or an exception is thrown.

Parameters:
sthe String to interpret
Returns:
the value of the String as a Short
Exceptions:
NumberFormatExceptionif s cannot be parsed as a short
NullPointerExceptionif s is null
See also:
Integer::decode(String)

Definition at line 222 of file Short.java.

  {
    int i = Integer.parseInt(s, 10, true);
    if ((short) i != i)
      throw new NumberFormatException();
    return new Short((short) i);
  }

Here is the call graph for this function:

double java.lang.Short.doubleValue ( ) [inline, virtual]

Return the value of this Short as a double.

Returns:
the double value

Implements java.lang.Number.

Definition at line 285 of file Short.java.

  {
    return value;
  }
boolean java.lang.Short.equals ( Object  obj) [inline]

Returns true if obj is an instance of Short and represents the same short value.

Parameters:
objthe object to compare
Returns:
whether these Objects are semantically equal

Definition at line 319 of file Short.java.

  {
    return obj instanceof Short && value == ((Short) obj).value;
  }

Here is the call graph for this function:

float java.lang.Short.floatValue ( ) [inline, virtual]

Return the value of this Short as a float.

Returns:
the float value

Implements java.lang.Number.

Definition at line 275 of file Short.java.

  {
    return value;
  }

Return a hashcode representing this Object.

Short's hash code is simply its value.

Returns:
this Object's hash code

Definition at line 307 of file Short.java.

  {
    return value;
  }
int java.lang.Short.intValue ( ) [inline, virtual]

Return the value of this Short as an int.

Returns:
the int value

Implements java.lang.Number.

Definition at line 255 of file Short.java.

  {
    return value;
  }
long java.lang.Short.longValue ( ) [inline, virtual]

Return the value of this Short as a long.

Returns:
the long value

Implements java.lang.Number.

Definition at line 265 of file Short.java.

  {
    return value;
  }
static short java.lang.Short.parseShort ( String  s) [inline, static]

Converts the specified String into a short.

This function assumes a radix of 10.

Parameters:
sthe String to convert
Returns:
the short value of s
Exceptions:
NumberFormatExceptionif s cannot be parsed as a short

Definition at line 130 of file Short.java.

  {
    return parseShort(s, 10);
  }

Here is the caller graph for this function:

static short java.lang.Short.parseShort ( String  s,
int  radix 
) [inline, static]

Converts the specified String into a short using the specified radix (base).

The string must not be null or empty. It may begin with an optional '-', which will negate the answer, provided that there are also valid digits. Each digit is parsed as if by Character.digit(d, radix), and must be in the range 0 to radix - 1. Finally, the result must be within MIN_VALUE to MAX_VALUE, inclusive. Unlike Double.parseDouble, you may not have a leading '+'.

Parameters:
sthe String to convert
radixthe radix (base) to use in the conversion
Returns:
the String argument converted to short
Exceptions:
NumberFormatExceptionif s cannot be parsed as a short

Definition at line 151 of file Short.java.

  {
    int i = Integer.parseInt(s, radix, false);
    if ((short) i != i)
      throw new NumberFormatException();
    return (short) i;
  }

Here is the call graph for this function:

short java.lang.Short.shortValue ( ) [inline]

Return the value of this Short.

Returns:
the short value

Reimplemented from java.lang.Number.

Definition at line 245 of file Short.java.

  {
    return value;
  }
static String java.lang.Short.toString ( short  s) [inline, static]

Converts the short to a String and assumes a radix of 10.

Parameters:
sthe short to convert to String
Returns:
the String representation of the argument

Definition at line 116 of file Short.java.

  {
    return String.valueOf((int) s);
  }
String java.lang.Short.toString ( ) [inline]

Converts the Short value to a String and assumes a radix of 10.

Returns:
the String representation of this Short

Definition at line 296 of file Short.java.

  {
    return String.valueOf((int) value);
  }
static Short java.lang.Short.valueOf ( String  s,
int  radix 
) [inline, static]

Creates a new Short object using the String and specified radix (base).

Parameters:
sthe String to convert
radixthe radix (base) to convert with
Returns:
the new Short
Exceptions:
NumberFormatExceptionif s cannot be parsed as a short
See also:
parseShort(String, int)

Definition at line 170 of file Short.java.

  {
    return new Short(parseShort(s, radix));
  }

Here is the call graph for this function:

static Short java.lang.Short.valueOf ( String  s) [inline, static]

Creates a new Short object using the String, assuming a radix of 10.

Parameters:
sthe String to convert
Returns:
the new Short
Exceptions:
NumberFormatExceptionif s cannot be parsed as a short
See also:
Short(String)
parseShort(String)

Definition at line 186 of file Short.java.

  {
    return new Short(parseShort(s, 10));
  }

Here is the call graph for this function:


Member Data Documentation

final char [] java.lang.Number.digits [static, package, inherited]
Initial value:
 {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
    'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
    'u', 'v', 'w', 'x', 'y', 'z',
  }

Table for calculating digits, used in Character, Long, and Integer.

Definition at line 68 of file Number.java.

final short java.lang.Short.MAX_VALUE = (short) 32767 [static]

The minimum value a short can represent is 32767 (or 215).

Definition at line 71 of file Short.java.

final short java.lang.Short.MIN_VALUE = (short) -32768 [static]

The minimum value a short can represent is -32768 (or -215).

Definition at line 65 of file Short.java.

final long java.lang.Short.serialVersionUID = 7515723908773894738L [static, private]

Compatible with JDK 1.1+.

Reimplemented from java.lang.Number.

Definition at line 59 of file Short.java.

final short java.lang.Short.value [private]

The primitive type short is represented by this Class object.

The immutable value of this Short.

the wrapped short

Definition at line 84 of file Short.java.


The documentation for this class was generated from the following file: