List of usage examples for org.apache.commons.beanutils.converters LongConverter LongConverter
public LongConverter(Object defaultValue)
From source file:com.feilong.core.bean.ConvertUtilTemp.java
/** * To long array./*w w w . j a va2s .c om*/ * * @param <T> * the generic type * @param defaultType * the default type * @param stringA * the string a * @return the t * @since 1.2.2 */ private <T> T toLongArray(Class<T> defaultType, String stringA) { LongConverter elementConverter = new LongConverter(new Long(0L)); elementConverter.setPattern("#,###"); elementConverter.setLocale(Locale.US); return convert(defaultType, elementConverter, stringA); }
From source file:com.tecapro.inventory.common.util.BeanUtil.java
/** * (non-Javadoc)// w w w. jav a2s. c om * @see org.apache.commons.beanutils.BeanUtilsBean.populate(Object bean, Map properties) * throws IllegalAccessException, InvocationTargetException * * @param input * @param bean */ @SuppressWarnings("unchecked") public void populate(Object input, Object bean) { try { beanUtil.setConvertUtil(convertUtil); beanUtil.setItemPropUtil(itemPropUtil); DoubleConverter dConverter = new DoubleConverter(null); ShortConverter sConverter = new ShortConverter(null); FloatConverter fConverter = new FloatConverter(null); LongConverter lConverter = new LongConverter(null); IntegerConverter iConverter = new IntegerConverter(null); beanUtil.getConvertUtils().register(dConverter, Double.class); beanUtil.getConvertUtils().register(sConverter, Short.class); beanUtil.getConvertUtils().register(fConverter, Float.class); beanUtil.getConvertUtils().register(lConverter, Long.class); beanUtil.getConvertUtils().register(iConverter, Integer.class); beanUtil.populate(bean, (Map<String, Object>) input); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.algoTrader.PropertySearch.java
/** * Initializes the converters to behave the way we want when converting values (we don't * want empty strings converted to zeros, like beanutils does by default) *//*w ww. j a va2 s. com*/ private void initializeConverters() { ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new ShortConverter(null), Short.class); ConvertUtils.register(new CalendarConverter(), Calendar.class); ConvertUtils.register(new DateConverter(), Date.class); }
From source file:com.feilong.core.bean.ConvertUtil.java
/** * ?{@link Long}./*from w ww . j av a 2 s.c o m*/ * * <p> * converted is missing or an error occurs converting the value,<span style="color:red"> null</span> * </p> * * @param toBeConvertedValue * ?. * @return <code>toBeConvertedValue</code> null, null<br> * ???, null * @see #convert(Object, Class) * @see org.apache.commons.beanutils.converters.LongConverter * @see org.apache.commons.lang3.math.NumberUtils#toLong(String) */ public static Long toLong(Object toBeConvertedValue) { return new LongConverter(null).convert(Long.class, toBeConvertedValue); }
From source file:com.sunchenbin.store.feilong.core.bean.ConvertUtil.java
/** * ?long.//from w ww .j a v a 2 s . co m * * <p> * converted is missing or an error occurs converting the value,<span style="color:red">return null</span> * </p> * * @param toBeConvertedValue * ?. * @return the long * @see #convert(Object, Class) * @see org.apache.commons.beanutils.converters.LongConverter */ public static Long toLong(Object toBeConvertedValue) { LongConverter longConverter = new LongConverter(null); return longConverter.convert(Long.class, toBeConvertedValue); }
From source file:org.andromda.cartridges.database.DatabaseTemplateObject.java
/** * Creates a new DatabaseTemplateObject object. *///from w w w .ja va 2s . co m public DatabaseTemplateObject() { // initialize converters we're using since we don't want to default to 0 ConvertUtils.register(new LongConverter(null), java.lang.Long.class); ConvertUtils.register(new IntegerConverter(null), java.lang.Integer.class); ConvertUtils.register(new ShortConverter(null), java.lang.Short.class); }
From source file:org.apache.struts.action.ActionServlet.java
/** * <p>Initialize other global characteristics of the controller * servlet.</p>/*ww w. j a v a2 s . co m*/ * * @throws ServletException if we cannot initialize these resources */ protected void initOther() throws ServletException { String value; value = getServletConfig().getInitParameter("config"); if (value != null) { config = value; } // Backwards compatibility for form beans of Java wrapper classes // Set to true for strict Struts 1.0 compatibility value = getServletConfig().getInitParameter("convertNull"); if ("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value) || "y".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)) { convertNull = true; } if (convertNull) { ConvertUtils.deregister(); ConvertUtils.register(new BigDecimalConverter(null), BigDecimal.class); ConvertUtils.register(new BigIntegerConverter(null), BigInteger.class); ConvertUtils.register(new BooleanConverter(null), Boolean.class); ConvertUtils.register(new ByteConverter(null), Byte.class); ConvertUtils.register(new CharacterConverter(null), Character.class); ConvertUtils.register(new DoubleConverter(null), Double.class); ConvertUtils.register(new FloatConverter(null), Float.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new ShortConverter(null), Short.class); } }
From source file:org.beanfuse.struts2.action.helper.ParamHelper.java
public static void registerConverter() { ConvertUtils.register(new SqlDateConverter(), java.sql.Date.class); ConvertUtils.register(new DateConverter(), java.util.Date.class); ConvertUtils.register(new BooleanConverter(null), Boolean.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new FloatConverter(null), Float.class); ConvertUtils.register(new DoubleConverter(null), Double.class); }
From source file:org.beangle.commons.converters.Converter.java
public static final ConvertUtilsBean getDefault() { ConvertUtilsBean convertUtils = new ConvertUtilsBean(); convertUtils.register(new SqlDateConverter(), java.sql.Date.class); convertUtils.register(new DateConverter(), java.util.Date.class); convertUtils.register(new BooleanConverter(null), Boolean.class); convertUtils.register(new IntegerConverter(null), Integer.class); convertUtils.register(new LongConverter(null), Long.class); convertUtils.register(new FloatConverter(null), Float.class); convertUtils.register(new DoubleConverter(null), Double.class); return convertUtils; }
From source file:org.ikasan.configurationService.service.ConfiguredResourceConfigurationService.java
/** * Constructor//from w ww . ja va 2 s . c om * * @param staticConfigurationDao - used to update configuration outside a runtime transaction * @param dynamicConfigurationDao - used to update configuration at runtime within a transaction */ public ConfiguredResourceConfigurationService(ConfigurationDao staticConfigurationDao, ConfigurationDao dynamicConfigurationDao) { this.staticConfigurationDao = staticConfigurationDao; if (staticConfigurationDao == null) { throw new IllegalArgumentException("configurationDao cannot be 'null'"); } this.dynamicConfigurationDao = dynamicConfigurationDao; if (dynamicConfigurationDao == null) { throw new IllegalArgumentException("dynamicConfigurationDao cannot be 'null'"); } // override some default converters to ensure null is default assignments ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); }