}
else if(obj instanceof double[][]) {
return matrix2rexp((double[][])obj);
}
else if(obj instanceof String[]){
return new REXPString((String[])obj);
}
else if(obj instanceof boolean[]){
return new REXPLogical((boolean[])obj);
}
else if(obj instanceof byte[]) {
return new REXPRaw((byte[])obj);
}
else if(obj instanceof Integer){
return new REXPInteger((Integer)obj);
}
else if(obj instanceof Double) {
return new REXPDouble((Double)obj);
}
else if(obj instanceof String) {
return new REXPString((String)obj);
}
else if(obj instanceof Boolean) {
return new REXPLogical((Boolean)obj);
}
else if(obj instanceof Enum<?>) {
return new REXPString(obj.toString());
}
else if(obj instanceof Map<?,?>){
return map2rexp((Map<?,?>)obj);
}
else if(obj instanceof List<?>) {
return list2rexp((List<?>)obj);
}
else if(cls.isArray() && !cls.getComponentType().isPrimitive()){
return array2rexp(obj);
}
//else if(obj instanceof RObject) return robject2rexp(obj);
else if(useBean && !cls.isPrimitive() && !cls.isArray()) return bean2rexp(obj);
else if(handleUnsupported) return new REXPString(obj.toString());
throw new IllegalArgumentException("Unsupported arg type " + cls);
}