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.Byte Class Reference

Instances of class Byte represent primitive byte values. More...

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

List of all members.

Public Member Functions

 Byte (byte value)
 Create a Byte object representing the value of the byte argument.
 Byte (String s)
 Create a Byte object representing the value specified by the String argument.
byte byteValue ()
 Return the value of this Byte.
short shortValue ()
 Return the value of this Byte as a short.
int intValue ()
 Return the value of this Byte as an int.
long longValue ()
 Return the value of this Byte as a long.
float floatValue ()
 Return the value of this Byte as a float.
double doubleValue ()
 Return the value of this Byte as a double.
String toString ()
 Converts the Byte 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 Byte and represents the same byte value.
int compareTo (Byte b)
 Compare two Bytes numerically by comparing their byte values.
int compareTo (Object o)
 Behaves like compareTo(Byte) unless the Object is not a Byte.

Static Public Member Functions

static String toString (byte b)
 Converts the byte to a String and assumes a radix of 10.
static byte parseByte (String s)
 Converts the specified String into a byte.
static byte parseByte (String s, int radix)
 Converts the specified String into an int using the specified radix (base).
static Byte valueOf (String s, int radix)
 Creates a new Byte object using the String and specified radix (base).
static Byte valueOf (String s)
 Creates a new Byte object using the String, assuming a radix of 10.
static Byte decode (String s)
 Convert the specified String into a Byte.

Static Public Attributes

static final byte MIN_VALUE = -128
 The minimum value a byte can represent is -128 (or -27).
static final byte MAX_VALUE = 127
 The maximum value a byte can represent is 127 (or 27 - 1).

Static Package Attributes

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

Private Attributes

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

Static Private Attributes

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

Detailed Description

Instances of class Byte represent primitive byte values.

Additionally, this class provides various helper functions and variables useful to bytes.

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

Definition at line 55 of file Byte.java.


Constructor & Destructor Documentation

java.lang.Byte.Byte ( byte  value) [inline]

Create a Byte object representing the value of the byte argument.

Parameters:
valuethe value to use

Definition at line 93 of file Byte.java.

  {
    this.value = value;
  }

Here is the caller graph for this function:

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

Create a Byte object representing the value specified by the String argument.

Parameters:
sthe string to convert
Exceptions:
NumberFormatExceptionif the String does not contain a byte
See also:
valueOf(String)

Definition at line 106 of file Byte.java.

  {
    value = parseByte(s, 10);
  }

Here is the call graph for this function:


Member Function Documentation

Return the value of this Byte.

Returns:
the byte value

Reimplemented from java.lang.Number.

Definition at line 238 of file Byte.java.

  {
    return value;
  }

Compare two Bytes numerically by comparing their byte values.

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

Parameters:
bthe Byte to compare
Returns:
the comparison
Since:
1.2

Definition at line 337 of file Byte.java.

  {
    return value - b.value;
  }

Here is the caller graph for this function:

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

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

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

Definition at line 353 of file Byte.java.

  {
    return compareTo((Byte) o);
  }

Here is the call graph for this function:

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

Convert the specified String into a Byte.

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

The extended BNF grammar is as follows:

 DecodableString:
      ( [ - ] DecimalNumber )
    | ( [ - ] ( 0x | 0X
              | # ) { 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 Byte
Exceptions:
NumberFormatExceptionif s cannot be parsed as a byte
NullPointerExceptionif s is null
See also:
Integer::decode(String)

Definition at line 225 of file Byte.java.

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

Here is the call graph for this function:

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

Return the value of this Byte as a double.

Returns:
the double value

Implements java.lang.Number.

Definition at line 288 of file Byte.java.

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

Returns true if obj is an instance of Byte and represents the same byte value.

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

Definition at line 323 of file Byte.java.

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

Here is the call graph for this function:

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

Return the value of this Byte as a float.

Returns:
the float value

Implements java.lang.Number.

Definition at line 278 of file Byte.java.

  {
    return value;
  }

Return a hashcode representing this Object.

Byte's hash code is simply its value.

Returns:
this Object's hash code

Definition at line 311 of file Byte.java.

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

Return the value of this Byte as an int.

Returns:
the int value

Implements java.lang.Number.

Definition at line 258 of file Byte.java.

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

Return the value of this Byte as a long.

Returns:
the long value

Implements java.lang.Number.

Definition at line 268 of file Byte.java.

  {
    return value;
  }
static byte java.lang.Byte.parseByte ( String  s) [inline, static]

Converts the specified String into a byte.

This function assumes a radix of 10.

Parameters:
sthe String to convert
Returns:
the byte value of s
Exceptions:
NumberFormatExceptionif s cannot be parsed as a byte
See also:
parseByte(String)

Definition at line 133 of file Byte.java.

  {
    return parseByte(s, 10);
  }

Here is the caller graph for this function:

static byte java.lang.Byte.parseByte ( String  s,
int  radix 
) [inline, static]

Converts the specified String into an int 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 byte
Exceptions:
NumberFormatExceptionif s cannot be parsed as a byte

Definition at line 154 of file Byte.java.

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

Here is the call graph for this function:

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

Return the value of this Byte as a short.

Returns:
the short value

Reimplemented from java.lang.Number.

Definition at line 248 of file Byte.java.

  {
    return value;
  }
static String java.lang.Byte.toString ( byte  b) [inline, static]

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

Parameters:
bthe byte to convert to String
Returns:
the String representation of the argument

Definition at line 118 of file Byte.java.

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

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

Returns:
the String representation of this Byte
See also:
Integer::toString()

Definition at line 300 of file Byte.java.

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

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

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

Definition at line 173 of file Byte.java.

  {
    return new Byte(parseByte(s, radix));
  }

Here is the call graph for this function:

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

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

Parameters:
sthe String to convert
Returns:
the new Byte
Exceptions:
NumberFormatExceptionif s cannot be parsed as a byte
See also:
Byte(String)
parseByte(String)

Definition at line 189 of file Byte.java.

  {
    return new Byte(parseByte(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 byte java.lang.Byte.MAX_VALUE = 127 [static]

The maximum value a byte can represent is 127 (or 27 - 1).

Definition at line 72 of file Byte.java.

final byte java.lang.Byte.MIN_VALUE = -128 [static]

The minimum value a byte can represent is -128 (or -27).

Definition at line 66 of file Byte.java.

final long java.lang.Byte.serialVersionUID = -7183698231559129828L [static, private]

Compatible with JDK 1.1+.

Reimplemented from java.lang.Number.

Definition at line 60 of file Byte.java.

final byte java.lang.Byte.value [private]

The primitive type byte is represented by this Class object.

The immutable value of this Byte.

the wrapped byte

Definition at line 85 of file Byte.java.


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