Package jnr.ffi

Class NativeLong

All Implemented Interfaces:
Serializable, Comparable<NativeLong>

public final class NativeLong extends Number implements Comparable<NativeLong>
Represents a C long.

In C, a long can be either 32 bits or 64bits, depending on the platform.

Replace any function parameters which are long in the C definition with a NativeLong.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    Internal cache of common native long values
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final NativeLong
     
    private static final NativeLong
     
    private final long
     
    private static final NativeLong
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeLong(int value)
    Creates a new NativeLong instance with the supplied value.
    NativeLong(long value)
    Creates a new NativeLong instance with the supplied value.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static NativeLong
    _valueOf(int value)
     
    private static NativeLong
    _valueOf(long value)
     
    final int
    Compares two NativeLong instances numerically.
    final double
    Returns an double representation of this NativeLong.
    final boolean
    Compares this NativeLong to another NativeLong.
    final float
    Returns an float representation of this NativeLong.
    final int
    Gets a hash code for this NativeLong.
    final int
    Returns an integer representation of this NativeLong.
    final long
    Returns an long representation of this NativeLong.
    Returns a string representation of this NativeLong.
    static NativeLong
    valueOf(int value)
    Returns a NativeLong instance representing the specified int value
    static NativeLong
    valueOf(long value)
    Returns a NativeLong instance representing the specified long value

    Methods inherited from class java.lang.Number

    byteValue, shortValue

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ZERO

      private static final NativeLong ZERO
    • ONE

      private static final NativeLong ONE
    • MINUS_ONE

      private static final NativeLong MINUS_ONE
    • value

      private final long value
  • Constructor Details

    • NativeLong

      public NativeLong(long value)
      Creates a new NativeLong instance with the supplied value.
      Parameters:
      value - a long or integer.
    • NativeLong

      public NativeLong(int value)
      Creates a new NativeLong instance with the supplied value.
      Parameters:
      value - an integer.
  • Method Details

    • intValue

      public final int intValue()
      Returns an integer representation of this NativeLong.
      Specified by:
      intValue in class Number
      Returns:
      an integer value for this NativeLong.
    • longValue

      public final long longValue()
      Returns an long representation of this NativeLong.
      Specified by:
      longValue in class Number
      Returns:
      an long value for this NativeLong.
    • floatValue

      public final float floatValue()
      Returns an float representation of this NativeLong.
      Specified by:
      floatValue in class Number
      Returns:
      an float value for this NativeLong.
    • doubleValue

      public final double doubleValue()
      Returns an double representation of this NativeLong.
      Specified by:
      doubleValue in class Number
      Returns:
      an double value for this NativeLong.
    • hashCode

      public final int hashCode()
      Gets a hash code for this NativeLong.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code for this NativeLong.
    • equals

      public final boolean equals(Object obj)
      Compares this NativeLong to another NativeLong.
      Overrides:
      equals in class Object
      Parameters:
      obj - the other NativeLong to compare to.
      Returns:
      true if this NativeLong is equal to the other NativeLong, else false.
    • toString

      public String toString()
      Returns a string representation of this NativeLong.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this NativeLong.
    • compareTo

      public final int compareTo(NativeLong other)
      Compares two NativeLong instances numerically.
      Specified by:
      compareTo in interface Comparable<NativeLong>
      Parameters:
      other - the other NativeLong to compare to.
      Returns:
      0 if other is equal to this instance, -1 if this instance is numerically less than other or 1 if this instance is numerically greater than other.
    • _valueOf

      private static NativeLong _valueOf(long value)
    • _valueOf

      private static NativeLong _valueOf(int value)
    • valueOf

      public static NativeLong valueOf(long value)
      Returns a NativeLong instance representing the specified long value
      Parameters:
      value - a long value
      Returns:
      a NativeLong instance representing value
    • valueOf

      public static NativeLong valueOf(int value)
      Returns a NativeLong instance representing the specified int value
      Parameters:
      value - a 32bit integer value
      Returns:
      a NativeLong instance representing value