package org.fusesource.fabric.zookeeper.commands;

import java.util.*;
import java.util.List;
import java.util.regex.Pattern;

public class RegexSupport {

    public static boolean matches(java.util.List<Pattern> patterns, String value) {
        if ( patterns.isEmpty() ) {
            return true;
        }
        boolean rc = false;
        for ( Pattern pattern : patterns ) {
            if ( pattern.matcher(value).matches() ) {
                rc = true;
            }
        }
        return rc;
    }

    public static List<Pattern> getPatterns(String[] regex) {
        List<Pattern> patterns = new ArrayList<Pattern>();
        if ( regex != null ) {
            for ( String p : regex ) {
                patterns.add(Pattern.compile(p));
            }
        }
        return patterns;
    }
}
@@ -1,8 +1,275 @@
+/**%0A * Copyright (C) 2011, FuseSource Corp.  All rights reserved.%0A * http://fusesource.com%0A *%0A * The software in this package is published under the terms of the%0A * CDDL license a copy of which has been included with this distribution%0A * in the license.txt file.%0A */%0A
 package 

add copyright header