List of usage examples for java.lang Integer TYPE
Class TYPE
To view the source code for java.lang Integer TYPE.
Click Source Link
From source file:Main.java
/** * Creates a class identifier of form Labc/abc;, from a Class. *///from w w w . ja v a 2 s. c om public static String ci(Class n) { if (n.isArray()) { n = n.getComponentType(); if (n.isPrimitive()) { if (n == Byte.TYPE) { return "[B"; } else if (n == Boolean.TYPE) { return "[Z"; } else if (n == Short.TYPE) { return "[S"; } else if (n == Character.TYPE) { return "[C"; } else if (n == Integer.TYPE) { return "[I"; } else if (n == Float.TYPE) { return "[F"; } else if (n == Double.TYPE) { return "[D"; } else if (n == Long.TYPE) { return "[J"; } else { throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); } } else { return "[" + ci(n); } } else { if (n.isPrimitive()) { if (n == Byte.TYPE) { return "B"; } else if (n == Boolean.TYPE) { return "Z"; } else if (n == Short.TYPE) { return "S"; } else if (n == Character.TYPE) { return "C"; } else if (n == Integer.TYPE) { return "I"; } else if (n == Float.TYPE) { return "F"; } else if (n == Double.TYPE) { return "D"; } else if (n == Long.TYPE) { return "J"; } else if (n == Void.TYPE) { return "V"; } else { throw new RuntimeException("Unrecognized type in compiler: " + n.getName()); } } else { return "L" + p(n) + ";"; } } }
From source file:com.swtxml.util.types.SimpleTypes.java
public static void addSimpleTypes(PropertyRegistry inj) { inj.add(new PropertyMatcher(Boolean.class, Boolean.TYPE), BOOLEAN); inj.add(new PropertyMatcher(Integer.class, Integer.TYPE), INTEGER); inj.add(new PropertyMatcher(Float.class, Float.TYPE), FLOAT); inj.add(new PropertyMatcher(Character.class, Character.TYPE), CHARACTER); inj.add(new PropertyMatcher(String.class), STRING); inj.add(new PropertyMatcher(int[].class), INT_ARRAY); }
From source file:Main.java
public static Object getResource(Context context, Field field, int value) { Resources resources = context.getResources(); Class type = field.getType(); if (type.isAssignableFrom(Boolean.TYPE) || type.isAssignableFrom(Boolean.class)) return resources.getBoolean(value); else if (type.isAssignableFrom(Integer.TYPE) || type.isAssignableFrom(Integer.class)) { return resources.getInteger(value); } else if (type.isAssignableFrom(ColorStateList.class)) return resources.getColorStateList(value); else if (type.isAssignableFrom(XmlResourceParser.class)) return resources.getXml(value); else if (type.isAssignableFrom(Float.TYPE) || type.isAssignableFrom(Float.class)) return resources.getDimension(value); else if (type.isAssignableFrom(Drawable.class)) return resources.getDrawable(value); else if (type.isAssignableFrom(Animation.class)) return AnimationUtils.loadAnimation(context, value); else if (type.isAssignableFrom(Movie.class)) return resources.getMovie(value); else if (type.isAssignableFrom(String.class)) return resources.getString(value); else if (type.isArray()) { if (type.getName().equals("[I")) { return resources.getIntArray(value); } else if (type.isAssignableFrom(String[].class)) { return resources.getStringArray(value); }/*from www . j a v a 2s . c o m*/ } return null; }
From source file:Main.java
public static boolean areNotificationsEnabled(Context context) { AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); ApplicationInfo appInfo = context.getApplicationInfo(); String pkg = context.getApplicationContext().getPackageName(); int uid = appInfo.uid; try {// w ww .ja v a2 s . co m Class<?> appOpsClass = Class.forName(AppOpsManager.class.getName()); Method checkOpNoThrowMethod = appOpsClass.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE, String.class); Field opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION); int value = (Integer) opPostNotificationValue.get(Integer.class); return ((Integer) checkOpNoThrowMethod.invoke(appOps, value, uid, pkg) == AppOpsManager.MODE_ALLOWED); } catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | InvocationTargetException | IllegalAccessException | RuntimeException e) { return true; } }
From source file:sim.portrayal.inspector.TimeSeriesChartingPropertyInspector.java
public static Class[] types() { return new Class[] { Number.class, Boolean.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, Valuable.class }; }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?,?,//from w ww . ja v a 2 s . com * * @param clazz * @return */ @SuppressWarnings("unchecked") private static <T> T getInternalDefaultValue(Class<T> clazz) { if (!clazz.isPrimitive()) { return null; } if (Short.TYPE.equals(clazz)) { return (T) Short.valueOf((short) 0); } if (Integer.TYPE.equals(clazz)) { return (T) Integer.valueOf(0); } if (Long.TYPE.equals(clazz)) { return (T) Long.valueOf(0); } if (Boolean.TYPE.equals(clazz)) { return (T) Boolean.valueOf(false); } if (Float.TYPE.equals(clazz)) { return (T) Float.valueOf(0); } if (Double.TYPE.equals(clazz)) { return (T) Double.valueOf(0); } if (Byte.TYPE.equals(clazz)) { return (T) Byte.valueOf((byte) 0); } if (Character.TYPE.equals(clazz)) { return (T) Character.valueOf('\0'); } return null; }
From source file:Main.java
private static Class<?>[] getArgsClasses(Object[] paramArrayOfObject) { Class[] arrayOfClass = null;//from www.j a v a 2 s .com if (paramArrayOfObject != null) { arrayOfClass = new Class[paramArrayOfObject.length]; for (int i = 0; i < paramArrayOfObject.length; ++i) { if (paramArrayOfObject[i] != null) { arrayOfClass[i] = paramArrayOfObject[i].getClass(); if (arrayOfClass[i] == Integer.class) { arrayOfClass[i] = Integer.TYPE; } else if (arrayOfClass[i] != String.class) { if (arrayOfClass[i] == Boolean.class) { arrayOfClass[i] = Boolean.TYPE; } else if (arrayOfClass[i] == Long.class) { arrayOfClass[i] = Long.TYPE; } } } } } return arrayOfClass; }
From source file:Main.java
public static boolean isConvertible(Class<?> srcPrimitive, Class<?> tgtPrimitive) { if (Boolean.TYPE.equals(srcPrimitive)) { return Boolean.TYPE.equals(tgtPrimitive); } else if (Byte.TYPE.equals(tgtPrimitive)) { return Byte.TYPE.equals(tgtPrimitive) || Short.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Character.TYPE.equals(srcPrimitive)) { return Character.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Double.TYPE.equals(srcPrimitive)) { return Double.TYPE.equals(tgtPrimitive); } else if (Float.TYPE.equals(srcPrimitive)) { return Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Integer.TYPE.equals(srcPrimitive)) { return Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Long.TYPE.equals(srcPrimitive)) { return Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Short.TYPE.equals(srcPrimitive)) { return Short.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); }/* ww w . ja v a 2s . co m*/ return false; }
From source file:gov.nih.nci.cabig.caaers.tools.CodedEnumType.java
@Override protected Class<Integer> codeJavaType() { return Integer.TYPE; }
From source file:Main.java
/** * Call a private method of a given class object * //from w w w .j a v a 2s . c o m * @param objectInstance Class object to invoke method on * @param methodName Method name to invoke * @param int1 int Parameter to the method * @return Return value from invoked method * * @throws NoSuchMethodException * @throws IllegalArgumentException * @throws IllegalAccessException * @throws InvocationTargetException */ public static Object callPrivateMethod(Object objectInstance, String methodName, int int1) throws NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException // NOSONAR { Method method = objectInstance.getClass().getDeclaredMethod(methodName, Integer.TYPE); method.setAccessible(true); return method.invoke(objectInstance, int1); }