Top Description Fields Constructors Methods
jnr.ffi

public final Class Address

extends Number
implements Comparable<Address>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

The Address class wraps a native address in an object. Both 32 bit and 64 bit native address values are wrapped in a singular Address type.

This class extends java.lang.Number and implements all Number methods for converting to primitive integer types.

An Address instance is lighter weight than most Pointer instances, and may be used when a native address needs to be stored in java, but no other operations (such as reading/writing values) need be performed on the native memory. For most cases, a Pointer offers more flexibility and should be preferred instead.

Field Summary

Modifier and TypeField and Description
private final long
address

The native numeric value of this Address

private static final Address
NULL

A global instance of this class representing the C NULL value

Constructor Summary

AccessConstructor and Description
private
Address(long
the native address.
address
)

Creates a new address representation.

public
Address(final Address
the native address.
address
)

Creates a new address representation.

Method Summary

Modifier and TypeMethod and Description
public final long

Returns:

the native memory address
address
()

Gets the native memory address represented by this Address as a long integer.

public final int

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.
compareTo
(Address
the other Address to compare to.
other
)

Implements java.lang.Comparable.compareTo.

Compares two Address instances numerically.
public final double

Returns:

the numeric value of this Address after conversion to a double.
doubleValue
()

Implements abstract java.lang.Number.doubleValue.

Returns the value of this Address as a double.
public final boolean

Returns:

true if this Address is equal to the other address, else false.
equals
(Object
the other address to compare to.
obj
)

Overrides java.lang.Object.equals.

Compares this address to another address.
public final float

Returns:

the numeric value of this Address after conversion to a float.
floatValue
()

Implements abstract java.lang.Number.floatValue.

Returns the value of this Address as a float.
public final int

Returns:

a hash code for this Address.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code for this Address.
public final int

Returns:

the numeric value of this Address after conversion to an int.
intValue
()

Implements abstract java.lang.Number.intValue.

Returns the value of this Address as an int.
public final boolean

Returns:

true if the address is 0
isNull
()

Tests if this Address is equivalent to C NULL

public final long

Returns:

the numeric value of this Address after conversion to a long.
longValue
()

Implements abstract java.lang.Number.longValue.

Returns the value of this Address as a long.
public final long

Returns:

an long value representing the native value of this address.
nativeAddress
()

Returns the native value of this address.

public final String

Returns:

a string representation of this Address.
toHexString
()

Returns a String object representing this Address as a hex value.

public final String

Returns:

a string representation of this Address.
toString
()

Overrides java.lang.Object.toString.

Returns a String object representing this Address as a decimal value.
public static Address

Returns:

an Address instance representing address
valueOf
(long
a long value
address
)

Returns a Address instance representing the specified long value.

public static Address

Returns:

an Address instance representing address
valueOf
(int
an int value
address
)

Returns a Address instance representing the specified int value.

Inherited from java.lang.Number:
byteValueshortValue

Field Detail

addressback to summary
private final long address

The native numeric value of this Address

NULLback to summary
private static final Address NULL

A global instance of this class representing the C NULL value

Constructor Detail

Addressback to summary
private Address(long address)

Creates a new address representation.

Parameters
address:long

the native address.

Addressback to summary
public Address(final Address address)

Creates a new address representation.

Parameters
address:Address

the native address.

Method Detail

addressback to summary
public final long address()

Gets the native memory address represented by this Address as a long integer.

Returns:long

the native memory address

compareToback to summary
public final int compareTo(Address other)

Implements java.lang.Comparable.compareTo.

Compares two Address instances numerically.

Parameters
other:Address

the other Address to compare to.

Returns:int

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.

doubleValueback to summary
public final double doubleValue()

Implements abstract java.lang.Number.doubleValue.

Returns the value of this Address as a double. This method is not particularly useful, and is here to fulfill the java.lang.Number interface contract.

Returns:double

the numeric value of this Address after conversion to a double.

Annotations
@Override
equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this address to another address.

Parameters
obj:Object

the other address to compare to.

Returns:boolean

true if this Address is equal to the other address, else false.

Annotations
@Override
floatValueback to summary
public final float floatValue()

Implements abstract java.lang.Number.floatValue.

Returns the value of this Address as a float. This method is not particularly useful, and is here to fulfill the java.lang.Number interface contract.

Returns:float

the numeric value of this Address after conversion to a float.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code for this Address.

Returns:int

a hash code for this Address.

Annotations
@Override
intValueback to summary
public final int intValue()

Implements abstract java.lang.Number.intValue.

Returns the value of this Address as an int. On 64bit systems, this will result in the upper 32bits of the address being truncated.

Returns:int

the numeric value of this Address after conversion to an int.

Annotations
@Override
isNullback to summary
public final boolean isNull()

Tests if this Address is equivalent to C NULL

Returns:boolean

true if the address is 0

longValueback to summary
public final long longValue()

Implements abstract java.lang.Number.longValue.

Returns the value of this Address as a long.

Returns:long

the numeric value of this Address after conversion to a long.

Annotations
@Override
nativeAddressback to summary
public final long nativeAddress()

Returns the native value of this address.

Returns:long

an long value representing the native value of this address.

toHexStringback to summary
public final String toHexString()

Returns a String object representing this Address as a hex value.

Returns:String

a string representation of this Address.

toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Returns a String object representing this Address as a decimal value.

Returns:String

a string representation of this Address.

Annotations
@Override
valueOfback to summary
public static Address valueOf(long address)

Returns a Address instance representing the specified long value.

Parameters
address:long

a long value

Returns:Address

an Address instance representing address

valueOfback to summary
public static Address valueOf(int address)

Returns a Address instance representing the specified int value.

Parameters
address:int

an int value

Returns:Address

an Address instance representing address