Example usage for org.apache.commons.collections4 MapIterator getValue

List of usage examples for org.apache.commons.collections4 MapIterator getValue

Introduction

In this page you can find the example usage for org.apache.commons.collections4 MapIterator getValue.

Prototype

V getValue();

Source Link

Document

Gets the current value, which is the value associated with the last key returned by next().

Usage

From source file:at.bitfire.davdroid.MemoryCookieStore.java

@Override
public List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> cookies = new LinkedList<>();

    synchronized (storage) {
        MapIterator<MultiKey<? extends String>, Cookie> iter = storage.mapIterator();
        while (iter.hasNext()) {
            iter.next();//from  w  w  w .j a  v a2 s.co m
            Cookie cookie = iter.getValue();

            // remove expired cookies
            if (cookie.expiresAt() <= System.currentTimeMillis()) {
                iter.remove();
                continue;
            }

            // add applicable cookies
            if (cookie.matches(url))
                cookies.add(cookie);
        }
    }

    return cookies;
}

From source file:com.pungwe.db.io.store.InstanceCachingStore.java

private void flushCache() throws IOException {
    LRUMap<Long, Record<?>> current = cache;
    cache = new LRUMap<Long, Record<?>>(cacheSize);
    MapIterator<Long, Record<?>> it = current.mapIterator();
    while (it.hasNext()) {
        Long key = it.next();//  w  w w  . j  av  a  2 s  .  co  m
        Record<Object> value = (Record<Object>) it.getValue();
        store.update(key, value.value, value.serializer);
    }
}

From source file:Model.CacheInMemory.java

@SuppressWarnings("unchecked")
public void cleanup() {

    long now = System.currentTimeMillis();
    ArrayList<K> deleteKey = null;

    synchronized (cacheMap) {
        MapIterator itr = cacheMap.mapIterator();

        deleteKey = new ArrayList<K>((cacheMap.size() / 2) + 1);
        K key = null;/*from   ww  w  .  j  av a  2 s . c  o m*/
        CacheObject c = null;

        while (itr.hasNext()) {
            key = (K) itr.next();
            c = (CacheObject) itr.getValue();

            if (c != null && (now > (timeToLive + c.lastAccessed))) {
                deleteKey.add(key);
            }
        }
    }

    for (K key : deleteKey) {
        synchronized (cacheMap) {
            cacheMap.remove(key);
        }

        Thread.yield();
    }
}

From source file:imitationLearning.WordSequenceCache.java

/**
 *
 *//*from  w  ww .j  a v  a2 s.  c o m*/
@SuppressWarnings("unchecked")
public void cleanup() {

    long now = System.currentTimeMillis();
    ArrayList<K> deleteKey = null;

    synchronized (cacheMap) {
        MapIterator itr = cacheMap.mapIterator();

        deleteKey = new ArrayList<K>((cacheMap.size() / 2) + 1);
        K key = null;
        CacheObject c = null;

        while (itr.hasNext()) {
            key = (K) itr.next();
            c = (CacheObject) itr.getValue();

            if (c != null && (now > (timeToLive + c.lastAccessed))) {
                deleteKey.add(key);
            }
        }
    }

    for (K key : deleteKey) {
        synchronized (cacheMap) {
            cacheMap.remove(key);
        }

        Thread.yield();
    }
}

From source file:com.joyent.manta.http.MantaHttpHeaders.java

/**
 * Returns the headers as an array of {@link org.apache.http.Header} instances.
 *
 * @return an array of {@link org.apache.http.Header} instances
 *///  ww  w.j  av a2s  .  c  o  m
public Header[] asApacheHttpHeaders() {
    if (wrappedHeaders.isEmpty()) {
        return new Header[0];
    }

    final int length = wrappedHeaders.size();
    final Header[] headers = new Header[length];
    final MapIterator<String, Object> itr = wrappedHeaders.mapIterator();

    int i = 0;
    while (itr.hasNext()) {
        String key = itr.next();
        Object val = itr.getValue();

        final HeaderGroup extracted = parseHeaderKeyValue(key, val);
        headers[i++] = extracted.getCondensedHeader(key);
    }

    if (length == i) {
        return headers;
    }

    return Arrays.copyOfRange(headers, 0, i);
}

From source file:org.tasks.caldav.MemoryCookieStore.java

@Override
public List<Cookie> loadForRequest(HttpUrl url) {
    List<Cookie> cookies = new LinkedList<>();

    synchronized (storage) {
        MapIterator<MultiKey<? extends String>, Cookie> iter = storage.mapIterator();
        while (iter.hasNext()) {
            iter.next();/*from  ww  w  .  j  a v a  2 s . co m*/
            Cookie cookie = iter.getValue();

            // remove expired cookies
            if (cookie.expiresAt() <= System.currentTimeMillis()) {
                iter.remove();
                continue;
            }

            // add applicable cookies
            if (cookie.matches(url)) {
                cookies.add(cookie);
            }
        }
    }

    return cookies;
}

From source file:uniol.apt.ui.impl.returns.IsomorphismReturnValueTransformation.java

@Override
public void transform(Writer output, Isomorphism isomorphism) throws IOException {
    boolean first = true;

    output.append("[");
    MapIterator<State, State> iterator = isomorphism.mapIterator();
    while (iterator.hasNext()) {
        State n = iterator.next();
        State m = iterator.getValue();
        if (!first)
            output.append(", ");
        output.append(n.getId());//from   w w  w . j  ava2  s  .c o  m
        output.append("=");
        output.append(m.getId());
        first = false;
    }

    output.append("]");
}