Converts a srec value to a Java object.

@param value The value
@return The Java object
767569
public static Object convertToJava(Value value) {
        switch (value.getType()) {
            case STRING:
                return ((StringValue) value).get();
            case BOOLEAN:
                return ((BooleanValue) value).get();
            case NUMBER:
                return ((NumberValue) value).get();
            case DATE:
                return ((DateValue) value).get();
            case NIL:
                return null;
            case OBJECT:
                return value.get();
        }
        throw new CommandExecutionException("Could not convert value " + value + " to an equivalent Java object");
    }
740385
public Object call(Object value) {
        if (value == null) { return new Integer(0); }
        return new Integer(String.valueOf(value).length());
    }
1009831
public <T> T convert(String value, Class<T> to) {
        if (Strings.isEmpty(value) && !(String.class.equals(to) || String[].class.equals(to))) {
            return null;
        }

        if (String.class.equals(to)) {
            return to.cast(value);
        } else if (Integer.class.equals(to)) {
            return to.cast(Integer.valueOf(value));
        } else if (Double.class.equals(to)) {
            return to.cast(Double.valueOf(value));
        } else if (Long.class.equals(to)) {
            return to.cast(Long.valueOf(value));
        } else if (Boolean.class.equals(to)) {
            return to.cast(Boolean.valueOf(value));
        } else if (URL.class.equals(to)) {
            try {
                return to.cast(new URI(value).toURL());
            } catch (MalformedURLException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else if (URI.class.equals(to)) {
            try {
                return to.cast(new URI(value));
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException("Unable to convert value " + value + " to URL", e);
            }
        } else {
            String trimmedValue = extractEnumName(value);
            if (to.isEnum()) {
                return (T) Enum.valueOf((Class<Enum>) to, trimmedValue.toUpperCase());
            } else if (String[].class.equals(to)) {
                final String[] convertedArray = value.split(",");
                if (convertedArray.length == 0) {
                    return to.cast(new String[0]);
                }

                trimElements(convertedArray);

                if (convertedArray.length == 1 && hasOnlyBlanks(convertedArray)) {
                    return to.cast(new String[0]);
                }

                return to.cast(convertedArray);
            } else if (Charset.class.equals(to)) {
                return to.cast(Charset.forName(trimmedValue.toUpperCase()));
            } else if (Class.class.equals(to)) {
                try {
                    Object clazz = Class.forName(value);
                    return to.cast(clazz);
                } catch (Exception e) {
                    throw new IllegalArgumentException("Unable to find class [" + value + "].", e);
                }
            } else // Try to create instance via reflection
            {
                try {
                    Object instance = Class.forName(value).newInstance();
                    return to.cast(instance);
                } catch (Exception e) {
                    throw new IllegalArgumentException(
                        "Unable to convert value [" + value + "] to a class [" + to.getName() + "].", e);
                }
            }
        }
    }
173928
public T get(final T value) {
		expungeStaleEntries();
		//
		final int index = (value.hashCode() & 0x7FFFFFFF) % elementData.length;
		Entry<T> m = elementData[index];
		while (m != null) {
			if (eq(value, m.get())) {
				return m.get();
			}
			m = m.nextInSlot;
		}
		return null;
	}
184238
public static Instant parseJsonDate(String value) {
        if (value == null) {
            return null;
        }
        return LocalDateTime.parse(value, JSON_DATETIME_FORMAT).atOffset(ZoneOffset.UTC).toInstant();
    }
1009460
@Override
    public Object convertUponSet(
                    final Object value
                    )
    {
        Date  date = null;
        if (value != null) {
            try {
                date = _formatter.parse( (String)value );
            } catch (ParseException p_ex) {
                throw new IllegalArgumentException( p_ex.getMessage() );
            }
        }

        return date;
    }
547361
public static EntryElement makeEntryElement(Object value) {
        Class<?> type = ClassUtils.primitiveToWrapper(value.getClass());
        return new EntryElement(type.getName(), value.toString());
    }
494805
public static java.util.Date getDateTime(Object value) {
        try {
            return toDateTime(value);
        } catch (ParseException pe) {
            pe.printStackTrace();
            return null;
        }
    }
333745
public <T> T convert(Object value, Class<T> clazz) {
    if (null == value) return null;
    if (value instanceof String && Strings.isEmpty((String) value)) { return null; }
    if (value.getClass().isArray()) {
      Object[] values = (Object[]) value;
      if (values.length >= 1) {
        value = values[0];
      }
    }
    return conversion.convert(value, clazz);
  }
381401
def convert(value)
      case value
      when java.util.List then value.to_a
      when java.util.Set then value.to_set
      when java.util.Map then value.to_hash
      else value
      end
    end
531180
protected Object cast(Object value) {
        switch (type) {
            case STRING :
               return valueFactories.getStringFactory().create(value);
            case LONG :
                return valueFactories.getLongFactory().create(value);
            case NAME :
                return valueFactories.getNameFactory().create(value);
            case PATH :
                return valueFactories.getPathFactory().create(value);
            case DATE :
                return valueFactories.getDateFactory().create(value);
            case BOOLEAN :
                return valueFactories.getBooleanFactory().create(value);
            case URI :
                return valueFactories.getUriFactory().create(value);
            case REFERENCE :
                return valueFactories.getReferenceFactory().create(value);
            case SIMPLEREFERENCE :
                return valueFactories.getSimpleReferenceFactory().create(value);
            case WEAKREFERENCE :
                return valueFactories.getWeakReferenceFactory().create(value);
            default :
                return value;
        }
    }
1353421
public Object convertStringToJavaField(String value, int columnPos) throws SQLException {
		if (value == null) {
			return null;
		} else {
			return fieldConverter.resultStringToJava(this, value, columnPos);
		}
	}
1023650
private Object convert(Object value, Class type) {

		Object convertedObject = null;

		if (type.equals(String.class)) {

			// strings can be returned immediately
			return value.toString();

		} else if (value instanceof Number) {

			Number number = (Number) value;

			if (type.equals(Integer.class) || type.equals(Integer.TYPE)) {
				return number.intValue();

			} else if (type.equals(Long.class) || type.equals(Long.TYPE)) {
				return number.longValue();

			} else if (type.equals(Double.class) || type.equals(Double.TYPE)) {
				return number.doubleValue();

			} else if (type.equals(Float.class) || type.equals(Float.TYPE)) {
				return number.floatValue();

			} else if (type.equals(Short.class) || type.equals(Integer.TYPE)) {
				return number.shortValue();

			} else if (type.equals(Byte.class) || type.equals(Byte.TYPE)) {
				return number.byteValue();

			}

		} else if (value instanceof List) {

			return value;

		} else if (value instanceof Map) {
			return value;
		}

		// fallback
		try {

			Method valueOf = type.getMethod("valueOf", String.class);
			if (valueOf != null) {

				convertedObject = valueOf.invoke(null, value.toString());

			} else {

				logger.warn("Unable to find static valueOf method for type {}", type);
			}

		} catch (Throwable t) {

			logger.warn("Unable to deserialize value {} of type {}, Class has no static valueOf method.", new Object[]{value, type});
		}

		return convertedObject;
	}
582131
public JsonWriter jsonValue(String value) throws IOException {
    if (value == null) {
      return nullValue();
    }
    writeDeferredName();
    beforeValue();
    out.append(value);
    return this;
  }
155517
private JsonElement convertValue(String value, JsonObject dataType) {
    if (dataType == null || !dataType.has(TYPE)) {
      return new JsonPrimitive(value);
    }

    String type = dataType.get(TYPE).getAsString().toUpperCase();
    ValueType valueType = ValueType.valueOf(type);
    return valueType.convert(value);
  }
873203
public static NfsType fromValue(int value) {
        NfsType nfsType = VALUES.get(value);
        if (nfsType == null) {
            nfsType = new NfsType(value);
            VALUES.put(value, nfsType);
        }
        return nfsType;
    }
767238
public static String typeValueString(final Object value) {
        StringBuilder sb = new StringBuilder(valueString(value));
        return sb.append(" :").append(typeString(value)).toString();
    }