public static Object asType(Object typeKey, Object value)
	{
		if (value==null) {
			return null;
		}

		if (typeKey==null) {
			return value;
		}

		// Check if the provided value is already of the target type
		if (typeKey instanceof Class && ((Class)typeKey)!=Object.class)
		{
			if (((Class)typeKey).isInstance(value)) {
				return value;
			}
		}

		// Find the type conversion object
		TypeConversion conversion;
		if (value instanceof ConvertibleType) {
			conversion=((ConvertibleType)value).getTypeConversion(typeKey);
		}
		else {
			conversion=typeConversions.get(typeKey);
		}

		// Convert the value
		if (conversion!=null)
		{
			if (value instanceof Listener)
			{
				((Listener)value).beforeConversion(typeKey);
				return ((Listener)value).afterConversion(typeKey,
					conversion.convertValue(value));
			}
			else {
				return conversion.convertValue(value);
			}
		}
		else {
			throw new IllegalArgumentException("Could not find type "+
				"conversion for type \""+typeKey+"\" (value = \""+value+"\"");
		}
	}