Package jnr.ffi
Class Address
java.lang.Object
java.lang.Number
jnr.ffi.Address
- All Implemented Interfaces:
Serializable,Comparable<Address>
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 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.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal longaddress()Gets the native memory address represented by thisAddressas alonginteger.final intCompares twoAddressinstances numerically.final doubleReturns the value of thisAddressas adouble.final booleanCompares this address to another address.final floatReturns the value of thisAddressas afloat.final inthashCode()Returns a hash code for thisAddress.final intintValue()Returns the value of thisAddressas anint.final booleanisNull()Tests if thisAddressis equivalent to C NULLfinal longReturns the value of thisAddressas along.final longReturns the native value of this address.final StringReturns aStringobject representing thisAddressas a hex value.final StringtoString()Returns aStringobject representing thisAddressas a decimal value.static AddressvalueOf(int address) Returns a Address instance representing the specifiedintvalue.static AddressvalueOf(long address) Returns a Address instance representing the specifiedlongvalue.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
Address
Creates a new address representation.- Parameters:
address- the native address.
-
-
Method Details
-
address
public final long address()Gets the native memory address represented by thisAddressas alonginteger.- Returns:
- the native memory address
-
intValue
public final int intValue()Returns the value of thisAddressas anint. On 64bit systems, this will result in the upper 32bits of the address being truncated. -
longValue
public final long longValue()Returns the value of thisAddressas along. -
floatValue
public final float floatValue()Returns the value of thisAddressas afloat. This method is not particularly useful, and is here to fulfill theNumberinterface contract.- Specified by:
floatValuein classNumber- Returns:
- the numeric value of this
Addressafter conversion to afloat.
-
doubleValue
public final double doubleValue()Returns the value of thisAddressas adouble. This method is not particularly useful, and is here to fulfill theNumberinterface contract.- Specified by:
doubleValuein classNumber- Returns:
- the numeric value of this
Addressafter conversion to adouble.
-
nativeAddress
public final long nativeAddress()Returns the native value of this address.- Returns:
- an
longvalue representing the native value of this address.
-
hashCode
public final int hashCode()Returns a hash code for thisAddress. -
equals
Compares this address to another address. -
toString
Returns aStringobject representing thisAddressas a decimal value. -
toHexString
Returns aStringobject representing thisAddressas a hex value.- Returns:
- a string representation of this
Address.
-
compareTo
Compares twoAddressinstances numerically.- Specified by:
compareToin interfaceComparable<Address>- Parameters:
other- the other Address to compare to.- Returns:
0ifotheris equal to this instance, -1 if this instance is numerically less thanotheror 1 if this instance is numerically greater thanother.
-
isNull
public final boolean isNull()Tests if thisAddressis equivalent to C NULL- Returns:
- true if the address is 0
-
valueOf
Returns a Address instance representing the specifiedlongvalue.- Parameters:
address- alongvalue- Returns:
- an
Addressinstance representingaddress
-
valueOf
Returns a Address instance representing the specifiedintvalue.- Parameters:
address- anintvalue- Returns:
- an
Addressinstance representingaddress
-