com.sun.jna

Class DefaultTypeMapper

public class DefaultTypeMapper extends Object implements TypeMapper

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 DefaultTypeMapper and/or DefaultTypeMapper 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 DefaultTypeMapper and DefaultTypeMapper.

See Also: OPTION_TYPE_MAPPER

Method Summary
voidaddFromNativeConverter(Class cls, FromNativeConverter converter)
Add a FromNativeConverter to convert a native result type into the given Java type.
voidaddToNativeConverter(Class cls, ToNativeConverter converter)
Add a ToNativeConverter to define the conversion into a native type from arguments of the given Java type.
protected voidaddTypeConverter(Class cls, TypeConverter converter)
Add a TypeConverter to provide bidirectional mapping between a native and Java type.
FromNativeConvertergetFromNativeConverter(Class javaType)
ToNativeConvertergetToNativeConverter(Class javaType)

Method Detail

addFromNativeConverter

public void addFromNativeConverter(Class 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.

addToNativeConverter

public void addToNativeConverter(Class 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.

addTypeConverter

protected void addTypeConverter(Class cls, TypeConverter converter)
Add a TypeConverter to provide bidirectional mapping between a native and Java type.

getFromNativeConverter

public FromNativeConverter getFromNativeConverter(Class javaType)

getToNativeConverter

public ToNativeConverter getToNativeConverter(Class javaType)
Copyright © 2007-2009 Timothy Wall. All Rights Reserved.