use of lucee.runtime.type.UDF in project Lucee by lucee.
the class UDFComparator method call.
public static boolean call(PageContext pc, Array arr, Object sortTypeOrClosure, String sortorder, boolean localeSensitive) throws PageException {
// Comparator
Comparator comp;
if (sortTypeOrClosure instanceof UDF)
comp = new UDFComparator(pc, (UDF) sortTypeOrClosure);
else
comp = ArrayUtil.toComparator(pc, Caster.toString(sortTypeOrClosure), sortorder, localeSensitive);
arr.sortIt(comp);
return true;
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class AbstractFinal method add.
public void add(List<InterfaceImpl> interfaces) {
// add all interfaces to a flat structure
Iterator<InterfaceImpl> it = interfaces.iterator();
Iterator<UDF> iit;
InterfaceImpl inter;
UDF udf;
while (it.hasNext()) {
inter = it.next();
List<InterfaceImpl> parents = inter._getExtends();
// first add the parents, so children can overwrite functions with same name
if (!ArrayUtil.isEmpty(parents))
add(parents);
// UDFs
iit = inter.getUDFIt();
while (iit.hasNext()) {
udf = iit.next();
add(udf);
}
// this is add to a map to ensure we have every interface only once
this.interfaces.put(inter.getPageSource().getDisplayPath(), inter);
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class EvaluateComponent method setInternalState.
public static void setInternalState(Component comp, Struct sctThis, Struct sctVariables) throws PageException {
// this
// delete this scope data members
ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, comp);
Collection.Key[] cwKeys = CollectionUtil.keys(cw);
Object member;
for (int i = 0; i < cwKeys.length; i++) {
member = cw.get(cwKeys[i]);
if (member instanceof UDF)
continue;
cw.removeEL(cwKeys[i]);
}
// set this scope data members
Iterator<Entry<Key, Object>> it = sctThis.entryIterator();
Entry<Key, Object> e;
// keys = sctThis.keys();
while (it.hasNext()) {
e = it.next();
comp.set(e.getKey(), e.getValue());
}
// Variables
ComponentScope scope = comp.getComponentScope();
// delete variables scope data members
Key[] sKeys = CollectionUtil.keys(scope);
for (int i = 0; i < sKeys.length; i++) {
if (KeyConstants._this.equals(sKeys[i]))
continue;
if (scope.get(sKeys[i]) instanceof UDF)
continue;
scope.removeEL(sKeys[i]);
}
// set variables scope data members
it = sctVariables.entryIterator();
// keys = sctVariables.keys();
while (it.hasNext()) {
e = it.next();
scope.set(e.getKey(), e.getValue());
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class EntityNew method setPropeties.
public static void setPropeties(PageContext pc, Component c, Struct properties, boolean ignoreNotExisting) throws PageException {
if (properties == null)
return;
// argumentCollection
if (properties.size() == 1 && properties.containsKey(KeyConstants._argumentCollection) && !c.containsKey(KeyConstants._setArgumentCollection)) {
properties = Caster.toStruct(properties.get(KeyConstants._argumentCollection));
}
Iterator<Entry<Key, Object>> it = properties.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
Key funcName = KeyImpl.init("set" + e.getKey().getString());
if (ignoreNotExisting) {
if (c.get(funcName, null) instanceof UDF)
;
c.call(pc, funcName, new Object[] { e.getValue() });
} else {
c.call(pc, funcName, new Object[] { e.getValue() });
}
}
}
use of lucee.runtime.type.UDF in project Lucee by lucee.
the class ClassicAppListener method _onRequest.
static void _onRequest(PageContext pc, PageSource requestedPage, PageSource application, RequestListener rl) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
pci.setAppListenerType(ApplicationListener.TYPE_CLASSIC);
// on requestStart
if (application != null)
pci._doInclude(new PageSource[] { application }, false, null);
if (rl != null) {
requestedPage = rl.execute(pc, requestedPage);
if (requestedPage == null)
return;
}
// request
try {
pci._doInclude(new PageSource[] { requestedPage }, false, null);
} catch (MissingIncludeException mie) {
ApplicationContext ac = pc.getApplicationContext();
boolean rethrow = true;
if (ac instanceof ClassicApplicationContext) {
ClassicApplicationContext cfc = (ClassicApplicationContext) ac;
UDF udf = cfc.getOnMissingTemplate();
if (udf != null) {
String targetPage = requestedPage.getRealpathWithVirtual();
rethrow = (!Caster.toBooleanValue(udf.call(pc, new Object[] { targetPage }, true), true));
}
}
if (rethrow)
throw mie;
}
// on Request End
if (application != null) {
PageSource onReqEnd = application.getRealPage(Constants.CFML_CLASSIC_APPLICATION_END_EVENT_HANDLER);
if (onReqEnd.exists())
pci._doInclude(new PageSource[] { onReqEnd }, false, null);
}
}
Aggregations