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:com.redblackit.web.server.mvc.RequestUrlHandlerMethodArgumentResolverTest.java
/** * Test call using parameter 1// w ww.j a va2 s . c o m * * Test method for * {@link com.redblackit.web.server.mvc.RequestUrlHandlerMethodArgumentResolver#resolveArgument(org.springframework.core.MethodParameter, org.springframework.web.method.support.ModelAndViewContainer, org.springframework.web.context.request.NativeWebRequest, org.springframework.web.bind.support.WebDataBinderFactory)} */ @Test public void testResolveArgumentParm1of3() throws Exception { Method method = null; try { method = testParameters.testController.getClass().getMethod("methodParameter1of3", Integer.TYPE, testParameters.parameterType, Model.class); } catch (NoSuchMethodException nsme) { logger.fatal(assertMsg("controller method", null)); throw nsme; } verifyParameter(method, 1); }
From source file:com.google.feedserver.util.BeanCliHelper.java
/** * For each class registered, we extract options based on the {@link Flag} * decorator set on each field in the bean. We use the help argument on the * decorator to set command line option usage text. * /* ww w . j av a 2s .co m*/ * Note: classes with identical flag field names will get overwritten with the * last one processed. TODO(rayc) support collision detection and use fully * qualified class name for flag option. * * see {@link Flag} for more info. * * @return Options all command-line options registered for parsing. */ private Options createOptions() { Options options = new Options(); options.addOption(new Option("help", false, "Print out usage.")); // Go through all registered beans. for (Object bean : beans) { // Go through all fields. for (Field field : bean.getClass().getDeclaredFields()) { Flag flag = field.getAnnotation(Flag.class); if (flag == null) { continue; // no decorator we move on. } // Check type we only support boolean, String and Integer. if ((field.getType() != Integer.class) && (field.getType() != Integer.TYPE) && (field.getType() != String.class) && (field.getType() != Boolean.class) && (field.getType() != Boolean.TYPE)) { throw new RuntimeException("Field: " + field.getName() + " flag type not supported"); } // Create options. String argName = field.getName(); if (field.getType().getName().equals(Boolean.class.getName()) || field.getType().getName().equals(Boolean.TYPE.getName())) { options.addOption(new Option(argName, false, flag.help())); options.addOption(new Option("no" + argName, false, flag.help())); } else { options.addOption(new Option(argName, true, flag.help())); } } } return options; }
From source file:org.eclipse.recommenders.internal.stacktraces.rcp.LogListenerTest.java
@Test public void testMonitoringStatusWithNoChildsFiltered() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { settings.setAction(SILENT);//from w w w.java 2 s. c o m MultiStatus multi = new MultiStatus("org.eclipse.ui.monitoring", 0, "UI freeze of 6,0s at 11:24:59.108", new RuntimeException("stand-in-stacktrace")); Method method = Status.class.getDeclaredMethod("setSeverity", Integer.TYPE); method.setAccessible(true); method.invoke(multi, IStatus.ERROR); sut.logging(multi, ""); verifyNoErrorReportSend(); }
From source file:at.alladin.rmbt.shared.hstoreparser.HstoreParser.java
/** * get a specific key from json by preserving the fields type * @param json/*from w ww . ja v a 2 s .com*/ * @param key * @param toField * @return * @throws JSONException */ public static Object getFromJsonByField(JSONObject json, String key, Field toField) throws JSONException { final Object o = json.get(key); if (o != JSONObject.NULL) { if (toField.getType().equals(Integer.class) || toField.getType().equals(Integer.TYPE)) { return Integer.parseInt(String.valueOf(o)); } else if (toField.getType().equals(String.class)) { return o; } else if (toField.getType().equals(Long.class) || toField.getType().equals(Long.TYPE)) { return Long.parseLong(String.valueOf(o)); } else if (toField.getType().equals(Boolean.class) || toField.getType().equals(Boolean.TYPE)) { return Boolean.parseBoolean(String.valueOf(o)); } else if (toField.getType().equals(Float.class) || toField.getType().equals(Float.TYPE)) { return Float.parseFloat(String.valueOf(o)); } else if (toField.getType().equals(Double.class) || toField.getType().equals(Double.TYPE)) { return Double.parseDouble(String.valueOf(o)); } else { return o; } } return JSONObject.NULL; }
From source file:com.nonninz.robomodel.RoboModel.java
void saveField(Field field, TypedContentValues cv) { final Class<?> type = field.getType(); final boolean wasAccessible = field.isAccessible(); field.setAccessible(true);// w w w . j a v a2 s . co m try { if (type == String.class) { cv.put(field.getName(), (String) field.get(this)); } else if (type == Boolean.TYPE) { cv.put(field.getName(), field.getBoolean(this)); } else if (type == Byte.TYPE) { cv.put(field.getName(), field.getByte(this)); } else if (type == Double.TYPE) { cv.put(field.getName(), field.getDouble(this)); } else if (type == Float.TYPE) { cv.put(field.getName(), field.getFloat(this)); } else if (type == Integer.TYPE) { cv.put(field.getName(), field.getInt(this)); } else if (type == Long.TYPE) { cv.put(field.getName(), field.getLong(this)); } else if (type == Short.TYPE) { cv.put(field.getName(), field.getShort(this)); } else if (type.isEnum()) { final Object value = field.get(this); if (value != null) { final Method method = type.getMethod("name"); final String str = (String) method.invoke(value); cv.put(field.getName(), str); } } else { // Try to JSONify it (db column must be of type text) final String json = mMapper.writeValueAsString(field.get(this)); cv.put(field.getName(), json); } } catch (final IllegalAccessException e) { final String msg = String.format("Field %s is not accessible", type, field.getName()); throw new IllegalArgumentException(msg); } catch (final JsonProcessingException e) { Ln.w(e, "Error while dumping %s of type %s to Json", field.getName(), type); final String msg = String.format("Field %s is not accessible", type, field.getName()); throw new IllegalArgumentException(msg); } catch (final NoSuchMethodException e) { // Should not happen throw new RuntimeException(e); } catch (final InvocationTargetException e) { // Should not happen throw new RuntimeException(e); } finally { field.setAccessible(wasAccessible); } }
From source file:com.nway.spring.jdbc.bean.AsmBeanProcessor.java
private Object processColumn(ResultSet rs, int index, Class<?> propType, String writer, String processorName, String beanName, MethodVisitor mv) throws SQLException { if (propType.equals(String.class)) { visitMethod(mv, index, beanName, "Ljava/lang/String;", "getString", writer); return rs.getString(index); } else if (propType.equals(Integer.TYPE)) { visitMethod(mv, index, beanName, "I", "getInt", writer); return rs.getInt(index); } else if (propType.equals(Integer.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_INTEGER, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Integer.class); } else if (propType.equals(Long.TYPE)) { visitMethod(mv, index, beanName, "J", "getLong", writer); return rs.getLong(index); } else if (propType.equals(Long.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_LONG, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Long.class); } else if (propType.equals(java.sql.Date.class)) { visitMethod(mv, index, beanName, "Ljava/sql/Date;", "getDate", writer); return rs.getDate(index); } else if (propType.equals(java.util.Date.class)) { visitMethodCast(mv, index, beanName, PROPERTY_TYPE_DATE, "java/util/Date", writer); return rs.getTimestamp(index); } else if (propType.equals(Timestamp.class)) { visitMethod(mv, index, beanName, "Ljava/sql/Timestamp;", "getTimestamp", writer); return rs.getTimestamp(index); } else if (propType.equals(Time.class)) { visitMethod(mv, index, beanName, "Ljava/sql/Time;", "getTime", writer); return rs.getTime(index); } else if (propType.equals(Double.TYPE)) { visitMethod(mv, index, beanName, "D", "getDouble", writer); return rs.getDouble(index); } else if (propType.equals(Double.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_DOUBLE, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Double.class); } else if (propType.equals(Float.TYPE)) { visitMethod(mv, index, beanName, "F", "getFloat", writer); return rs.getFloat(index); } else if (propType.equals(Float.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_FLOAT, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Float.class); } else if (propType.equals(Boolean.TYPE)) { visitMethod(mv, index, beanName, "Z", "getBoolean", writer); return rs.getBoolean(index); } else if (propType.equals(Boolean.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_BOOLEAN, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Boolean.class); } else if (propType.equals(Clob.class)) { visitMethod(mv, index, beanName, "Ljava/sql/Clob;", "getClob", writer); return rs.getClob(index); } else if (propType.equals(Blob.class)) { visitMethod(mv, index, beanName, "Ljava/sql/Blob;", "getBlob", writer); return rs.getBlob(index); } else if (propType.equals(byte[].class)) { visitMethod(mv, index, beanName, "[B", "getBytes", writer); return rs.getBytes(index); } else if (propType.equals(Short.TYPE)) { visitMethod(mv, index, beanName, "S", "getShort", writer); return rs.getShort(index); } else if (propType.equals(Short.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_SHORT, writer, processorName); return JdbcUtils.getResultSetValue(rs, index, Short.class); } else if (propType.equals(Byte.TYPE)) { visitMethod(mv, index, beanName, "B", "getByte", writer); return rs.getByte(index); } else if (propType.equals(Byte.class)) { visitMethodWrap(mv, index, beanName, PROPERTY_TYPE_BYTE, writer, processorName); return rs.getByte(index); } else {//from w w w.j a v a2s . co m visitMethodCast(mv, index, beanName, PROPERTY_TYPE_OTHER, propType.getName().replace('.', '/'), writer); return rs.getObject(index); } }
From source file:javadz.beanutils.ConvertUtilsBean.java
/** * Sets the default value for Integer conversions. * @param newDefaultInteger The default Integer value * @deprecated Register replacement converters for Integer.TYPE and * Integer.class instead//from w ww. j a va 2s . c om */ public void setDefaultInteger(int newDefaultInteger) { defaultInteger = new Integer(newDefaultInteger); register(new IntegerConverter(defaultInteger), Integer.TYPE); register(new IntegerConverter(defaultInteger), Integer.class); }
From source file:com.sun.faces.el.impl.Coercions.java
/** * Returns true if the given class is Byte, Short, Integer, Long, * Float, Double, BigInteger, or BigDecimal *//*from ww w .j a va 2 s . c om*/ static boolean isNumberClass(Class pClass) { return pClass == Byte.class || pClass == Byte.TYPE || pClass == Short.class || pClass == Short.TYPE || pClass == Integer.class || pClass == Integer.TYPE || pClass == Long.class || pClass == Long.TYPE || pClass == Float.class || pClass == Float.TYPE || pClass == Double.class || pClass == Double.TYPE || pClass == BigInteger.class || pClass == BigDecimal.class; }
From source file:com.streamsets.datacollector.execution.preview.sync.SyncPreviewer.java
private static Object getValueFromParam(Field field, String stringValue) { Class<?> type = field.getType(); if (String.class.isAssignableFrom(type)) { return stringValue; } else if (Integer.class.isAssignableFrom(type) || Integer.TYPE == type) { return Integer.parseInt(stringValue); } else if (Long.class.isAssignableFrom(type) || Long.TYPE == type) { return Long.parseLong(stringValue); } else if (Boolean.class.isAssignableFrom(type) || Boolean.TYPE == type) { return Boolean.parseBoolean(stringValue); }/*from ww w . ja v a 2 s . c o m*/ return null; }
From source file:org.apache.openejb.util.proxy.QueryProxy.java
private boolean isInt(final Class<?> aClass) { return Integer.TYPE.equals(aClass) || Integer.class.equals(aClass); }