List of usage examples for org.apache.commons.beanutils.converters ShortConverter ShortConverter
public ShortConverter(Object defaultValue)
From source file:com.tecapro.inventory.common.util.BeanUtil.java
/** * (non-Javadoc)//from ww w. j a v a 2s. c o m * @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 . ja v a 2 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:org.andromda.cartridges.database.DatabaseTemplateObject.java
/** * Creates a new DatabaseTemplateObject object. *//*w ww . j a v a2 s .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>/*from w ww. j a va2 s.c om*/ * * @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.kuali.rice.kns.web.struts.action.KualiActionServlet.java
/** * <p>Initialize other global characteristics of the controller servlet.</p> * Overridden to remove the ConvertUtils.deregister() command that caused problems * with the concurrent data dictionary load. (KULRNE-4405) * * @exception ServletException if we cannot initialize these resources *//*from w w w . j a va 2s . c om*/ @Override protected void initOther() throws ServletException { String value = null; 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.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); } // KULRICE-8176: KFS Notes/Attachments Tab Functionality for Note Text Error - Visible/Special characters, spaces, or tabs parameterEncoding = getServletConfig().getInitParameter("PARAMETER_ENCODING"); }
From source file:org.quickbundle.third.struts.action.RmActionServlet.java
/** * <p>Initialize other global characteristics of the controller * servlet.</p>/*from www .j a v a2 s .com*/ * * @throws ServletException if we cannot initialize these resources */ protected void initOther() throws ServletException { String value; value = getServletConfig().getInitParameter("config"); if (value != null) { //QB-RM add *.xml if (value.trim().length() > 0 && value.indexOf("*.xml") > -1) { // String finalValue = ""; String[] aValue = value.trim().split(","); for (int j = 0; j < aValue.length; j++) { String path = aValue[j]; if (path.trim().length() == 0) { continue; } //??*.xml if (path.trim().endsWith("*.xml")) { File fWarDirStr = RmPathHelper.getWarDir(); File fPath = new File(fWarDirStr + File.separator + (path.substring(0, path.length() - "*.xml".length()))); for (int i = 0; i < fPath.listFiles().length; i++) { File fPathXml = fPath.listFiles()[i]; if (fPathXml.isFile() && fPathXml.toString().toLowerCase().endsWith(".xml")) { String newPath = fPathXml.getAbsolutePath() .substring((int) fWarDirStr.getAbsoluteFile().toString().length()) .replaceAll("\\\\", "/"); finalValue += newPath + ","; } } } else { finalValue += path + ","; } } if (finalValue.endsWith(",")) { finalValue = finalValue.substring(0, finalValue.length() - ",".length()); } config = finalValue; } else { 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); } }