com.sun.jna

## Class PointerType

- java.lang.Object
- - com.sun.jna.PointerType

All Implemented Interfaces:
  NativeMapped

Direct Known Subclasses:
  ByReference, COMInvoker, Ddeml.HCONV, Ddeml.HCONVLIST, Ddeml.HSZ, Guid.REFIID, WinDef.LPVOID, WinDef.PVOID, WinNT.HANDLE, WTypes.BSTR, WTypes.LPOLESTR, WTypes.LPSTR, WTypes.LPWSTR, X11.Display, X11.GC, X11.Screen, X11.Visual, X11.XImage

    public abstract class PointerType
    extends java.lang.Object
    implements NativeMapped

Type representing a type-safe native pointer. Derived classes may override the `NativeMapped.fromNative(java.lang.Object, com.sun.jna.FromNativeContext)` method, which should instantiate a new object (or look up an existing one) of the appropriate type.

### Constructor Summary

Constructors
`protected` `PointerType()` The default constructor wraps a NULL pointer.
`protected` `PointerType(Pointer p)` This constructor is typically used by `fromNative(java.lang.Object, com.sun.jna.FromNativeContext)` if generating a new object instance.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `equals(java.lang.Object o)` Instances of `PointerType` with identical pointers compare equal by default.
`java.lang.Object` `fromNative(java.lang.Object nativeValue, FromNativeContext context)` The default implementation simply creates a new instance of the class and assigns its pointer field.
`Pointer` `getPointer()` Returns the associated native `Pointer`.
`int` `hashCode()` The hash code for a `PointerType` is the same as that for its pointer.
`java.lang.Class<?>` `nativeType()` Indicate the native type used by this converter.
`void` `setPointer(Pointer p)`
`java.lang.Object` `toNative()` Convert this object to its native type (a `Pointer`).
`java.lang.String` `toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### PointerType

    protected PointerType()

The default constructor wraps a NULL pointer.

#### PointerType

    protected PointerType(Pointer p)

This constructor is typically used by `fromNative(java.lang.Object, com.sun.jna.FromNativeContext)` if generating a new object instance.

### Method Detail

#### nativeType

    public java.lang.Class<?> nativeType()

Description copied from interface: `NativeMapped`
Indicate the native type used by this converter.

Specified by:
  `nativeType` in interface `NativeMapped`
Returns:
  Java class representation of the native type.

#### toNative

    public java.lang.Object toNative()

Convert this object to its native type (a `Pointer`).

Specified by:
  `toNative` in interface `NativeMapped`
Returns:
  Java representation of the original Java object converted to a native type.

#### getPointer

    public Pointer getPointer()

Returns the associated native `Pointer`.

Returns:
  Native pointer representation for this object.

#### setPointer

    public void setPointer(Pointer p)

#### fromNative

    public java.lang.Object fromNative(java.lang.Object nativeValue,
                                       FromNativeContext context)

The default implementation simply creates a new instance of the class and assigns its pointer field. Override if you need different behavior, such as ensuring a single `PointerType` instance for each unique `Pointer` value, or instantiating a different `PointerType` subclass.

Specified by:
  `fromNative` in interface `NativeMapped`
Parameters:
  `nativeValue` - Java representation of the native type to be converted.
  `context` - Context in which the conversion is taking place.
Returns:
  Converted object.

#### hashCode

    public int hashCode()

The hash code for a `PointerType` is the same as that for its pointer.

Overrides:
  `hashCode` in class `java.lang.Object`

#### equals

    public boolean equals(java.lang.Object o)

Instances of `PointerType` with identical pointers compare equal by default.

Overrides:
  `equals` in class `java.lang.Object`

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`

Copyright © 2007-2016 Timothy Wall. All Rights Reserved.