Top Description Inners Fields Constructors Methods
com.sun.jna

public Class DefaultTypeMapper

extends Object
implements TypeMapper
Class Inheritance
All Implemented Interfaces
com.sun.jna.TypeMapper
Known Direct Subclasses
com.sun.jna.win32.W32APITypeMapper
Imports
java.util.ArrayList, .Iterator, .List

Provide custom mappings to and from native types. The default lookup checks classes corresponding to converters in the order added; if the class to be converted is an instance of the converter's registered class, the converter will be used.

Derived classes should install additional converters using addToNativeConverter and/or addFromNativeConverter in the default constructor. Classes for primitive types will automatically register for the corresponding Object type and vice versa (i.e. you don't have to register both int.class and Integer.class). If you want different mapping behavior than the default, simply override getToNativeConverter and getFromNativeConverter.

See Also
Library#OPTION_TYPE_MAPPER

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private List<E>
private List<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addFromNativeConverter(Class<T> cls, FromNativeConverter converter)

Add a FromNativeConverter to convert a native result type into the given Java type.

public void
addToNativeConverter(Class<T> cls, ToNativeConverter converter)

Add a ToNativeConverter to define the conversion into a native type from arguments of the given Java type.

protected void
addTypeConverter(Class<T> cls, TypeConverter converter)

Add a TypeConverter to provide bidirectional mapping between a native and Java type.

private Class<T>
public FromNativeConverter
getFromNativeConverter(Class<T> javaType)

Implements com.sun.jna.TypeMapper.getFromNativeConverter.

Return the FromNativeConverter appropriate for the given Java class.
public ToNativeConverter
getToNativeConverter(Class<T> javaType)

Implements com.sun.jna.TypeMapper.getToNativeConverter.

Return the ToNativeConverter appropriate for the given Java class.
private Object
lookupConverter(Class<T> javaClass, List<E> converters)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fromNativeConvertersback to summary
private List<E> fromNativeConverters
toNativeConvertersback to summary
private List<E> toNativeConverters

Constructor Detail

DefaultTypeMapperback to summary
public DefaultTypeMapper()

Method Detail

addFromNativeConverterback to summary
public void addFromNativeConverter(Class<T> cls, FromNativeConverter converter)

Add a FromNativeConverter to convert a native result type into the given Java type. Converters are checked for in the order added.

addToNativeConverterback to summary
public void addToNativeConverter(Class<T> cls, ToNativeConverter converter)

Add a ToNativeConverter to define the conversion into a native type from arguments of the given Java type. Converters are checked for in the order added.

addTypeConverterback to summary
protected void addTypeConverter(Class<T> cls, TypeConverter converter)

Add a TypeConverter to provide bidirectional mapping between a native and Java type.

getAltClassback to summary
private Class<T> getAltClass(Class<T> cls)
getFromNativeConverterback to summary
public FromNativeConverter getFromNativeConverter(Class<T> javaType)

Implements com.sun.jna.TypeMapper.getFromNativeConverter.

Doc from com.sun.jna.TypeMapper.getFromNativeConverter.

Return the FromNativeConverter appropriate for the given Java class.

getToNativeConverterback to summary
public ToNativeConverter getToNativeConverter(Class<T> javaType)

Implements com.sun.jna.TypeMapper.getToNativeConverter.

Doc from com.sun.jna.TypeMapper.getToNativeConverter.

Return the ToNativeConverter appropriate for the given Java class.

lookupConverterback to summary
private Object lookupConverter(Class<T> javaClass, List<E> converters)
com.sun.jna back to summary

private Class DefaultTypeMapper.Entry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public Object
public Class<T>

Constructor Summary

AccessConstructor and Description
public
Entry(Class<T> type, Object converter)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

converterback to summary
public Object converter
typeback to summary
public Class<T> type

Constructor Detail

Entryback to summary
public Entry(Class<T> type, Object converter)