converts a object to a QueryColumn, if possible

@param o
@return
@throws PageException
10957
public static QueryColumn toQueryColumn(Object o) throws PageException {
	if (o instanceof QueryColumn) return (QueryColumn) o;
	throw new CasterException(o, "querycolumn");
    }
730418
public static Query toQuery(Object o, Query defaultValue) {
	if (o instanceof Query) return (Query) o;
	else if (o instanceof ObjectWrap) {
	    return toQuery(((ObjectWrap) o).getEmbededObject(defaultValue), defaultValue);
	}
	return defaultValue;
    }
18418
public static Object get(PageContext pc, Object coll, int[] types, Key[] keys, Object[][] args, Object defaultValue) throws PageException {
	if (coll == null) return defaultValue;
	int to = keys.length - 1;
	VariableUtilImpl vu = (VariableUtilImpl) pc.getVariableUtil();
	for (int i = 0; i <= to; i++) {
	    switch (types[i]) {
	    case TYPE_DATA:
		coll = vu.getCollection(pc, coll, keys[i], Null.NULL);
		break;
	    case TYPE_UDF_ARGS:
		coll = vu.callFunctionWithoutNamedValues(pc, coll, keys[i], args[i], false, Null.NULL);
		break;
	    case TYPE_UDF_NAMED_ARGS:
		coll = vu.callFunctionWithNamedValues(pc, coll, keys[i], args[i], false, Null.NULL);
		break;
	    case TYPE_BIF:
		coll = null;// TODO
		break;
	    }

	    if (coll == Null.NULL || (coll == null && i < to)) return defaultValue;
	}
	return coll;
    }
479344
public static TimeSpan toTimespan(Object o) throws PageException {
	TimeSpan ts = toTimespan(o, null);
	if (ts != null) return ts;

	throw new CasterException(o, "timespan");
    }
685917
public static double toDoubleValue(Object o) throws PageException {
	if (o instanceof Number) {
	    return ((Number) o).doubleValue();
	}
	else if (o instanceof Boolean) return ((Boolean) o).booleanValue() ? 1 : 0;
	else if (o instanceof CharSequence) return toDoubleValue(o.toString(), true);
	// else if(o instanceof Clob) return toDoubleValue(toString(o));
	else if (o instanceof Castable) return ((Castable) o).castToDoubleValue();
	else if (o == null) return 0;// toDoubleValue("");
	else if (o instanceof ObjectWrap) return toDoubleValue(((ObjectWrap) o).getEmbededObject());
	else if (o instanceof Date) return DateTimeUtil.getInstance().toDoubleValue(((Date) o).getTime());
	else if (o instanceof Calendar) return DateTimeUtil.getInstance().toDoubleValue(((Calendar) o).getTimeInMillis());
	else if (o instanceof Character) return (double) (((Character) o).charValue());
	throw new CasterException(o, "number");
    }
955108
public static Object castTo(PageContext pc, short type, Object o) throws PageException {
	if (type == CFTypes.TYPE_ANY) return o;
	else if (type == CFTypes.TYPE_ARRAY) return toArray(o);
	else if (type == CFTypes.TYPE_BOOLEAN) return toBoolean(o);
	else if (type == CFTypes.TYPE_BINARY) return toBinary(o);
	else if (type == CFTypes.TYPE_DATETIME) return DateCaster.toDateAdvanced(o, pc.getTimeZone());
	else if (type == CFTypes.TYPE_NUMERIC) return toDouble(o);
	else if (type == CFTypes.TYPE_QUERY) return toQuery(o);
	else if (type == CFTypes.TYPE_QUERY_COLUMN) return toQueryColumn(o);
	else if (type == CFTypes.TYPE_STRING) return toString(o);
	else if (type == CFTypes.TYPE_STRUCT) return toStruct(o);
	else if (type == CFTypes.TYPE_TIMESPAN) return toTimespan(o);
	else if (type == CFTypes.TYPE_UUID) return toGUId(o);
	else if (type == CFTypes.TYPE_UUID) return toUUId(o);
	else if (type == CFTypes.TYPE_VARIABLE_NAME) return toVariableName(o);
	else if (type == CFTypes.TYPE_VOID) return toVoid(o);
	else if (type == CFTypes.TYPE_FUNCTION) return toFunction(o);
	else if (type == CFTypes.TYPE_XML) return toXML(o);
	// ext.img else if(type==CFTypes.TYPE_IMAGE) return ImageUtil.toImage(pc,o,true);

	if (type == CFTypes.TYPE_UNDEFINED) throw new ExpressionException("type isn't defined (TYPE_UNDEFINED)");
	throw new ExpressionException("invalid type [" + type + "]");
    }
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;
    }
562211
public PageResult<Entity> page(Entity where, Page page) throws SQLException{
		return db.page(fixEntity(where), page);
	}
843355
private void _serialize(PageContext pc, Set test, Object object, StringBuilder sb, boolean serializeQueryByColumns, Set done) throws ConverterException {

	// NULL
	if (object == null || object == NULL) {
	    sb.append(goIn());
	    sb.append("null");
	    return;
	}
	// String
	if (object instanceof String || object instanceof StringBuilder) {
	    sb.append(goIn());
	    sb.append(StringUtil.escapeJS(object.toString(), '"', charsetEncoder));
	    return;
	}
	// TimeZone
	if (object instanceof TimeZone) {
	    sb.append(goIn());
	    sb.append(StringUtil.escapeJS(((TimeZone) object).getID(), '"', charsetEncoder));
	    return;
	}
	// Locale
	if (object instanceof Locale) {
	    sb.append(goIn());
	    sb.append(StringUtil.escapeJS(LocaleFactory.toString((Locale) object), '"', charsetEncoder));
	    return;
	}
	// Character
	if (object instanceof Character) {
	    sb.append(goIn());
	    sb.append(StringUtil.escapeJS(String.valueOf(((Character) object).charValue()), '"', charsetEncoder));
	    return;
	}
	// Number
	if (object instanceof Number) {
	    sb.append(goIn());
	    sb.append(Caster.toString(((Number) object)));
	    return;
	}
	// Boolean
	if (object instanceof Boolean) {
	    sb.append(goIn());
	    sb.append(Caster.toString(((Boolean) object).booleanValue()));
	    return;
	}
	// DateTime
	if (object instanceof DateTime) {
	    _serializeDateTime((DateTime) object, sb);
	    return;
	}
	// Date
	if (object instanceof Date) {
	    _serializeDate((Date) object, sb);
	    return;
	}
	// XML
	if (object instanceof Node) {
	    _serializeXML((Node) object, sb);
	    return;
	}
	// Timespan
	if (object instanceof TimeSpan) {
	    _serializeTimeSpan((TimeSpan) object, sb);
	    return;
	}
	// File
	if (object instanceof File) {
	    _serialize(pc, test, ((File) object).getAbsolutePath(), sb, serializeQueryByColumns, done);
	    return;
	}
	// String Converter
	if (object instanceof ScriptConvertable) {
	    sb.append(((ScriptConvertable) object).serialize());
	    return;
	}
	// byte[]
	if (object instanceof byte[]) {
	    sb.append("\"" + Base64Coder.encode((byte[]) object) + "\"");
	    return;
	}
431985
public static Object callWithNamedValues(PageContext pc, Object coll, Collection.Key methodName, Struct args, short type, String strType) throws PageException {
	Map<Key, FunctionLibFunction> members = getMembers(pc, type);
	FunctionLibFunction member = members.get(methodName);

	if (member != null) {
	    List<FunctionLibFunctionArg> _args = member.getArg();
	    FunctionLibFunctionArg arg;
	    if (args.size() < _args.size()) {
		Object val;
		ArrayList<Ref> refs = new ArrayList<Ref>();
		arg = _args.get(0);
		refs.add(new Casting(arg.getTypeAsString(), arg.getType(), new LFunctionValue(new LString(arg.getName()), coll)));
		for (int y = 1; y < _args.size(); y++) {
		    arg = _args.get(y);

		    // match by name
		    val = args.get(arg.getName(), null);

		    // match by alias
		    if (val == null) {
			String alias = arg.getAlias();
			if (!StringUtil.isEmpty(alias, true)) {
			    String[] aliases = lucee.runtime.type.util.ListUtil.trimItems(lucee.runtime.type.util.ListUtil.listToStringArray(alias, ','));
			    for (int x = 0; x < aliases.length; x++) {
				val = args.get(aliases[x], null);
				if (val != null) break;
			    }
			}
		    }

		    if (val == null) {
			if (arg.getRequired()) {
			    String[] names = member.getMemberNames();
			    String n = ArrayUtil.isEmpty(names) ? "" : names[0];
			    throw new ExpressionException("missing required argument [" + arg.getName() + "] for member function call [" + n + "]");
			}
		    }
		    else {
			refs.add(new Casting(arg.getTypeAsString(), arg.getType(), new LFunctionValue(new LString(arg.getName()), val)));
			// refs.add(new LFunctionValue(new LString(arg.getName()),new
			// Casting(pc,arg.getTypeAsString(),arg.getType(),val)));
		    }

		}
		return new BIFCall(coll, member, refs.toArray(new Ref[refs.size()])).getValue(pc);
	    }

	}
	throw new ExpressionException("No matching function member [" + methodName + "] for call with named arguments found, available function members are ["
		+ lucee.runtime.type.util.ListUtil.sort(CollectionUtil.getKeyList(members.keySet().iterator(), ","), "textnocase", "asc", ",") + "]");
    }
490932
public static String call(PageContext pc, Object var, boolean serializeQueryByColumns, String strCharset) throws PageException {
	Charset cs = StringUtil.isEmpty(strCharset) ? pc.getWebCharset() : CharsetUtil.toCharset(strCharset);
	return _call(pc, var, serializeQueryByColumns, cs);
    }
652369
public Boolean evaluate(Object o) {

        EntityClassReader classReader = EntityClassReader.getClassReaderFor(o.getClass());

        if (classReader.getPropertyType(propertyName) != Boolean.class)
                throw new RuntimeException("Property " + propertyName + " on object " + o + " is not of type Boolean");

        Object result = null;
        try {
            result = classReader.getPropertyValue(o, propertyName);
        }
        catch (InvalidObjectReaderException e) {
            ; // can never occur
        }

        return (Boolean)result;
    }
949976
public static Attr toAttr(Document doc, Object o) throws PageException {
	if (o instanceof Attr) return (Attr) o;
	if (o instanceof Struct && ((Struct) o).size() == 1) {
	    Struct sct = (Struct) o;
	    Entry<Key, Object> e = sct.entryIterator().next();
	    Attr attr = doc.createAttribute(e.getKey().getString());
	    attr.setValue(Caster.toString(e.getValue()));
	    return attr;
	}

	throw new XMLException("can't cast Object of type " + Caster.toClassName(o) + " to a XML Attribute");
    }
909329
public PageResult<Entity> page(Connection conn, Collection<String> fields, Entity where, int page, int numPerPage) throws SQLException {
		checkConn(conn);
		
		final int count = count(conn, where);
		PageResultHandler pageResultHandler = PageResultHandler.create(new PageResult<Entity>(page, numPerPage, count));
		return this.page(conn, fields, where, page, numPerPage, pageResultHandler);
	}
115971
public static Float toFloat(Object o) throws PageException {
	if (o instanceof Float) return (Float) o;
	return new Float(toFloatValue(o));
    }
826374
public static Object toCFTypex(SQLItem item) throws PageException {
	try {
	    return _toCFTypex(item);
	}
	catch (PageException e) {
	    if (item.isNulls()) return item.getValue();
	    throw e;
	}
    }
699652
public static Query toQuery(Object o, boolean duplicate, Query defaultValue) {
	try {
	    return toQuery(o, duplicate);
	}
	catch (PageException e) {
	    return defaultValue;
	}
    }