Package com.opensymphony.xwork2.conversion

Examples of com.opensymphony.xwork2.conversion.TypeConversionException


        LocalizedTextUtil.addDefaultResourceBundle(Constants.BUNDLE_KEY);

        // Initialize ActionContext
        ConfigurationManager configurationManager = new ConfigurationManager();
        configurationManager.addContainerProvider(new XWorkConfigurationProvider());
        Configuration config = configurationManager.getConfiguration();
        Container container = config.getContainer();

        ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
        stack.getContext().put(ActionContext.CONTAINER, container);
View Full Code Here


        }

        try {
            return DateUtil.convertStringToDate(value[0]);
        } catch (ParseException pe) {
            throw new TypeConversionException(pe.getMessage(), pe);
        }
    }
View Full Code Here

            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            try {
                return sdf.parse(values[0]);
            }
            catch(ParseException e) {
                throw new TypeConversionException(e);
            }
        }
        return null;
    }
View Full Code Here

    DateFormat df = new SimpleDateFormat(dateFormat);
    try {
      return df.parse(values[0]);
    } catch (ParseException e) {
      e.printStackTrace();
      throw new TypeConversionException(values[0] + " is not one valid date.");
    }   
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public String convertToString(Map context, Object o) {
    if(!(o instanceof Date)) throw new TypeConversionException();
    String dateFormat = LoxiaSupportSettings.getInstance().get(LoxiaSupportConstants.DATE_PATTERN);
    DateFormat df = new SimpleDateFormat(dateFormat);
    return df.format((Date)o);
  }
View Full Code Here

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
          if (!Pattern.matches(regEx, as[0])) {
            logger.warn("convertFromString(Map, String[], Class) - " + as[0] + " nie pasuje do RegEx-a:: " + regEx);
            throw new TypeConversionException(as[0] + " nie pasuje do RegEx-a:: " + regEx);
          }
        }
       
        mask = this.getMask(action);
        DateFormat df = new SimpleDateFormat(mask);
        res = df.parse(as[0]);

        if (logger.isDebugEnabled())
          logger.debug("convertFromString(Map, String[], Class) - " + as[0] + " -> " + res);
       
      } catch (ParseException ex) {
        logger.warn("convertFromString(Map, String[], Class) - " + as[0] + ", mask: " + mask);
        throw new TypeConversionException("No nie da sie tego przekonwertowac ciolku!", ex);
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("convertFromString(Map, String[], Class) - end - return value=" + res);
View Full Code Here

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
          if (!Pattern.matches(regEx, as[0])) {
            logger.warn("convertFromString(Map, String[], Class) - " + as[0] + " nie pasuje do RegEx-a:: " + regEx);
            throw new TypeConversionException(as[0] + " nie pasuje do RegEx-a:: " + regEx);
          }
        }
       
        mask = this.getMask(action);
        DecimalFormat nf = new DecimalFormat(mask);
        Number number = nf.parse(as[0]);
        res = Double.valueOf(number.doubleValue());

        if (logger.isDebugEnabled())
          logger.debug("convertFromString(Map, String[], Class) - " + as[0] + " -> " + res);
       
      } catch (ParseException ex) {
        logger.warn("convertFromString(Map, String[], Class) - " + as[0] + ", mask: " + mask);
        throw new TypeConversionException("No nie da sie tego przekonwertowac ciolku!", ex);
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("convertFromString(Map, String[], Class) - end - return value=" + res);
View Full Code Here

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
          if (!Pattern.matches(regEx, as[0])) {
            logger.warn("convertFromString() - [{}] doesn't match RegEx [{}]", as[0], regEx);
            throw new TypeConversionException(as[0] + " doesn't match RegEx " + regEx);
          }
        }
       
        mask = this.getMask(action);
        DecimalFormat nf = new DecimalFormat(mask);
        Number number = nf.parse(as[0]);
        res = BigDecimal.valueOf(number.doubleValue());

        logger.debug("convertFromString() - [{}] -> [{}]", as[0], res);
       
      } catch (ParseException ex) {
        logger.warn("convertFromString() - [{}], mask [{}]", as[0], mask);
        throw new TypeConversionException("This one can not be converted!", ex);
      }
    }

    logger.debug("convertFromString() - end - return value=[{}]", res);
    return res;
View Full Code Here

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
          if (!Pattern.matches(regEx, as[0])) {
            logger.warn("convertFromString(Map, String[], Class) - " + as[0] + " nie pasuje do RegEx-a:: " + regEx);
            throw new TypeConversionException(as[0] + " nie pasuje do RegEx-a:: " + regEx);
          }
        }
       
        mask = this.getMask(action);
        DecimalFormat nf = new DecimalFormat(mask);
        Number number = nf.parse(as[0]);
        res = BigDecimal.valueOf(number.doubleValue());

        if (logger.isDebugEnabled())
          logger.debug("convertFromString(Map, String[], Class) - " + as[0] + " -> " + res);
       
      } catch (ParseException ex) {
        logger.warn("convertFromString(Map, String[], Class) - " + as[0] + ", mask: " + mask);
        throw new TypeConversionException("No nie da sie tego przekonwertowac ciolku!", ex);
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("convertFromString(Map, String[], Class) - end - return value=" + res);
View Full Code Here

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
          if (!Pattern.matches(regEx, as[0])) {
            logger.warn("convertFromString(Map, String[], Class) - " + as[0] + " nie pasuje do RegEx-a:: " + regEx);
            throw new TypeConversionException(as[0] + " nie pasuje do RegEx-a:: " + regEx);
          }
        }
       
        mask = this.getMask(action);
        DateFormat df = new SimpleDateFormat(mask);
        res = df.parse(as[0]);

        if (logger.isDebugEnabled())
          logger.debug("convertFromString(Map, String[], Class) - " + as[0] + " -> " + res);
       
      } catch (ParseException ex) {
        logger.warn("convertFromString(Map, String[], Class) - " + as[0] + ", mask: " + mask);
        throw new TypeConversionException("No nie da sie tego przekonwertowac ciolku!", ex);
      }
    }

    if (logger.isDebugEnabled()) {
      logger.debug("convertFromString(Map, String[], Class) - end - return value=" + res);
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.conversion.TypeConversionException

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.