Examples of TypeConversionException


Examples of com.opensymphony.xwork2.conversion.TypeConversionException

        // 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

Examples of com.opensymphony.xwork2.util.TypeConversionException

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

Examples of com.opensymphony.xwork2.util.TypeConversionException

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

Examples of de.dfki.util.xmlrpc.conversion.TypeConversionException

    public static <T> T getUserRepresentation( Class<T> targetClass, Object xmlRpcRepresentation )
        throws TypeConversionException
    {
        if (xmlRpcRepresentation == null)
        {
            throw( new TypeConversionException( "Object to convert must not be null" ) );
        }

        ApiParameter p = ApiParameter.createFrom( targetClass );
        Object result = getTypeConverter().convertToUserRepresentation( p, xmlRpcRepresentation );
       
View Full Code Here

Examples of de.dfki.util.xmlrpc.conversion.TypeConversionException

        {
            cls = Class.forName( xmlRpcRepresentation );
        }
        catch( ClassNotFoundException e )
        {
            throw( new TypeConversionException( "Could not create class object:", e ) );
        }
        return( cls );
    }
View Full Code Here

Examples of de.dfki.util.xmlrpc.conversion.TypeConversionException

        {
            url = new URL(xmlRepresentation);
        }
        catch( MalformedURLException e )
        {
            throw( new TypeConversionException( e ) );
        }
        return( url );
    }
View Full Code Here

Examples of de.dfki.util.xmlrpc.conversion.TypeConversionException

        Class<? extends Convertable<?>> convertableCls = null;
        ApiParameter containerContent = null;

        if( apiParameterType == null )
        {
            throw( new TypeConversionException( "Cannot create ApiParameter description without type!" ) );
        }
       
        if (apiParameterClass == null)
        {
            apiParameterClass = getClassFromType( apiParameterType );
        }
       
        //try a std mapping
        Type xmlRpcType = StandardXmlRpcTypeConverter.mapJavaTypeToXmlRpcType( apiParameterClass );
       

        boolean isXmlRpcCompatible = false;
       
        if (xmlRpcType != null || Object.class.equals( apiParameterClass )  )
        {
            isXmlRpcCompatible = true;
        }

        if (xmlRpcType == null && apiParameterClass.isArray())
        {
            isXmlRpcCompatible = true;
            xmlRpcType = Type.ARRAY;
        }

        // let's see what the annotations tell us
       
        //first: parameter annotations / types with nested content information maps, collections, arrays
        //Contains containsAnno = AnnotationUtils.getAnnotation( parameterAnnotations, Contains.class );
        java.lang.reflect.Type contentType = getContentType( apiParameterType );
        if (/*containsAnno != null ||*/ contentType != null && xmlRpcType != Type.BASE64 )
        {
            containerContent = createFrom( new Annotation[0], contentType, getClassFromType( contentType ) );
        }
       
        XmlRpcBean xmlRpcBeanAnno = AnnotationUtils.getAnnotationForClass( apiParameterClass, XmlRpcBean.class );
        if (xmlRpcBeanAnno != null)
        {
            try
            {
                xmlRpcType = Type.STRUCT;
                ParameterConverter<?,?> c = new XmlRpcBeanConverter( apiParameterClass );
           
                //register a converter for especially for this bean type
                ParameterConverterRegistry.setParameterConverterForClass( apiParameterClass, c );
               
                ParameterConverterRegistry.readParameterConverterMappingsFromApiClass( apiParameterClass );
            }
            catch( Exception e )
            {
                throw( new TypeConversionException( "Error creating bean converter:", e ) );
            }
        }
       
        //second: annotations for used types
        XmlRpc xmlRpcAnno = AnnotationUtils.getAnnotationForClass( apiParameterClass, XmlRpc.class );
        if( xmlRpcAnno != null )
        {
            xmlRpcType = xmlRpcAnno.type();
            convertableCls = xmlRpcAnno.concrete();
            separateConverterCls = xmlRpcAnno.converter();
           
            //usesConvertable = a concete class != parameter class does conversion
            boolean usesConvertable = !convertableCls.equals( NoParameterBoundConverter.class );
           
            //usesConverter = a seperate converter does conversion
            boolean usesConverter = !separateConverterCls.equals( NoSeparateParameterConverter.class );
           
            //isConvertable = the parameter does the work itself
            boolean isConvertable = !usesConvertable && !usesConverter;
           
            if (usesConvertable && usesConverter)
            {
                throw( new AnnotationException( "Parameter can only be either a convertable or use a parameter converter, not both at a time!" ) );
            }
           
            if (isConvertable)
            {
                convertableCls = validateConvertableClass( apiParameterClass, xmlRpcType );
            }
            else if (usesConvertable)
            {
                validateConvertableClass( convertableCls, xmlRpcType );
            }
            else if (usesConverter)
            {
                checkParameterConverter( separateConverterCls, xmlRpcType );
            }
        }
       
        ParameterConverter<?,?> converter = ParameterConverterRegistry.getParameterConverterByClass( separateConverterCls );
        if (converter == null)
        {
            //maybe a mapping
            converter = ParameterConverterRegistry.getParameterConverterForClass( apiParameterClass );
        }
     
        if( converter != null )
        {
            xmlRpcType = converter.getXmlRpcRepresentationType();
        }

        if( xmlRpcType == null && !isXmlRpcCompatible
                        && de.dfki.util.xmlrpc.XmlRpc.treatUnknownTypesAsBeans() )
        {
            //the last chance: treat this type as a bean
            log().info( "Found XML-RPC unaware type '" + apiParameterClass.getName() + "' treating it as XmlRpcBean!" );
            converter = new XmlRpcBeanConverter( apiParameterClass );
            xmlRpcType = converter.getXmlRpcRepresentationType();
           
            ParameterConverterRegistry.setParameterConverterForClass( apiParameterClass, converter );
            log().info( "XmlRpcBeanConverter registered for " + apiParameterClass );
        }
       
        if( xmlRpcType == null && !isXmlRpcCompatible )
        {
            throw ( new TypeConversionException( "Cannot find a XML-RPC compliant type conversion for class "
                + apiParameterClass.getName() + ". Maybe missing annotation?" ) );
        }

        ApiParameter param = new ApiParameter( xmlRpcType, apiParameterClass, converter, convertableCls, isXmlRpcCompatible, containerContent );
        return( param );
View Full Code Here

Examples of jodd.typeconverter.TypeConversionException

      try {
        File tempFile = FileUtil.createTempFile();
        FileUtil.writeBytes(tempFile, (byte[])value);
        return tempFile;
      } catch (IOException ioex) {
        throw new TypeConversionException(ioex);
      }
    }
    if (type == String.class) {
      try {
        File tempFile = FileUtil.createTempFile();
        FileUtil.writeString(tempFile, value.toString());
        return tempFile;
      } catch (IOException ioex) {
        throw new TypeConversionException(ioex);
      }
    }
    throw new TypeConversionException(value);
  }
View Full Code Here

Examples of jodd.typeconverter.TypeConversionException

      if (StringUtil.startsWithChar(stringValue, '+')) {
        stringValue = stringValue.substring(1);
      }
      return Short.valueOf(stringValue);
    } catch (NumberFormatException nfex) {
      throw new TypeConversionException(value, nfex);
    }
  }
View Full Code Here

Examples of jodd.typeconverter.TypeConversionException

      return (Class) value;
    }
    try {
      return ClassLoaderUtil.loadClass(value.toString().trim());
    } catch (ClassNotFoundException cnfex) {
      throw new TypeConversionException(value, cnfex);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.