Search in sources :

Example 36 with UDF

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;
}
Also used : UDF(lucee.runtime.type.UDF) Comparator(java.util.Comparator)

Example 37 with UDF

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);
    }
}
Also used : InterfaceImpl(lucee.runtime.InterfaceImpl) UDF(lucee.runtime.type.UDF)

Example 38 with UDF

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());
    }
}
Also used : Entry(java.util.Map.Entry) ComponentScope(lucee.runtime.ComponentScope) UDF(lucee.runtime.type.UDF) ComponentSpecificAccess(lucee.runtime.ComponentSpecificAccess) Key(lucee.runtime.type.Collection.Key)

Example 39 with UDF

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() });
        }
    }
}
Also used : Entry(java.util.Map.Entry) UDF(lucee.runtime.type.UDF) Key(lucee.runtime.type.Collection.Key)

Example 40 with UDF

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);
    }
}
Also used : UDF(lucee.runtime.type.UDF) MissingIncludeException(lucee.runtime.exp.MissingIncludeException) PageContextImpl(lucee.runtime.PageContextImpl) PageSource(lucee.runtime.PageSource)

Aggregations

UDF (lucee.runtime.type.UDF)42 Key (lucee.runtime.type.Collection.Key)14 Struct (lucee.runtime.type.Struct)14 Component (lucee.runtime.Component)9 Entry (java.util.Map.Entry)7 PageException (lucee.runtime.exp.PageException)7 Member (lucee.runtime.component.Member)6 FunctionArgument (lucee.runtime.type.FunctionArgument)6 StructImpl (lucee.runtime.type.StructImpl)6 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)6 Iterator (java.util.Iterator)5 ComponentScope (lucee.runtime.ComponentScope)5 ComponentSpecificAccess (lucee.runtime.ComponentSpecificAccess)5 PageContextImpl (lucee.runtime.PageContextImpl)5 Property (lucee.runtime.component.Property)5 Array (lucee.runtime.type.Array)5 Collection (lucee.runtime.type.Collection)5 IOException (java.io.IOException)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3