FileDocCategorySizeDatePackage
PlatformAddress.javaAPI DocAndroid 1.5 API9420Wed May 06 22:41:04 BST 2009org.apache.harmony.luni.platform

PlatformAddress

public class PlatformAddress extends Object implements Comparable, ICommonDataTypes
The platform address class is an unsafe virtualization of an OS memory block.

Fields Summary
static final int
SIZEOF
This final field defines the size of an address on this platform.
public static final PlatformAddress
NULL
NULL is the canonical address with address value zero.
public static final IMemorySpy
memorySpy
static final IMemorySystem
osMemory
static final long
UNKNOWN
final int
osaddr
final long
size
Constructors Summary
PlatformAddress(int address, long size)


        
        super();
        osaddr = address;
        this.size = size;
    
Methods Summary
public final voidautoFree()
Sending auto free to an address means that, when this subsystem has allocated the memory, it will automatically be freed when this object is collected by the garbage collector if the memory has not already been freed explicitly.

        memorySpy.autoFree(this);
    
public final intcompareTo(java.lang.Object other)

        if (other == null) {
            throw new NullPointerException(); // per spec.
        }
        if (other instanceof PlatformAddress) {
            int otherPA = ((PlatformAddress) other).osaddr;
            if (osaddr == otherPA) {
                return 0;
            }
            return osaddr < otherPA ? -1 : 1;
        }

        throw new ClassCastException(); // per spec.
    
public org.apache.harmony.luni.platform.PlatformAddressduplicate()

        return PlatformAddressFactory.on(osaddr, size);
    
public final booleanequals(java.lang.Object other)

        return (other instanceof PlatformAddress)
                && (((PlatformAddress) other).osaddr == osaddr);
    
public voidfree()

        // Memory spys can veto the basic free if they determine the memory was
        // not allocated.
        if (memorySpy.free(this)) {
            osMemory.free(osaddr);
        }
    
public final org.apache.harmony.luni.platform.PlatformAddressgetAddress(int offset)

        int addr = getInt(offset);
        return PlatformAddressFactory.on(addr);
    
public final bytegetByte(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JBYTE);
        return osMemory.getByte(osaddr + offset);
    
public final voidgetByteArray(int offset, byte[] bytes, int bytesOffset, int length)

        memorySpy.rangeCheck(this, offset, length * SIZEOF_JBYTE);
        osMemory.getByteArray(osaddr + offset, bytes, bytesOffset, length);
    
public final doublegetDouble(int offset, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
        return osMemory.getDouble(osaddr + offset, order);
    
public final doublegetDouble(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
        return osMemory.getDouble(osaddr + offset);
    
public final floatgetFloat(int offset, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
        return osMemory.getFloat(osaddr + offset, order);
    
public final floatgetFloat(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
        return osMemory.getFloat(osaddr + offset);
    
public final intgetInt(int offset, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
        return osMemory.getInt(osaddr + offset, order);
    
public final intgetInt(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
        return osMemory.getInt(osaddr + offset);
    
public final longgetLong(int offset, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
        return osMemory.getLong(osaddr + offset, order);
    
public final longgetLong(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
        return osMemory.getLong(osaddr + offset);
    
public final shortgetShort(int offset, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
        return osMemory.getShort(osaddr + offset, order);
    
public final shortgetShort(int offset)

        memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
        return osMemory.getShort(osaddr + offset);
    
public final longgetSize()

        return size;
    
public final inthashCode()

        return (int) osaddr;
    
public final booleanisNULL()

        return this == NULL;
    
public final voidmoveTo(org.apache.harmony.luni.platform.PlatformAddress dest, long numBytes)

        osMemory.memmove(dest.osaddr, osaddr, numBytes);
    
public org.apache.harmony.luni.platform.PlatformAddressoffsetBytes(int offset)

        return PlatformAddressFactory.on(osaddr + offset, size - offset);
    
public final voidsetAddress(int offset, org.apache.harmony.luni.platform.PlatformAddress address)

        osMemory.setAddress(osaddr + offset, address.osaddr);
    
public final voidsetByte(int offset, byte value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JBYTE);
        osMemory.setByte(osaddr + offset, value);
    
public final voidsetByteArray(int offset, byte[] bytes, int bytesOffset, int length)

        memorySpy.rangeCheck(this, offset, length * SIZEOF_JBYTE);
        osMemory.setByteArray(osaddr + offset, bytes, bytesOffset, length);
    
public final voidsetDouble(int offset, double value, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
        osMemory.setDouble(osaddr + offset, value, order);
    
public final voidsetDouble(int offset, double value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JDOUBLE);
        osMemory.setDouble(osaddr + offset, value);
    
public final voidsetFloat(int offset, float value, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
        osMemory.setFloat(osaddr + offset, value, order);
    
public final voidsetFloat(int offset, float value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JFLOAT);
        osMemory.setFloat(osaddr + offset, value);
    
public final voidsetInt(int offset, int value, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
        osMemory.setInt(osaddr + offset, value, order);
    
public final voidsetInt(int offset, int value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JINT);
        osMemory.setInt(osaddr + offset, value);
    
public final voidsetIntArray(int offset, int[] ints, int intsOffset, int length, boolean swap)

        memorySpy.rangeCheck(this, offset, length * SIZEOF_JINT);
        osMemory.setIntArray(osaddr + offset, ints, intsOffset, length, swap);
    
public final voidsetLong(int offset, long value, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
        osMemory.setLong(osaddr + offset, value, order);
    
public final voidsetLong(int offset, long value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JLONG);
        osMemory.setLong(osaddr + offset, value);
    
public final voidsetShort(int offset, short value, Endianness order)

        memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
        osMemory.setShort(osaddr + offset, value, order);
    
public final voidsetShort(int offset, short value)

        memorySpy.rangeCheck(this, offset, SIZEOF_JSHORT);
        osMemory.setShort(osaddr + offset, value);
    
public final voidsetShortArray(int offset, short[] shorts, int shortsOffset, int length, boolean swap)

        memorySpy.rangeCheck(this, offset, length * SIZEOF_JSHORT);
        osMemory.setShortArray(osaddr + offset, shorts, shortsOffset, length,
            swap);
    
public final inttoInt()

        return osaddr;
    
public final longtoLong()

        return osaddr;
    
public final java.lang.StringtoString()

        return "PlatformAddress[" + osaddr + "]"; //$NON-NLS-1$ //$NON-NLS-2$