|
JNA API> 3.2.7 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.jna.DefaultTypeMapper
public class DefaultTypeMapper
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(java.lang.Class, com.sun.jna.ToNativeConverter)
and/or addFromNativeConverter(java.lang.Class, com.sun.jna.FromNativeConverter)
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(java.lang.Class)
and getFromNativeConverter(java.lang.Class)
.
Library.OPTION_TYPE_MAPPER
Constructor Summary | |
---|---|
DefaultTypeMapper()
|
Method Summary | |
---|---|
void |
addFromNativeConverter(Class cls,
FromNativeConverter converter)
Add a FromNativeConverter to convert a native result type into the
given Java type. |
void |
addToNativeConverter(Class 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 cls,
TypeConverter converter)
Add a TypeConverter to provide bidirectional mapping between
a native and Java type. |
FromNativeConverter |
getFromNativeConverter(Class javaType)
Return the FromNativeConverter appropriate for the given Java class. |
ToNativeConverter |
getToNativeConverter(Class javaType)
Return the ToNativeConverter appropriate for the given Java class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultTypeMapper()
Method Detail |
---|
public void addToNativeConverter(Class cls, ToNativeConverter converter)
ToNativeConverter
to define the conversion into a native
type from arguments of the given Java type. Converters are
checked for in the order added.
public void addFromNativeConverter(Class cls, FromNativeConverter converter)
FromNativeConverter
to convert a native result type into the
given Java type. Converters are checked for in the order added.
protected void addTypeConverter(Class cls, TypeConverter converter)
TypeConverter
to provide bidirectional mapping between
a native and Java type.
public FromNativeConverter getFromNativeConverter(Class javaType)
TypeMapper
FromNativeConverter
appropriate for the given Java class.
getFromNativeConverter
in interface TypeMapper
public ToNativeConverter getToNativeConverter(Class javaType)
TypeMapper
ToNativeConverter
appropriate for the given Java class.
getToNativeConverter
in interface TypeMapper
|
JNA API> 3.2.7 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |