Example usage for org.apache.commons.digester SimpleRegexMatcher match

List of usage examples for org.apache.commons.digester SimpleRegexMatcher match

Introduction

In this page you can find the example usage for org.apache.commons.digester SimpleRegexMatcher match.

Prototype

@Override
public boolean match(String basePattern, String regexPattern) 

Source Link

Document

Matches using simple regex algorithm.

Usage

From source file:org.carewebframework.ui.icons.IconLibraryRegistry.java

/**
 * Returns the paths to matching icon resources given name, dimensions, and library name, any
 * one of which may contain wildcard characters.
 * /*from w w w .  ja  v a 2s.  c o m*/
 * @param library Library name containing the icon (e.g., "silk"). If null, all libraries are
 *            searched.
 * @param iconName Name of the requested icon (e.g., "help*.png").
 * @param dimensions Dimensions of the requested icon (e.g., "16x*").
 * @return The icon path.
 */
public List<String> getMatching(String library, final String iconName, String dimensions) {
    SimpleRegexMatcher matcher = new SimpleRegexMatcher();
    dimensions = dimensions == null ? defaultDimensions : dimensions;

    List<String> results = null;

    for (IIconLibrary lib : this) {
        if (library == null || matcher.match(lib.getId(), library)) {
            List<String> urls = lib.getMatching(iconName, dimensions);

            if (results == null) {
                results = urls;
            } else {
                results.addAll(urls);
            }
        }
    }

    return results == null ? Collections.<String>emptyList() : results;
}