public List match()

in commons-digester3-core/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java [256:287]


        public List<Rule> match( final String namespaceURI, final String matchPath, final String name, final Attributes attributes )
        {
            final List<Rule> match = decoratedRules.match( namespaceURI, matchPath, name, attributes );

            if ( matchPath.startsWith( matchPrefix ) && matchPath.indexOf( '/', matchPrefix.length() ) == -1 )
            {

                // The current element is a direct child of the element
                // specified in the init method, so we want to ensure that
                // the rule passed to this object's constructor is included
                // in the returned list of matching rules.

                if ( match == null || match.isEmpty() )
                {
                    // The "real" rules class doesn't have any matches for
                    // the specified path, so we return a list containing
                    // just one rule: the one passed to this object's
                    // constructor.
                    return rules;
                }
                // The "real" rules class has rules that match the current
                // node, so we return this list *plus* the rule passed to
                // this object's constructor.
                //
                // It might not be safe to modify the returned list,
                // so clone it first.
                final LinkedList<Rule> newMatch = new LinkedList<>( match );
                newMatch.addLast( rule );
                return newMatch;
            }
            return match;
        }