Back to project page Dumbledroid.
The source code is released under:
Copyright (c) 2013, Leocadio Tin? All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project Dumbledroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package io.leocad.dumbledroidplugin.core; /*ww w . java 2s.c o m*/ public class ClassMapper { public static String getPrimitiveTypeName(Object object) { Class<?> objClass = object.getClass(); if (objClass == Integer.class) { return "int"; } else if (objClass == Long.class) { return "long"; } else if (objClass == Double.class) { return "double"; } else if (objClass == Boolean.class) { return "boolean"; } return null; } public static String getPrimitiveTypeNameByCasting(String value) { try { Integer.valueOf(value); return "int"; } catch (NumberFormatException e) {} try { Long.valueOf(value); return "long"; } catch (NumberFormatException e) {} try { Double.valueOf(value); // Prefer double over float return "double"; } catch (NumberFormatException e) {} final String valueLower = value.toLowerCase(); if (valueLower.equals("true") || valueLower.equals("false")) { return "boolean"; } return null; } public static String getWrapperTypeNameByCasting(String value) { try { Integer.valueOf(value); return "Integer"; } catch (NumberFormatException e) {} try { Long.valueOf(value); return "Long"; } catch (NumberFormatException e) {} try { Double.valueOf(value); // Prefer double over float return "Double"; } catch (NumberFormatException e) {} final String valueLower = value.toLowerCase(); if (valueLower.equals("true") || valueLower.equals("false")) { return "Boolean"; } return null; } }