Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.ConversionException


        DateFormat df = new SimpleDateFormat(TS_FORMAT);
        if (value instanceof Date) {
            try {
                return df.format(value);
            } catch (Exception e) {
                throw new ConversionException("Error converting Timestamp to String");
            }
        }

        return value.toString();
    }
View Full Code Here


            return convertToDate(type, value, DateUtil.getDatePattern());
        } else if (type == String.class) {
            return convertToString(value);
        }

        throw new ConversionException("Could not convert " + value.getClass().getName() + " to " + type.getName());
    }
View Full Code Here

                if (type.equals(Timestamp.class)) {
                    return new Timestamp(date.getTime());
                }
                return date;
            } catch (final Exception e) {
                throw new ConversionException("Error converting String to Date", e);
            }
        }

        throw new ConversionException("Could not convert " + value.getClass().getName() + " to " + type.getName());
    }
View Full Code Here

            }

            try {
                return df.format(value);
            } catch (final Exception e) {
                throw new ConversionException("Error converting Date to String", e);
            }
        } else {
            return value.toString();
        }
    }
View Full Code Here

                return formatter.format(value);
            }
        }

        throw new ConversionException("Could not convert " + value + " to " + type.getName() + "!");
    }
View Full Code Here

        // Deal with a null value
        if (value == null) {
            if (useDefault) {
                return (defaultValue);
            } else {
                throw new ConversionException("No value specified");
            }
        }

        // Deal with the no-conversion-needed case
        if (model.getClass() == value.getClass()) {
            return (value);
        }

        // Deal with the input value as an int array
        if (ints.getClass() == value.getClass())
        {
            int[] values = (int[]) value;
            String[] results = new String[values.length];
            for (int i = 0; i < values.length; i++)
            {
                results[i] = Integer.toString(values[i]);
            }

            return (results);
        }

        // Parse the input value as a String into elements
        // and convert to the appropriate type
        try {
            List list = parseElements(value.toString());
            String results[] = new String[list.size()];
            for (int i = 0; i < results.length; i++) {
                results[i] = (String) list.get(i);
            }
            return (results);
        } catch (Exception e) {
            if (useDefault) {
                return (defaultValue);
            } else {
                throw new ConversionException(value.toString(), e);
            }
        }

    }
View Full Code Here

                    (ttype > 0)) {
                    list.add(st.sval);
                } else if (ttype == StreamTokenizer.TT_EOF) {
                    break;
                } else {
                    throw new ConversionException
                        ("Encountered token of type " + ttype);
                }
            }

            // Return the completed list
            return (list);

        } catch (IOException e) {

            throw new ConversionException(e);

        }


View Full Code Here

     *  successfully
     */
    protected Object parse(Object value, String pattern) throws ParseException {
        final Number parsed = (Number) super.parse(value, pattern);
        if (parsed.longValue() != parsed.byteValue()) {
            throw new ConversionException("Supplied number is not of type Byte: " + parsed.longValue());
        }
        // now returns property Byte
        return new Byte(parsed.byteValue());
    }
View Full Code Here

                return valueStr;
            }
            return null;
        }
        catch (IllegalArgumentException e) {
            throw new ConversionException(e.getMessage(), e);
        }
    }
View Full Code Here

      {
        return (defaultValue);
      }
      else
      {
        throw new ConversionException("No value specified");
      }
    }
    if (value instanceof ParameterMode)
    {
      return (value);
View Full Code Here

TOP

Related Classes of org.apache.commons.beanutils.ConversionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.