Package com.googlecode.mjorm.convert

Examples of com.googlecode.mjorm.convert.ConversionException


    } else if (String.class.isInstance(source)) {
      return Boolean.valueOf(String.class.cast(source));
    }

    throw new ConversionException("Unable to convert source to boolean");
  }
View Full Code Here


     
    } else if (String.class.isInstance(source)) {
      return Character.valueOf(String.class.cast(source).trim().charAt(0));
     
    }
    throw new ConversionException("Unable to convert source to character");
  }
View Full Code Here

      componentType = targetType.getComponentJavaType();
    }

    // bail if we don't have a component type
    if (componentType==null) {
      throw new ConversionException(
        "Unable to determine componentType of "+targetType);
    }

    // create array
    Object ret = Array.newInstance(componentType.asClass(), source.size());
View Full Code Here

      parameterType = targetType.getJavaTypeParameter(0);
    }

    // bail if we don't have a parameter type
    if (parameterType==null) {
      throw new ConversionException(
        "Unable to determine parameterType of "+targetType);
    }

    // get target class
    Class<?> targetClass = targetType.asClass();

    // create collection
    Collection ret;
    if (!targetClass.isInterface()) {
      try {
        ret = Collection.class.cast(ReflectionUtil.instantiate(targetClass));
      } catch (Exception e) {
        throw new ConversionException("Couldn't instantiate "+targetClass.getName(), e);
      }
    } else if (SortedSet.class.isAssignableFrom(targetClass)) {

      // get comparator hint
      String comaparatorClassName = hints.get(HINT_COMPARATOR_CLASS);

      // create the comparator if we can
      Comparator<?> comparator = null;
      if (comaparatorClassName!=null) {
        try {
          comparator = Comparator.class.cast(
            ReflectionUtil.instantiate(Class.forName(comaparatorClassName)));
        } catch(Exception e) {
          throw new ConversionException("Error creating comparator: "+comaparatorClassName);
        }
      }

      // create TreeSet
      ret = (comparator!=null)
View Full Code Here

      parameterType = targetType.getJavaTypeParameter(1);
    }

    // bail if we don't have a parameter type
    if (parameterType==null) {
      throw new ConversionException(
        "Unable to determine parameter type for "+targetType);
    }

    // create and convert
    Map<String, Object> ret = new HashMap<String, Object>();
View Full Code Here

    } else if (targetType.is(BigInteger.class)) {
      return BigInteger.valueOf(source.longValue());
     
    }

    throw new ConversionException(
      "Unable to convert source Number to "+targetType);
  }
View Full Code Here

TOP

Related Classes of com.googlecode.mjorm.convert.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.