translate a string cfml type definition to a Type Object

@param cfType
@param axistype
@return
@throws PageException
771146
public static Type toType(Class type, boolean axistype) throws PageException {
	if (axistype) type = ((ConfigImpl) ThreadLocalPageContext.getConfig()).getWSHandler().toWSTypeClass(type);
	return Type.getType(type);
    }
699987
public static Iterator<ColumnFamily> pageRowLocally(final ColumnFamilyStore cfs, ByteBuffer key, final int pageSize)
    {
        SliceFromReadCommand command = new SliceFromReadCommand(cfs.metadata.ksName, key, cfs.name, System.currentTimeMillis(), new IdentityQueryFilter());
        final SliceQueryPager pager = new SliceQueryPager(command, null, null, true);

        return new Iterator<ColumnFamily>()
        {
            // We don't use AbstractIterator because we don't want hasNext() to do an actual query
            public boolean hasNext()
            {
                return !pager.isExhausted();
            }

            public ColumnFamily next()
            {
                try
                {
                    List<Row> rows = pager.fetchPage(pageSize);
                    ColumnFamily cf = rows.isEmpty() ? null : rows.get(0).cf;
                    return cf == null ? ArrayBackedSortedColumns.factory.create(cfs.metadata) : cf;
                }
                catch (Exception e)
                {
                    throw new RuntimeException(e);
                }
            }

            public void remove()
            {
                throw new UnsupportedOperationException();
            }
        };
    }
602624
public static Object call(PageContext pc, Object[] objArr) throws PageException {
	if (objArr.length < 3) throw new ExpressionException("invalid call of a CFML Based built in function");

	// translate arguments
	String filename = Caster.toString((((FunctionValue) objArr[0]).getValue()));
	Collection.Key name = KeyImpl.toKey((((FunctionValue) objArr[1]).getValue()));
	boolean isweb = Caster.toBooleanValue((((FunctionValue) objArr[2]).getValue()));

	// function from archive may come without mapping definition
	int offset = 3;
	String mappingName = "mapping-function";
	// clearly no mapping definition
	if (objArr.length > 3 && objArr[3] instanceof FunctionValue) {
	    FunctionValue fv = (FunctionValue) objArr[3];
	    if (fv.getName().equals("__mapping")) {
		mappingName = Caster.toString(fv.getValue());
		offset = 4;
	    }
	}

	UDF udf = loadUDF(pc, filename, mappingName, name, isweb);
	Struct meta = udf.getMetaData(pc);
	boolean callerScopes = (meta == null) ? false : Caster.toBooleanValue(meta.get("callerScopes", Boolean.FALSE), false);
	boolean caller = meta == null ? false : Caster.toBooleanValue(meta.get(KeyConstants._caller, Boolean.FALSE), false);

	Struct namedArguments = null, cs = null;
	if (callerScopes) {

	    cs = new StructImpl();
	    if (pc.undefinedScope().getCheckArguments()) {
		cs.set(KeyConstants._local, pc.localScope().duplicate(false));
		cs.set(KeyConstants._arguments, pc.argumentsScope().duplicate(false));
	    }
	}

	Object[] arguments = null;
	if (objArr.length <= offset) arguments = ArrayUtil.OBJECT_EMPTY;
	else if (objArr[offset] instanceof FunctionValue) {
	    FunctionValue fv;
	    namedArguments = new StructImpl(Struct.TYPE_LINKED);
	    if (callerScopes) namedArguments.setEL(KeyConstants._caller, cs);
	    else if (caller) namedArguments.setEL(KeyConstants._caller, Duplicator.duplicate(pc.undefinedScope(), false));
	    for (int i = offset; i < objArr.length; i++) {
		fv = toFunctionValue(name, objArr[i]);
		namedArguments.set(fv.getName(), fv.getValue());
	    }
	}
	else {
	    int off = (caller || callerScopes ? 3 : 4);
	    arguments = new Object[objArr.length - off];
	    if (callerScopes) arguments[0] = cs;
	    else if (caller) arguments[0] = Duplicator.duplicate(pc.undefinedScope(), false);
	    for (int i = offset; i < objArr.length; i++) {
		arguments[i - off] = toObject(name, objArr[i]);
	    }
	}
	// execute UDF
	if (namedArguments == null) {
	    return ((UDFImpl) udf).call(pc, name, arguments, false);
	}

	return ((UDFImpl) udf).callWithNamedValues(pc, name, namedArguments, false);
    }
1151958
private Ref xorOp() throws PageException {
	Ref ref = orOp();
	while (cfml.forwardIfCurrent("xor")) {
	    cfml.removeSpace();
	    ref = new Xor(ref, orOp(), limited);
	}
	return ref;
    }
826374
public static Object toCFTypex(SQLItem item) throws PageException {
	try {
	    return _toCFTypex(item);
	}
	catch (PageException e) {
	    if (item.isNulls()) return item.getValue();
	    throw e;
	}
    }
755004
private void doGetJavaCFXTags() throws PageException {
	Map map = config.getCFXTagPool().getClasses();
	lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._displayname, KeyConstants._sourcename, KeyConstants._readonly, KeyConstants._name,
		KeyConstants._class, KeyConstants._bundleName, KeyConstants._bundleVersion, KeyConstants._isvalid }, 0, "query");
	Iterator it = map.keySet().iterator();

	int row = 0;
	while (it.hasNext()) {
	    CFXTagClass tag = (CFXTagClass) map.get(it.next());
	    if (tag instanceof JavaCFXTagClass) {
		row++;
		qry.addRow(1);
		JavaCFXTagClass jtag = (JavaCFXTagClass) tag;
		qry.setAt(KeyConstants._displayname, row, tag.getDisplayType());
		qry.setAt(KeyConstants._sourcename, row, tag.getSourceName());
		qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(tag.isReadOnly()));
		qry.setAt(KeyConstants._isvalid, row, Caster.toBoolean(tag.isValid()));
		qry.setAt(KeyConstants._name, row, jtag.getName());
		qry.setAt(KeyConstants._class, row, jtag.getClassDefinition().getClassName());
		qry.setAt(KeyConstants._bundleName, row, jtag.getClassDefinition().getName());
		qry.setAt(KeyConstants._bundleVersion, row, jtag.getClassDefinition().getVersionAsString());
	    }

	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
908119
private static Object evaluateScript(final ActionContext actionContext, final GraphObject entity, final String engineName, final String script) throws FrameworkException {

		final ScriptEngineManager manager = new ScriptEngineManager();
		ScriptEngine engine = manager.getEngineByName(engineName);

		if (engine == null) {
			List<ScriptEngineFactory> factories = manager.getEngineFactories();

			for (ScriptEngineFactory factory : factories) {

				if (factory.getNames().contains(engineName)) {

					engine = factory.getScriptEngine();
					break;

				}

			}

		}


		if (engine == null) {
			throw new RuntimeException(engineName + " script engine could not be initialized. Check class path.");
		}

		final ScriptContext scriptContext = engine.getContext();
		final Bindings bindings           = new StructrScriptBindings(actionContext, entity);

		if (!(engine instanceof RenjinScriptEngine)) {
			scriptContext.setBindings(bindings, ScriptContext.GLOBAL_SCOPE);
		} else if (engine instanceof  RenjinScriptEngine) {

			engine.put("Structr", new StructrScriptObject(actionContext, entity));

		}

		StringWriter output = new StringWriter();
		scriptContext.setWriter(output);

		try {

			Object extractedValue = engine.eval(script);

			if (output != null && output.toString() != null && output.toString().length() > 0) {
				extractedValue = output.toString();
			}

			return extractedValue;

		} catch (final Throwable e) {

			if (!actionContext.getDisableVerboseExceptionLogging()) {
				logger.error("Error while processing {} script: {}", engineName, script, e);
			}

			throw new FrameworkException(422, e.getMessage());
		}

	}
576638
@Override
    public Object call(PageContext pc, Collection.Key key, Object[] arguments) throws PageException {
	// first check variables
	Object o = shadow.get(key);
	if (o instanceof UDFPlus) {
	    return ((UDFPlus) o).call(pc, key, arguments, false);
	}

	// then check in component
	Member m = component.getMember(access, key, false, false);
	if (m != null) {
	    if (m instanceof UDFPlus) return ((UDFPlus) m).call(pc, key, arguments, false);
	}

	return MemberUtil.call(pc, this, key, arguments, new short[] { CFTypes.TYPE_STRUCT }, new String[] { "struct" });
	// throw ComponentUtil.notFunction(component, key, m!=null?m.getValue():null,access);
    }
427357
public static QueryColumn toQueryColumn(Object o, PageContext pc) throws PageException {
	if (o instanceof QueryColumn) return (QueryColumn) o;
	if (o instanceof String) {
	    o = VariableInterpreter.getVariableAsCollection(pc, (String) o);
	    if (o instanceof QueryColumn) return (QueryColumn) o;
	}

	throw new CasterException(o, "querycolumn");
    }
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;
    }
1125868
@Override
    public Object call(PageContext pc, Key methodName, Object[] arguments) throws PageException {
	return MemberUtil.call(pc, this, methodName, arguments, new short[] { lucee.commons.lang.CFTypes.TYPE_QUERY }, new String[] { "query" });
	// return Reflector.callMethod(this,methodName,arguments);
    }
391554
private Ref eqvOp() throws PageException {
	Ref ref = xorOp();
	while (cfml.forwardIfCurrent("eqv")) {
	    cfml.removeSpace();
	    ref = new EQV(ref, xorOp(), limited);
	}
	return ref;
    }
808126
public void appendFooterHeaderStyleXMLToAutomaticStyle(final XMLUtil util,
														   final Appendable appendable, final Type pageSectionType) throws IOException {
		appendable.append("<style:").append(pageSectionType.getTypeName())
				.append("-style>");
		appendable.append("<style:header-footer-properties");
		util.appendAttribute(appendable, "fo:min-height", this.minHeight.toString());
		this.margins.appendXMLContent(util, appendable);
		appendable.append("/></style:").append(pageSectionType.getTypeName())
				.append("-style>");
	}
694069
@Scope(DocScope.IO)
    public <T> XBAutoMap<T> readAsMapOf(final Class<T> valueType) throws IOException {
        DefaultXPathBinder.validateEvaluationType(valueType);
        final Class<?> resourceAwareClass = ReflectionHelper.getDirectCallerClass();
        Document document = IOHelper.getDocumentFromURL(projector.config().createDocumentBuilder(), url, requestProperties, resourceAwareClass);
        InvocationContext invocationContext = new InvocationContext(null, null, null, null, null, valueType, projector);
        return new AutoMap<T>(document, invocationContext, valueType);
    }
1045663
public void setType(String type) throws ExpressionException {
	type = type.toLowerCase().trim();
	if (type.equals("exception")) {
	    errorPage.setType(ErrorPage.TYPE_EXCEPTION);
	}
	else if (type.equals("request")) {
	    errorPage.setType(ErrorPage.TYPE_REQUEST);
	}
	// else if(type.equals("validation")) this.type=VALIDATION;
	else throw new ExpressionException("invalid type [" + type + "] for tag error, use one of the following types [exception,request]");
    }
1018753
public static void applyXXEProtection(DocumentBuilderFactory factory) {
		Map<String, Boolean> features = new HashMap<String, Boolean>();
		features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
		features.put("http://xml.org/sax/features/external-general-entities", false);
		features.put("http://xml.org/sax/features/external-parameter-entities", false);
		features.put("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

		for (Map.Entry<String, Boolean> entry : features.entrySet()) {
			String feature = entry.getKey();
			Boolean value = entry.getValue();
			try {
				factory.setFeature(feature, value);
			} catch (ParserConfigurationException e) {
				//feature is not supported by the local XML engine, skip it
			}
		}

		factory.setXIncludeAware(false);
		factory.setExpandEntityReferences(false);
	}
138407
protected Object interpretPart(PageContext pc, ParserString cfml) throws PageException {
	this.cfml = cfml;
	init(pc);

	cfml.removeSpace();
	return assignOp().getValue(pc);
    }