public static FromNativeConverter<String, Pointer> getInstance(FromNativeContext fromNativeContext) {
Charset charset = Charset.defaultCharset();
if (fromNativeContext instanceof MethodResultContext) {
// See if the interface class has a global @Encoding declaration
Encoding e = getEncoding(Arrays.asList(((MethodResultContext) fromNativeContext).getMethod().getDeclaringClass().getAnnotations()));
if (e != null) {
charset = Charset.forName(e.value());
}
}
// Allow each method to override the default
Encoding e = getEncoding(fromNativeContext.getAnnotations());
if (e != null) {
charset = Charset.forName(e.value());
}
return getInstance(charset);
}