Performs a type conversion according to the EL's rules.
173331
public static Object coerce(Object value, Class classe) throws JspException {
        try {
            // just delegate the call
            return Coercions.coerce(value, classe, logger);
        } catch (ELException ex) {
            throw new JspException(ex);
        }
    }
1036624
private Class<?> convertType(Class<?> old)
   {
      if (Boolean.class.equals(old))
      {
         return boolean.class;
      }
      else if (boolean.class.equals(old))
      {
         return Boolean.class;
      }
      else if (Byte.class.equals(old))
      {
         return byte.class;
      }
      else if (byte.class.equals(old))
      {
         return Byte.class;
      }
      else if (Short.class.equals(old))
      {
         return short.class;
      }
      else if (short.class.equals(old))
      {
         return Short.class;
      }
      else if (Integer.class.equals(old))
      {
         return int.class;
      }
      else if (int.class.equals(old))
      {
         return Integer.class;
      }
      else if (Long.class.equals(old))
      {
         return long.class;
      }
      else if (long.class.equals(old))
      {
         return Long.class;
      }
      else if (Float.class.equals(old))
      {
         return float.class;
      }
      else if (float.class.equals(old))
      {
         return Float.class;
      }
      else if (Double.class.equals(old))
      {
         return double.class;
      }
      else if (double.class.equals(old))
      {
         return Double.class;
      }
      else if (Character.class.equals(old))
      {
         return char.class;
      }
      else if (char.class.equals(old))
      {
         return Character.class;
      }

      return null;
   }
1316726
@SuppressWarnings("unchecked")
	public <T> T convertElement(ConversionContext context, Object source,
			TypeReference<T> destinationType) throws ConverterException {
		return (T) elementConverter.convert(context, source, destinationType);
	}
156581
private static Class<?> convertToObject(Class<?> type) {
        if (type == int.class) {
            return Integer.class;
        }
        else if (type == boolean.class) {
            return Boolean.class;
        }
        else if (type == byte.class) {
            return Byte.class;
        }
        else if (type == char.class) {
            return Character.class;
        }
        else if (type == short.class) {
            return Short.class;
        }
        else if (type == long.class) {
            return Long.class;
        }
        else if (type == float.class) {
            return Float.class;
        }
        else if (type == double.class) {
            return Double.class;
        }
        else if (type == void.class) {
            return Void.class;
        }
        else {
            return type;
        }
    }
436841
def _convert_type(self, data_type):
        '''
        
        '''
        if (data_type == 1) or (data_type == 41):
            dt_string = 'b'
        elif data_type == 2:
            dt_string = 'h'
        elif data_type == 4:
            dt_string = 'i'
        elif (data_type == 8) or (data_type == 33):
            dt_string = 'q'
        elif data_type == 11:
            dt_string = 'B'
        elif data_type == 12:
            dt_string = 'H'
        elif data_type == 14:
            dt_string = 'I'
        elif (data_type == 21) or (data_type == 44):
            dt_string = 'f'
        elif (data_type == 22) or (data_type == 45) or (data_type == 31):
            dt_string = 'd'
        elif (data_type == 32):
            dt_string = 'd'
        elif (data_type == 51) or (data_type == 52):
            dt_string = 's'
        return dt_string
927829
private static Object convert(Class<?> clazz, String value) {
      /* TODO create a new Converter class and move this method there for reuse */

        if (Integer.class.equals(clazz) || int.class.equals(clazz)) {
            return Integer.valueOf(value);
        } else if (Double.class.equals(clazz) || double.class.equals(clazz)) {
            return Double.valueOf(value);
        } else if (Long.class.equals(clazz) || long.class.equals(clazz)) {
            return Long.valueOf(value);
        } else if (Boolean.class.equals(clazz) || boolean.class.equals(clazz)) {
            return Boolean.valueOf(value);
        }

        return value;
    }
662466
protected static Object convertBasicValue(String value, Class<?> type) {
        if (type == null) {
            throw new IllegalArgumentException("Type cannot be null");
        }

        if (String.class.equals(type)) {
            return value;
        }

        if (value == null || value.trim().isEmpty()) {
            return null;
        }

        try {
            value = value.trim();
            if (Byte.class.equals(type)) {
                return Byte.parseByte(value);
            } else if (Short.class.equals(type)) {
                return Short.parseShort(value);
            } else if (Integer.class.equals(type)) {
                return Integer.parseInt(value);
            } else if (Long.class.equals(type)) {
                return Long.parseLong(value);
            } else if (BigInteger.class.equals(type)) {
                return new BigInteger(value);
            } else if (Float.class.equals(type)) {
                return Float.parseFloat(value);
            } else if (Double.class.equals(type)) {
                return Double.parseDouble(value);
            } else if (BigDecimal.class.equals(type)) {
                return new BigDecimal(value);
            } else if (Boolean.class.equals(type)) {
                return Boolean.parseBoolean(value);
            }
        } catch (Exception e) {
            throw new UniformException(String.format("Error while converting value %s to data type %s. Make sure the element has correct values and/or validators", value, type.getName()), e);
        }

        throw new UnsupportedOperationException("Could not convert value to unknown type: " + type.getName());
    }
164139
public static Object convertExample(String value, String type) {
        if (value == null) {
            return null;
        }

        try {
            switch (type) {
                case "integer":
                    return Integer.valueOf(value);
                case "number":
                    return Float.valueOf(value);
                case "boolean":
                    return Boolean.valueOf(value);
                case "string":
                    return value;
                default:
                    return value;
            }
        } catch (NumberFormatException e) {
            throw new RuntimeException(String.format("Value '%s' cannot be converted to '%s'", value, type), e);
        }
    }
526504
@Override
    public boolean supportsConvert(int fromType, int toType) throws SQLException {
        checkClosed();
        switch (fromType) {
        /*
         * ALL types can be converted to VARCHAR /VoltType.String
         */
        case java.sql.Types.VARCHAR:
        case java.sql.Types.VARBINARY:
        case java.sql.Types.TIMESTAMP:
        case java.sql.Types.OTHER:
            switch (toType) {
            case java.sql.Types.VARCHAR:
                return true;

            default:
                return false;
            }
        case java.sql.Types.TINYINT:
        case java.sql.Types.SMALLINT:
        case java.sql.Types.INTEGER:
        case java.sql.Types.BIGINT:
        case java.sql.Types.FLOAT:
        case java.sql.Types.DECIMAL:
            switch (toType) {
            case java.sql.Types.VARCHAR:
            case java.sql.Types.TINYINT:
            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.FLOAT:
            case java.sql.Types.DECIMAL:
                return true;

            default:
                return false;
            }
        default:
            return false;
        }
    }
740522
def convert_type(self, value, spec):
        
        data_type = spec.get('type', 'string').lower().strip()
        if data_type in ['bool', 'boolean']:
            return value.lower() in BOOL_TRUISH
        elif data_type in ['int', 'integer']:
            try:
                return int(value)
            except (ValueError, TypeError):
                return None
        elif data_type in ['float', 'decimal', 'real']:
            try:
                return float(value)
            except (ValueError, TypeError):
                return None
        elif data_type in ['date', 'datetime', 'timestamp']:
            if 'format' in spec:
                format_list = self._get_date_format_list(spec.get('format'))
                if format_list is None:
                    raise MappingException(
                        '%s format mapping is not valid: %r' %
                        (spec.get('column'), spec.get('format'))
                    )
                for format, precision in format_list:
                    try:
                        return {'value': datetime.strptime(value, format),
                                'value_precision': precision}
                    except (ValueError, TypeError):
                        pass
                return None
            else:
                try:
                    return parser.parse(value)
                except (ValueError, TypeError):
                    return None
        elif data_type == 'file':
            try:
                return self._get_file(value)
            except:
                raise
        return value
719097
def assign_literal(element, value):
        
        """
        # Searches for a conversion method specific to the type of value.
        helper = helpers.CAST_DICT.get(type(value), str)

        # Removes all children and attributes.
        element.clear()
        element.text = helper(value)
215512
def convert(self, value, _type):
        
        return self.type_convertors.get(_type, lambda x: x)(value)
338680
public static <T> T convertGenericToSpecificType(Class<?> type) {
		if (type == GrayI8.class)
			return (T) GrayU8.class;
		if (type == GrayI16.class)
			return (T) GrayS16.class;
		if (type == InterleavedI8.class)
			return (T) InterleavedU8.class;
		if (type == InterleavedI16.class)
			return (T) InterleavedS16.class;
		return (T) type;
	}
476558
@Override
  public <S, T> Convert<S, T> converter(Class<S> source, Class<T> target)
  {
    ConvertFrom<S> convertType = getOrCreate(source);
    
    return convertType.converter(target);
  }
1349609
protected
  Object convertArg(String val, Class type) {
    if(val == null)
      return null;

    String v = val.trim();
    if (String.class.isAssignableFrom(type)) {
      return val;
    } else if (Integer.TYPE.isAssignableFrom(type)) {
      return new Integer(v);
    } else if (Long.TYPE.isAssignableFrom(type)) {
      return new Long(v);
    } else if (Boolean.TYPE.isAssignableFrom(type)) {
      if ("true".equalsIgnoreCase(v)) {
        return Boolean.TRUE;
      } else if ("false".equalsIgnoreCase(v)) {
        return Boolean.FALSE;
      }
    } else if (Priority.class.isAssignableFrom(type)) {
      return OptionConverter.toLevel(v, (Level) Level.DEBUG);
    } else if (ErrorHandler.class.isAssignableFrom(type)) {
      return OptionConverter.instantiateByClassName(v,
	  ErrorHandler.class, null);
    }
    return null;
  }
915927
public <T> T convert(Object value, Class<T> type) {
		return converter.convert(value, type);
	}
1030548
public <T> T convert(Object source, TypeReference<T> typeReference)
			throws ConverterException {
		return (T) convert(new ConversionContext(), source, typeReference);
	}