cast a Object to a Long Object(reference type)

@param o Object to cast
@return casted Long Object
@throws PageException
193467
public static Long toLong(Object o) throws PageException {
	if (o instanceof Long) return (Long) o;
	return Long.valueOf(toLongValue(o));

    }
200236
public static Character toCharacter(Object o) throws PageException {
	if (o instanceof Character) return (Character) o;
	return new Character(toCharValue(o));

    }
452210
public static String call(PageContext pc, Object object) throws PageException {
	return call(pc, object, null, true, 9999, null, null, null, null, 9999, true, true);
    }
1137032
public static short toShortValue(Object o) throws PageException {
	if (o instanceof Short) return ((Short) o).shortValue();
	else if (o instanceof CharSequence) return (short) toDoubleValue(o.toString());
	else if (o instanceof Character) return (short) (((Character) o).charValue());
	else if (o instanceof Boolean) return (short) ((((Boolean) o).booleanValue()) ? 1 : 0);
	else if (o instanceof Number) return (((Number) o).shortValue());
	else if (o instanceof Castable) return (short) ((Castable) o).castToDoubleValue();
	else if (o instanceof ObjectWrap) return toShortValue(((ObjectWrap) o).getEmbededObject());

	throw new CasterException(o, "short");
    }
641940
public static DateTime toDateAdvanced(Object o, TimeZone timezone) throws PageException {
	if (o instanceof Date) {
	    if (o instanceof DateTime) return (DateTime) o;
	    return new DateTimeImpl((Date) o);
	}
	else if (o instanceof Castable) return ((Castable) o).castToDateTime();
	else if (o instanceof String) {
	    DateTime dt = toDateAdvanced((String) o, timezone, null);
	    if (dt == null) throw new ExpressionException("can't cast [" + o + "] to date value");
	    return dt;
	}
	else if (o instanceof Number) return util.toDateTime(((Number) o).doubleValue());
	else if (o instanceof ObjectWrap) return toDateAdvanced(((ObjectWrap) o).getEmbededObject(), timezone);
	else if (o instanceof Calendar) {

	    return new DateTimeImpl((Calendar) o);
	}
	throw new ExpressionException("can't cast [" + Caster.toClassName(o) + "] to date value");
    }
374780
public static Boolean toBoolean(Object o) throws PageException {
	if (o instanceof Boolean) return (Boolean) o;
	return toBooleanValue(o) ? Boolean.TRUE : Boolean.FALSE;

    }
342048
public static long toLongValue(Object o, long defaultValue) {
	if (o instanceof Character) return (((Character) o).charValue());
	else if (o instanceof Boolean) return ((((Boolean) o).booleanValue()) ? 1L : 0L);
	else if (o instanceof Number) return (((Number) o).longValue());
	else if (o instanceof CharSequence) return (long) toDoubleValue(o.toString(), defaultValue);
	else if (o instanceof Castable) {
	    return (long) ((Castable) o).castToDoubleValue(defaultValue);
	}
	else if (o instanceof Character) return (long) (((Character) o).charValue());
	else if (o instanceof ObjectWrap) return toLongValue(((ObjectWrap) o).getEmbededObject(toLong(defaultValue)), defaultValue);

	return defaultValue;
    }
10957
public static QueryColumn toQueryColumn(Object o) throws PageException {
	if (o instanceof QueryColumn) return (QueryColumn) o;
	throw new CasterException(o, "querycolumn");
    }
983888
public void setType(String type) throws PageException {
	if (type == null) return;
	try {
	    this.type = toType(type);
	}
	catch (SearchException e) {
	    throw Caster.toPageException(e);
	}
    }
599430
public long getLong(int index) throws JSONException {
        Object object = this.get(index);
        try {
            return object instanceof Number ? ((Number) object).longValue()
                    : Long.parseLong((String) object);
        } catch (Exception e) {
            throw new JSONException("JSONArray[" + index + "] is not a number.");
        }
    }
503394
public static Double toDouble(Object o) throws PageException {
	if (o instanceof Double) return (Double) o;
	return new Double(toDoubleValue(o));

    }
355863
protected Ref assignOp() throws PageException {
	Ref ref = contOp();

	if (cfml.forwardIfCurrent('=')) {
	    cfml.removeSpace();
	    if (mode == STATIC || ref instanceof Literal) {
		ref = new DynAssign(ref, assignOp(), limited);
	    }
	    else {
		ref = new Assign(ref, assignOp(), limited);
	    }
	}
	return ref;
    }
1129263
@Override
    public <T> PagedResult<T> deserializeDataWrapper(Class<T> objectClass, java.io.InputStream inputStream) throws JSONSerializerException{
        Util.throwIfNull(objectClass, inputStream);

        PagedResult<T> rw = null;

        try {
            // Read the json input stream into a List.
            rw = OBJECT_MAPPER.readValue(inputStream,
                    OBJECT_MAPPER.getTypeFactory().constructParametrizedType(PagedResult.class, PagedResult.class, objectClass));
        } catch (JsonParseException e) {
            throw new JSONSerializerException(e);
        } catch (JsonMappingException e) {
            throw new JSONSerializerException(e);
        } catch (IOException e) {
            throw new JSONSerializerException(e);
        }

        return rw;
    }
465500
public static long getLong(JsonObject object, String field) {
        final JsonValue value = object.get(field);
        throwExceptionIfNull(value, field);
        return value.asLong();
    }
969220
public static Object toGUId(Object o) throws PageException {
	String str = toString(o);
	if (!Decision.isGUId(str)) throw new ExpressionException("can't cast [" + str + "] to guid value");
	return str;
    }
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;
	}
1244537
private static Object toQuery(Object obj) throws PageException {
	if (obj instanceof Struct) {
	    Struct sct = (Struct) obj;
	    Key[] keys = CollectionUtil.keys(sct);

	    // Columns
	    Key[] columns = null;
	    if (contains(keys, KeyConstants._COLUMNS)) columns = toColumns(sct.get(KeyConstants._COLUMNS, null));
	    else if (contains(keys, KeyConstants._COLUMNLIST)) columns = toColumnlist(sct.get(KeyConstants._COLUMNLIST, null));

	    // rowcount
	    int rowcount = -1;
	    if (contains(keys, ROWCOUNT)) rowcount = toRowCount(sct.get(ROWCOUNT, null));
	    else if (contains(keys, KeyConstants._RECORDCOUNT)) rowcount = toRowCount(sct.get(KeyConstants._RECORDCOUNT, null));

	    if (columns != null) {
		if (keys.length == 2 && contains(keys, KeyConstants._DATA)) {

		    Array[] data = toData(sct.get(KeyConstants._DATA, null), columns);
		    if (data != null) {
			return new QueryImpl(columns, data, "query");
		    }
		}

		else if (keys.length == 3 && rowcount != -1 && contains(keys, KeyConstants._DATA)) {
		    Array[] data = toData(sct.get(KeyConstants._DATA, null), columns, rowcount);
		    if (data != null) {
			return new QueryImpl(columns, data, "query");
		    }
		}
	    }
	    return toQuery(sct, keys);
	}
	/*
	 * else if(obj instanceof Query) { return toQuery((Query) obj); }
	 */
	else if (obj instanceof Collection) {
	    Collection coll = (Collection) obj;
	    return toQuery(coll, CollectionUtil.keys(coll));
	}

	return obj;

    }