Class Addr64

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<java.lang.Object>, IAddress

    public class Addr64
    extends java.lang.Object
    implements IAddress, java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Addr64​(byte[] addrBytes)  
      Addr64​(long addr)
      Create an address represented by long bits.
      Addr64​(java.lang.String addr)  
      Addr64​(java.lang.String addr, boolean truncate)  
      Addr64​(java.lang.String addr, int radix)  
      Addr64​(java.lang.String addr, int radix, boolean truncate)  
      Addr64​(java.math.BigInteger rawaddress)  
      Addr64​(java.math.BigInteger rawaddress, boolean truncate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IAddress add​(long offset)
      Adds offset to address and returns new address object which is the result

      Note: This method has an offset limit of Long.MAX and Long.MIN, which under some addressing schemes may impose an unnecessary limitation, see IAddress.add(BigInteger offset) to handle larger offsets.
      IAddress add​(java.math.BigInteger offset)
      Adds offset to address and returns new address object which is the result
      int compareTo​(java.lang.Object other)  
      java.math.BigInteger distanceTo​(IAddress other)
      Returns distance to address.
      boolean equals​(java.lang.Object x)
      Returns whether this address equals the given object.
      int getCharsNum()
      Returns amount of symbols in hex representation.
      java.math.BigInteger getMaxOffset()
      Returns maximal offset possible for address.
      int getSize()
      Returns the address size in bytes.
      java.math.BigInteger getValue()
      Returns the value of the address.
      int hashCode()  
      boolean isMax()
      Return true if address is maximal, i.e.
      boolean isZero()
      Return true if address is zero, i.e.
      java.lang.String toBinaryAddressString()
      Converts address to the binary representation with '0b' prefix and with all leading zeros.
      java.lang.String toHexAddressString()
      Converts address to the hex representation with '0x' prefix and with all leading zeros.
      java.lang.String toOctalAddressString()  
      java.lang.String toString()
      Identical to toString(10)
      java.lang.String toString​(int radix)
      Converts address to string as an unsigned number with given radix
      • Methods inherited from class java.lang.Object

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

      • ZERO

        public static final Addr64 ZERO
      • MAX

        public static final Addr64 MAX
      • MAX_OFFSET

        public static final java.math.BigInteger MAX_OFFSET
    • Constructor Detail

      • Addr64

        public Addr64​(byte[] addrBytes)
      • Addr64

        public Addr64​(java.math.BigInteger rawaddress)
      • Addr64

        public Addr64​(java.math.BigInteger rawaddress,
                      boolean truncate)
      • Addr64

        public Addr64​(java.lang.String addr)
      • Addr64

        public Addr64​(long addr)
        Create an address represented by long bits. Signed bit will be used as unsigned extension, if you don't want it mask it before passing here.
        Since:
        5.9
      • Addr64

        public Addr64​(java.lang.String addr,
                      boolean truncate)
      • Addr64

        public Addr64​(java.lang.String addr,
                      int radix)
      • Addr64

        public Addr64​(java.lang.String addr,
                      int radix,
                      boolean truncate)
    • Method Detail

      • add

        public IAddress add​(java.math.BigInteger offset)
        Description copied from interface: IAddress
        Adds offset to address and returns new address object which is the result
        Specified by:
        add in interface IAddress
        Parameters:
        offset - to add
        Returns:
        the new address
      • add

        public IAddress add​(long offset)
        Description copied from interface: IAddress
        Adds offset to address and returns new address object which is the result

        Note: This method has an offset limit of Long.MAX and Long.MIN, which under some addressing schemes may impose an unnecessary limitation, see IAddress.add(BigInteger offset) to handle larger offsets.
        Specified by:
        add in interface IAddress
        Parameters:
        offset - to add
        Returns:
        the new address
      • getMaxOffset

        public java.math.BigInteger getMaxOffset()
        Description copied from interface: IAddress
        Returns maximal offset possible for address. The offset should be identical for all addresses of given class.
        Specified by:
        getMaxOffset in interface IAddress
        Returns:
        the max offset for this address class
      • distanceTo

        public java.math.BigInteger distanceTo​(IAddress other)
        Description copied from interface: IAddress
        Returns distance to address. Distance may be positive or negative
        Specified by:
        distanceTo in interface IAddress
        Parameters:
        other - address which distance is calculated to.
        Returns:
        distance to address
      • isMax

        public boolean isMax()
        Description copied from interface: IAddress
        Return true if address is maximal, i.e. maximal possible
        Specified by:
        isMax in interface IAddress
        Returns:
        true if address is maximal
      • isZero

        public boolean isZero()
        Description copied from interface: IAddress
        Return true if address is zero, i.e. minimal possible
        Specified by:
        isZero in interface IAddress
        Returns:
        true is address is zero
      • getValue

        public java.math.BigInteger getValue()
        Description copied from interface: IAddress
        Returns the value of the address.
        Specified by:
        getValue in interface IAddress
      • compareTo

        public int compareTo​(java.lang.Object other)
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.Object>
      • equals

        public boolean equals​(java.lang.Object x)
        Description copied from interface: IAddress
        Returns whether this address equals the given object.
        Specified by:
        equals in interface IAddress
        Overrides:
        equals in class java.lang.Object
        Parameters:
        x - the other object
        Returns:
        true if the addresses are equivalent, and false if they are not
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Description copied from interface: IAddress
        Identical to toString(10)
        Specified by:
        toString in interface IAddress
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of address using a radix of 10
      • toString

        public java.lang.String toString​(int radix)
        Description copied from interface: IAddress
        Converts address to string as an unsigned number with given radix
        Specified by:
        toString in interface IAddress
        Parameters:
        radix - to use for string conversion
        Returns:
        a string representation of address
      • toHexAddressString

        public java.lang.String toHexAddressString()
        Description copied from interface: IAddress
        Converts address to the hex representation with '0x' prefix and with all leading zeros. The length of returned string should be the same for all addresses of given class. I.e. 10 for 32-bit addresses and 18 for 64-bit addresses
        Specified by:
        toHexAddressString in interface IAddress
      • toOctalAddressString

        public java.lang.String toOctalAddressString()
        Since:
        5.4
      • toBinaryAddressString

        public java.lang.String toBinaryAddressString()
        Description copied from interface: IAddress
        Converts address to the binary representation with '0b' prefix and with all leading zeros. The length of returned string should be the same for all addresses of given class. I.e. 34 for 32-bit addresses and 66 for 64-bit addresses
        Specified by:
        toBinaryAddressString in interface IAddress
      • getCharsNum

        public int getCharsNum()
        Description copied from interface: IAddress
        Returns amount of symbols in hex representation. Is identical to toHexAddressString().length(). It is present for performance purpose.
        Specified by:
        getCharsNum in interface IAddress
        Returns:
        the number of character symbols to represent this address in hex.
      • getSize

        public int getSize()
        Description copied from interface: IAddress
        Returns the address size in bytes.
        Specified by:
        getSize in interface IAddress
        Returns:
        the number of bytes required to hold this address.