List of usage examples for java.lang Short TYPE
Class TYPE
To view the source code for java.lang Short TYPE.
Click Source Link
From source file:org.dhatim.javabean.BeanUtils.java
/** * Create the bean setter method instance for this visitor. * * @param setterName The setter method name. * @param setterParamType//from w w w . j av a 2s . co m * @return The bean setter method. */ public static Method createSetterMethod(String setterName, Object bean, Class<?> setterParamType) { Method beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, setterParamType); // Try it as a list... if (beanSetterMethod == null && List.class.isAssignableFrom(setterParamType)) { String setterNamePlural = setterName + "s"; // Try it as a List using the plural name... beanSetterMethod = ClassUtil.getSetterMethod(setterNamePlural, bean, setterParamType); if (beanSetterMethod == null) { // Try it as an array using the non-plural name... } } // Try it as a primitive... if (beanSetterMethod == null && Integer.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Integer.TYPE); } if (beanSetterMethod == null && Long.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Long.TYPE); } if (beanSetterMethod == null && Float.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Float.TYPE); } if (beanSetterMethod == null && Double.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Double.TYPE); } if (beanSetterMethod == null && Character.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Character.TYPE); } if (beanSetterMethod == null && Short.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Short.TYPE); } if (beanSetterMethod == null && Byte.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Byte.TYPE); } if (beanSetterMethod == null && Boolean.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Boolean.TYPE); } return beanSetterMethod; }
From source file:org.openTwoFactor.clientExt.net.sf.ezmorph.object.NumberMorpher.java
/** * Creates a new morpher for the target type. * * @param type must be a primitive or wrapper type. BigDecimal and BigInteger * are also supported.//from w ww.j av a 2 s.c om */ public NumberMorpher(Class type) { super(false); if (type == null) { throw new MorphException("Must specify a type"); } if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type) && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type) && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type) && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type) && !BigDecimal.class.isAssignableFrom(type)) { throw new MorphException("Must specify a Number subclass"); } this.type = type; }
From source file:org.seasar.mayaa.impl.util.ObjectUtil.java
protected static Class loadPrimitiveClass(String className) { if (StringUtil.isEmpty(className)) { throw new IllegalArgumentException(); }// w w w. j a v a 2s . com if ("short".equals(className)) { return Short.TYPE; } else if ("int".equals(className)) { return Integer.TYPE; } else if ("long".equals(className)) { return Long.TYPE; } else if ("float".equals(className)) { return Float.TYPE; } else if ("double".equals(className)) { return Double.TYPE; } else if ("byte".equals(className)) { return Byte.TYPE; } else if ("char".equals(className)) { return Character.TYPE; } else if ("boolean".equals(className)) { return Boolean.TYPE; } else if ("void".equals(className)) { return Void.TYPE; } return null; }
From source file:org.fhcrc.cpl.toolbox.AbstractConvertHelper.java
protected void register() { _register(new NullSafeConverter(new BigDecimalConverter()), BigDecimal.class); _register(new NullSafeConverter(new BigIntegerConverter()), BigInteger.class); _register(new NullSafeConverter(new BooleanArrayConverter()), boolean[].class); _register(new ByteConverter(), Byte.TYPE); _register(new NullSafeConverter(new ByteConverter()), Byte.class); _register(new CharacterConverter(), Character.TYPE); _register(new NullSafeConverter(new CharacterConverter()), Character.class); _register(new NullSafeConverter(new CharacterArrayConverter()), char[].class); _register(new NullSafeConverter(new ClassConverter()), Class.class); _register(new NullSafeConverter(new DoubleArrayConverter()), double[].class); _register(new FloatArrayConverter(), float[].class); _register(new NullSafeConverter(new IntegerArrayConverter()), int[].class); _register(new LongConverter(), Long.TYPE); _register(new NullSafeConverter(new LongConverter()), Long.class); _register(new NullSafeConverter(new LongArrayConverter()), long[].class); _register(new ShortConverter(), Short.TYPE); _register(new NullSafeConverter(new ShortConverter()), Short.class); _register(new NullSafeConverter(new ShortArrayConverter()), short[].class); _register(new NullSafeConverter(new StringArrayConverter()), String[].class); _register(new NullSafeConverter(new SqlDateConverter()), java.sql.Date.class); _register(new NullSafeConverter(new SqlTimeConverter()), java.sql.Time.class); _register(new NullSafeConverter(new SqlTimestampConverter()), java.sql.Time.class); }
From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveObjectFactory.java
private PrimitiveObjectFactory() { typeHandlers.put(String.class, PrimitiveString.class); typeHandlers.put(Enum.class, PrimitiveEnum.class); typeHandlers.put(Integer.TYPE, PrimitiveInteger.class); typeHandlers.put(Integer.class, PrimitiveInteger.class); typeHandlers.put(Boolean.TYPE, PrimitiveBoolean.class); typeHandlers.put(Boolean.class, PrimitiveBoolean.class); typeHandlers.put(Double.TYPE, PrimitiveDouble.class); typeHandlers.put(Double.class, PrimitiveDouble.class); typeHandlers.put(Long.TYPE, PrimitiveLong.class); typeHandlers.put(Long.class, PrimitiveLong.class); typeHandlers.put(Character.TYPE, PrimitiveChar.class); typeHandlers.put(Character.class, PrimitiveChar.class); typeHandlers.put(Short.TYPE, PrimitiveShort.class); typeHandlers.put(Short.class, PrimitiveShort.class); typeHandlers.put(Float.TYPE, PrimitiveFloat.class); typeHandlers.put(Float.class, PrimitiveFloat.class); typeHandlers.put(Byte.TYPE, PrimitiveByte.class); typeHandlers.put(Byte.class, PrimitiveByte.class); typeHandlers.put(BigInteger.class, PrimitiveBigInteger.class); typeHandlers.put(BigDecimal.class, PrimitiveBigDecimal.class); }
From source file:loon.LGame.java
private static Class<?> getType(Object o) { if (o instanceof Integer) { return Integer.TYPE; } else if (o instanceof Float) { return Float.TYPE; } else if (o instanceof Double) { return Double.TYPE; } else if (o instanceof Long) { return Long.TYPE; } else if (o instanceof Short) { return Short.TYPE; } else if (o instanceof Short) { return Short.TYPE; } else if (o instanceof Boolean) { return Boolean.TYPE; } else {/*from w w w. j a va 2s. c o m*/ return o.getClass(); } }
From source file:com.base.dao.sql.ReflectionUtils.java
public static Object convertValue(Object value, Class toType) { Object result = null;/*from ww w. j a v a2 s. c om*/ if (value != null) { if (value.getClass().isArray() && toType.isArray()) { Class componentType = toType.getComponentType(); result = Array.newInstance(componentType, Array.getLength(value)); for (int i = 0, icount = Array.getLength(value); i < icount; i++) { Array.set(result, i, convertValue(Array.get(value, i), componentType)); } } else { if ((toType == Integer.class) || (toType == Integer.TYPE)) result = Integer.valueOf((int) longValue(value)); if ((toType == Double.class) || (toType == Double.TYPE)) result = new Double(doubleValue(value)); if ((toType == Boolean.class) || (toType == Boolean.TYPE)) result = booleanValue(value) ? Boolean.TRUE : Boolean.FALSE; if ((toType == Byte.class) || (toType == Byte.TYPE)) result = Byte.valueOf((byte) longValue(value)); if ((toType == Character.class) || (toType == Character.TYPE)) result = new Character((char) longValue(value)); if ((toType == Short.class) || (toType == Short.TYPE)) result = Short.valueOf((short) longValue(value)); if ((toType == Long.class) || (toType == Long.TYPE)) result = Long.valueOf(longValue(value)); if ((toType == Float.class) || (toType == Float.TYPE)) result = new Float(doubleValue(value)); if (toType == BigInteger.class) result = bigIntValue(value); if (toType == BigDecimal.class) result = bigDecValue(value); if (toType == String.class) result = stringValue(value); if (toType == Date.class) { result = DateUtils.toDate(stringValue(value)); } if (Enum.class.isAssignableFrom(toType)) result = enumValue((Class<Enum>) toType, value); } } else { if (toType.isPrimitive()) { result = primitiveDefaults.get(toType); } } return result; }
From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java
/** * Creates a new morpher for the target type with a default value.<br> * The defaultValue should be of the same class as the target type. * /*w w w . ja v a 2s . c o m*/ * @param type must be a primitive or wrapper type. BigDecimal and BigInteger are also supported. * @param defaultValue return value if the value to be morphed is null */ public JsonNumberMorpher(Class<?> type, Number defaultValue) { super(true); if (type == null) { throw new MorphException("Must specify a type"); } if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type) && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type) && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type) && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type) && !BigDecimal.class.isAssignableFrom(type)) { throw new MorphException("Must specify a Number subclass"); } this.type = type; }
From source file:org.lunarray.model.descriptor.builder.annotation.util.RenderDefaultsUtil.java
/** * Fills the defaults.//from w ww. j a v a 2s .co m */ private RenderDefaultsUtil() { this.renderDefaults = new HashMap<Class<?>, RenderType>(); this.renderDefaults.put(Calendar.class, RenderType.DATE_PICKER); this.renderDefaults.put(Date.class, RenderType.DATE_PICKER); this.renderDefaults.put(java.sql.Date.class, RenderType.DATE_PICKER); this.renderDefaults.put(String.class, RenderType.TEXT); this.renderDefaults.put(Integer.class, RenderType.TEXT); this.renderDefaults.put(Double.class, RenderType.TEXT); this.renderDefaults.put(Float.class, RenderType.TEXT); this.renderDefaults.put(Long.class, RenderType.TEXT); this.renderDefaults.put(Byte.class, RenderType.TEXT); this.renderDefaults.put(Short.class, RenderType.TEXT); this.renderDefaults.put(Character.class, RenderType.TEXT); this.renderDefaults.put(Integer.TYPE, RenderType.TEXT); this.renderDefaults.put(Double.TYPE, RenderType.TEXT); this.renderDefaults.put(Float.TYPE, RenderType.TEXT); this.renderDefaults.put(Long.TYPE, RenderType.TEXT); this.renderDefaults.put(Byte.TYPE, RenderType.TEXT); this.renderDefaults.put(Short.TYPE, RenderType.TEXT); this.renderDefaults.put(Character.TYPE, RenderType.TEXT); this.renderDefaults.put(BigDecimal.class, RenderType.TEXT); this.renderDefaults.put(BigInteger.class, RenderType.TEXT); this.renderDefaults.put(Boolean.class, RenderType.CHECKBOX); this.renderDefaults.put(Boolean.TYPE, RenderType.CHECKBOX); }
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
public Object get(String name) { Object value = dynaValues.get(name); if (value != null) { return value; }//from ww w.j a va2 s . co m Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("Unspecified property type for " + name); } if (!type.isPrimitive()) { return value; } if (type == Boolean.TYPE) { return Boolean.FALSE; } else if (type == Byte.TYPE) { return new Byte((byte) 0); } else if (type == Character.TYPE) { return new Character((char) 0); } else if (type == Short.TYPE) { return new Short((short) 0); } else if (type == Integer.TYPE) { return new Integer(0); } else if (type == Long.TYPE) { return new Long(0); } else if (type == Float.TYPE) { return new Float(0.0); } else if (type == Double.TYPE) { return new Double(0); } return null; }