cast a Object to a Double Object (reference Type)

@param o Object to cast
@return casted Double Object
@throws PageException
503394
public static Double toDouble(Object o) throws PageException {
	if (o instanceof Double) return (Double) o;
	return new Double(toDoubleValue(o));

    }
1232690
public static Clob toClob(Connection conn, Object value) throws PageException, SQLException {
	if (value instanceof Clob) return (Clob) value;
	// Java >= 1.6
	if (SystemUtil.JAVA_VERSION >= SystemUtil.JAVA_VERSION_6) {
	    Clob clob = conn.createClob();
	    clob.setString(1, Caster.toString(value));
	    return clob;
	}

	// Java < 1.6
	if (isOracle(conn)) {
	    Clob clob = OracleClob.createClob(conn, Caster.toString(value), null);
	    if (clob != null) return clob;
	}
	return ClobImpl.toClob(value);
    }
1247996
public static Object recordcount(PageContext pc, Object obj) throws PageException {
	if (obj instanceof Query) return Caster.toDouble(((Query) obj).getRecordcount());
	return pc.getCollection(obj, KeyConstants._RECORDCOUNT);
    }
407777
public static function castPjbInternal($javaObject, string $cast_type)
    {
        if ($javaObject instanceof JavaType) {
            return $javaObject->__cast($cast_type);
        }

        // mixed (string | int | bool)
        $first_char = strtoupper($cast_type[0]);
        switch ($first_char) {
            case 'S':
                return (string) $javaObject;
            case 'B':
                return (bool) $javaObject;
            case 'L':
            case 'I':
                return (int) $javaObject;
            case 'D':
            case 'F':
                return (float) $javaObject;
            case 'N':
                return null;
            case 'A':
                return (array) $javaObject;
            case 'O':
                return (object) $javaObject;
        }
    }
1187490
public static <T> T prop(JavaScriptObject o, Object id, Class<? extends T> type) {
    return o == null ? null : o.<JsCache> cast().get(id, type);
  }
682388
public static Object copy(Object o)
	{
		if (o instanceof java.io.Serializable)
		{
			try
			{
				ByteArrayOutputStream bs = new ByteArrayOutputStream(128);
				ObjectOutputStream dos = new ObjectOutputStream(bs);
				dos.writeObject(o);
				ByteArrayInputStream is = new ByteArrayInputStream(bs.toByteArray());
				ObjectInputStream ios = new ObjectInputStream(is);
				Object copy = ios.readObject();
				return copy;

			}
			catch (IOException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			catch (ClassNotFoundException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}

		return null;
	}
374473
private Ref impOp() throws PageException {
	Ref ref = eqvOp();
	while (cfml.forwardIfCurrentAndNoWordAfter("imp")) {
	    cfml.removeSpace();
	    ref = new Imp(ref, eqvOp(), limited);
	}
	return ref;
    }
325855
public static String toVariableName(Object o) throws PageException {
	String str = toString(o);
	if (!Decision.isVariableName(str)) throw new ExpressionException("can't cast [" + str + "] to variable name value");
	return str;
    }
353772
public static JsonElement wrap(Object o) throws JsonException {
        if (o == null) {
            //null value means not specified i.e.-> no valued will be mapped
            //Json.null is specific value
            return null;
        }
        if (o instanceof JsonElement) {
            return (JsonElement) o;
        }
        if (o instanceof ElementWrapper) {
            return ((ElementWrapper) o).getJson();
        }
        if (o instanceof Collection) {
            return new JsonArray((Collection) o);
        } else if (o.getClass().isArray()) {
            return new JsonArray(o);
        }
        if (o instanceof Map) {
            return new JsonObject((Map) o);
        }
        if (o instanceof Boolean) {
            return new JsonBoolean((Boolean) o);
        }
        if (o instanceof Number) {
            return new JsonNumber((Number) o);
        }
        if (o instanceof String) {
            return new JsonString((String) o);
        }
        if (o instanceof Character) {
            return new JsonString(Character.toString((Character) o));
        }
        if (o instanceof ByteBuffer) {
            return new JsonString(((ByteBuffer) o).asCharBuffer().toString());
        }

        return new JsonString(o.toString());
    }
826374
public static Object toCFTypex(SQLItem item) throws PageException {
	try {
	    return _toCFTypex(item);
	}
	catch (PageException e) {
	    if (item.isNulls()) return item.getValue();
	    throw e;
	}
    }
704565
public static Comment toComment(Document doc, Object o) throws PageException {
	if (o instanceof Comment) return (Comment) o;
	else if (o instanceof CharacterData) return doc.createComment(((CharacterData) o).getData());
	return doc.createComment(Caster.toString(o));
    }
193467
public static Long toLong(Object o) throws PageException {
	if (o instanceof Long) return (Long) o;
	return Long.valueOf(toLongValue(o));

    }
714181
public static Query toQuery(Object o) throws PageException {
	if (o instanceof Query) return (Query) o;
	if (o instanceof ObjectWrap) {
	    return toQuery(((ObjectWrap) o).getEmbededObject());
	}
	if (o instanceof ResultSet) return new QueryImpl((ResultSet) o, "query", ThreadLocalPageContext.getTimeZone());
	if (o instanceof Component) {
	    Member member = ((Component) o).getMember(Component.ACCESS_PRIVATE, KeyConstants.__toQuery, false, false);
	    if (member instanceof UDFPlus) {
		UDFPlus udf = (UDFPlus) member;
		if (udf.getReturnType() == CFTypes.TYPE_QUERY && udf.getFunctionArguments().length == 0) {
		    return Caster.toQuery(((Component) o).call(ThreadLocalPageContext.get(), KeyConstants.__toQuery, new Object[] {}));
		}
	    }
	}

	throw new CasterException(o, "query");
    }
1150890
public static Component toComponent(Object o) throws PageException {
	if (o instanceof Component) return (Component) o;
	else if (o instanceof ObjectWrap) {
	    return toComponent(((ObjectWrap) o).getEmbededObject());
	}
	throw new CasterException(o, "Component");
    }
651927
public static Object toNull(Object value) throws PageException {
	if (value == null) return null;
	if (value instanceof String && Caster.toString(value).trim().length() == 0) return null;
	if (value instanceof Number && ((Number) value).intValue() == 0) return null;
	throw new CasterException(value, "null");
    }
406421
public static String call(PageContext pc, Object object) throws PageException {
	if (StringUtil.isEmpty(object)) object = Constants.DOUBLE_ZERO;
	return Caster.toDecimal(object);
    }
504152
public static Object getField(Object obj, String prop) throws PageException {
	try {
	    return getFieldsIgnoreCase(obj.getClass(), prop)[0].get(obj);
	}
	catch (Throwable e) {
	    ExceptionUtil.rethrowIfNecessary(e);
	    throw Caster.toPageException(e);
	}
    }