All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.browsermob.proxy.ProxyBlockUtil Maven / Gradle / Ivy

There is a newer version: 2.0-beta-7
Show newest version
package org.browsermob.proxy;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/** Functions that hope to be useful in dealing with lists of Blocks */
public class ProxyBlockUtil {

    public static List collapseBlocks(List blocks) {
        List httpObjects = new ArrayList();
        for (Block block: blocks) {
            List objs = block.getObjects();
            for (HttpObject obj: objs) {
                httpObjects.add(obj);
            }
        }
        Collections.reverse(httpObjects);
        return httpObjects;
    }


    // returns the first match... null if none found
    public static HttpObject getExact(String toFind, List httpObjects) {
        for (HttpObject obj: httpObjects) {
            if (obj.getUrl().equals(toFind)) {
                return obj;
            }
        }
        return null;
    }

    public static HttpObject getUrlMatch(String toFind, List httpObjects) {
        for (HttpObject obj: httpObjects) {
            if (obj.getUrl().indexOf(toFind) != -1) {
                return obj;
            }
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy