Package com.googlecode.mjorm.convert

Examples of com.googlecode.mjorm.convert.JavaType


  public <T> Object unmapValue(T object) throws MjormException {
    try {
      if (object==null) {
        return null;
      }
      JavaType storageType = conversionContext.getStorageType(object.getClass());
      return conversionContext.convert(object, storageType);
    } catch(ConversionException ce) {
      throw new MjormException(ce);
    }
  }
View Full Code Here


    BasicDBList ret = new BasicDBList();
    for (Object value : source) {
      if (value!=null) {

        // get storage type
        JavaType storageType = context.getStorageType(value.getClass());

        // convert
        value = context.convert(value, storageType);
      }
      ret.add(value);
View Full Code Here

  public Object[] convert(
    BasicDBList source, JavaType targetType, ConversionContext context, TypeConversionHints hints)
    throws ConversionException {

    // get component type of array
    JavaType componentType = null;
    Type[] types = hints.get(TypeConversionHints.HINT_GENERIC_TYPE_PARAMETERS);
    if (types!=null && types.length>0) {
      componentType = JavaType.fromType(types[0]);
    }
    if (componentType==null) {
      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());

    // iterate and convert
    for (int i=0; i<source.size(); i++) {
      Object value = source.get(i);
      if (value!=null) {
View Full Code Here

    // iterate and convert
    for (int i=0; i<source.length; i++) {
      Object value = source[i];
      if (value!=null) {
        JavaType storageType = context.getStorageType(value.getClass());
        value = context.convert(value, storageType);
      }
      ret.add(value);
    }
View Full Code Here

  public Collection<?> convert(
    BasicDBList source, JavaType targetType, ConversionContext context, TypeConversionHints hints)
    throws ConversionException {

    // get parameter type
    JavaType parameterType = null;
    Type[] types = hints.get(TypeConversionHints.HINT_GENERIC_TYPE_PARAMETERS);
    if (types!=null && types.length>0) {
      parameterType = JavaType.fromType(types[0]);
    }
    if (parameterType==null) {
View Full Code Here

  public Map<String, Object> convert(
    BasicDBObject source, JavaType targetType, ConversionContext context, TypeConversionHints hints)
    throws ConversionException {

    // get parameter types
    JavaType parameterType = null;
    Type[] types = hints.get(TypeConversionHints.HINT_GENERIC_TYPE_PARAMETERS);
    if (types!=null && types.length>1) {
      parameterType = JavaType.fromType(types[1]);
    }
    if (parameterType==null) {
View Full Code Here

      Object value = entry.getValue();
     
      if (value!=null) {

        // get storage type
        JavaType storageType = context.getStorageType(value.getClass());

        // convert
        value = context.convert(entry.getValue(), storageType);
      }
     
View Full Code Here

          // convert it
          if (value!=null) {

            // get storage type
            JavaType storageType = prop.getStorageType();
            if (storageType==null && value!=null) {
              storageType = context.getStorageType(value.getClass());
            }

            // convert
View Full Code Here

TOP

Related Classes of com.googlecode.mjorm.convert.JavaType

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.