Search in sources :

Example 1 with KeyImpl

use of lucee.runtime.type.KeyImpl in project Lucee by lucee.

the class Filter method invoke.

private static Collection invoke(PageContext pc, StringListData sld, UDF udf, ExecutorService es, List<Future<Data<Pair<Object, Object>>>> futures) throws CasterException, PageException {
    Array arr = ListUtil.listToArray(sld.list, sld.delimiter, sld.includeEmptyFieldsx, sld.multiCharacterDelimiter);
    Array rtn = new ArrayImpl();
    Iterator it = (arr instanceof ArrayPro ? ((ArrayPro) arr).entryArrayIterator() : arr.entryIterator());
    Entry e;
    KeyImpl k = null;
    boolean async = es != null;
    Object res;
    while (it.hasNext()) {
        e = (Entry) it.next();
        res = _inv(pc, udf, new Object[] { e.getValue(), Caster.toDoubleValue(e.getKey()), sld.list, sld.delimiter }, e.getKey(), e.getValue(), es, futures);
        if (!async && Caster.toBooleanValue(res)) {
            rtn.append(e.getValue());
        }
    }
    return rtn;
}
Also used : Array(lucee.runtime.type.Array) Entry(java.util.Map.Entry) ArrayImpl(lucee.runtime.type.ArrayImpl) KeyImpl(lucee.runtime.type.KeyImpl) ListIterator(java.util.ListIterator) ForEachQueryIterator(lucee.runtime.type.it.ForEachQueryIterator) Iterator(java.util.Iterator) ArrayPro(lucee.runtime.type.ArrayPro)

Example 2 with KeyImpl

use of lucee.runtime.type.KeyImpl in project Lucee by lucee.

the class KeyConstants method getKey.

public static Key getKey(String key) {
    init();
    Key k = _____keys.get(key);
    if (k == null)
        return new KeyImpl(key);
    return k;
}
Also used : KeyImpl(lucee.runtime.type.KeyImpl) Key(lucee.runtime.type.Collection.Key)

Example 3 with KeyImpl

use of lucee.runtime.type.KeyImpl in project Lucee by lucee.

the class AppListenerUtil method toWSType.

public static short toWSType(String wstype) throws ApplicationException {
    String str = "";
    KeyImpl cs = new KeyImpl(str) {

        public String getString() {
            return null;
        }
    };
    short wst = toWSType(wstype, (short) -1);
    if (wst != -1)
        return wst;
    throw new ApplicationException("invalid webservice type [" + wstype + "], valid values are [axis1]");
// throw new ApplicationException("invalid webservice type ["+wstype+"], valid values are [axis1,jax-ws,cxf]");
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) KeyImpl(lucee.runtime.type.KeyImpl)

Example 4 with KeyImpl

use of lucee.runtime.type.KeyImpl in project Lucee by lucee.

the class HashMapPro method hash.

/**
 * Retrieve object hash code and applies a supplemental hash function to the
 * result hash, which defends against poor quality hash functions.  This is
 * critical because HashMap uses power-of-two length hash tables, that
 * otherwise encounter collisions for hashCodes that do not differ
 * in lower bits. Note: Null keys always map to hash 0, thus index 0.
 */
static final int hash(Object k) {
    if (k instanceof KeyImpl)
        return ((KeyImpl) k).slotForMap();
    int h = 0;
    /*if (useAltHashing) {
            if (k instanceof String) {
                return Hashing.stringHash32((String) k);
            }
            h = hashSeed;
        }*/
    h ^= k.hashCode();
    // This function ensures that hashCodes that differ only by
    // constant multiples at each bit position have a bounded
    // number of collisions (approximately 8 at default load factor).
    h ^= (h >>> 20) ^ (h >>> 12);
    return h ^ (h >>> 7) ^ (h >>> 4);
}
Also used : KeyImpl(lucee.runtime.type.KeyImpl) lucee.aprint(lucee.aprint)

Aggregations

KeyImpl (lucee.runtime.type.KeyImpl)4 Iterator (java.util.Iterator)1 ListIterator (java.util.ListIterator)1 Entry (java.util.Map.Entry)1 lucee.aprint (lucee.aprint)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 Array (lucee.runtime.type.Array)1 ArrayImpl (lucee.runtime.type.ArrayImpl)1 ArrayPro (lucee.runtime.type.ArrayPro)1 Key (lucee.runtime.type.Collection.Key)1 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)1