in commons-digester3-core/src/main/java/org/apache/commons/digester3/RulesBase.java [115:141]
public List<Rule> match( final String namespaceURI, final String pattern, final String name, final Attributes attributes )
{
// List rulesList = (List) this.cache.get(pattern);
List<Rule> rulesList = lookup( namespaceURI, pattern );
if ( rulesList == null || rulesList.isEmpty() )
{
// Find the longest key, ie more discriminant
String longKey = "";
for ( final String key : wildcardCache )
{
if ( ( pattern.equals( key.substring( 1 ) ) || pattern.endsWith( key ) )
&& key.length() > longKey.length() )
{
longKey = key;
}
}
if ( !longKey.isEmpty() )
{
rulesList = lookup( namespaceURI, "*" + longKey );
}
}
if ( rulesList == null )
{
rulesList = new ArrayList<>();
}
return rulesList;
}