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

org.seleniumhq.jetty7.util.PatternMatcher Maven / Gradle / Ivy

There is a newer version: 9.4.12.v20180830.1
Show newest version
package org.eclipse.jetty.util;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public abstract class PatternMatcher
{
    public abstract void matched (URI uri) throws Exception;
    
    
    /**
     * Find jar names from the provided list matching a pattern.
     * 
     * If the pattern is null and isNullInclusive is true, then
     * all jar names will match.
     * 
     * A pattern is a set of acceptable jar names. Each acceptable
     * jar name is a regex. Each regex can be separated by either a
     * "," or a "|". If you use a "|" this or's together the jar
     * name patterns. This means that ordering of the matches is
     * unimportant to you. If instead, you want to match particular
     * jar names, and you want to match them in order, you should
     * separate the regexs with "," instead. 
     * 
     * Eg "aaa-.*\\.jar|bbb-.*\\.jar"
     * Will iterate over the jar names and match
     * in any order.
     * 
     * Eg "aaa-*\\.jar,bbb-.*\\.jar"
     * Will iterate over the jar names, matching
     * all those starting with "aaa-" first, then "bbb-".
     *
     * @param pattern the pattern
     * @param uris the uris to test the pattern against
     * @param isNullInclusive if true, an empty pattern means all names match, if false, none match
     * @throws Exception
     */
    public void match (Pattern pattern, URI[] uris, boolean isNullInclusive)
    throws Exception
    {
        if (uris!=null)
        {
            String[] patterns = (pattern==null?null:pattern.pattern().split(","));

            List subPatterns = new ArrayList();
            for (int i=0; patterns!=null && i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy