/*
 * Copyright (C) 2010 TranceCode Software
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 */
package org.trancecode.xml.saxon;

import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.XdmNode;
import org.trancecode.annotation.Nullable;

/**
 * Utility and factory methods related to {@link SaxonProcessorDelegate}.
 * 
 * @author Herve Quiroz
 */
public final class SaxonProcessorDelegates
{
    /**
     * Creates a new ${@link MatchSaxonProcessorDelegate} that uses the given
     * XSLT match pattern to dispatch events to the two given delegates.
     * 
     * @param processor
     *            The Saxon processor used to initialize a new
     *            {@link SaxonBuilder} for each new document processing.
     * @param pattern
     *            The XSLT match pattern evaluated for each node
     * @param namespaceContext
     *            A node from which to retrieve namespaces.
     * @param matchDelegate
     *            The processor delegate called if the pattern matches a node
     * @param nomatchDelegate
     *            The processor delegate called if the pattern does not match a
     *            node
     */
    public static SaxonProcessorDelegate forXsltMatchPattern(final Processor processor, final String pattern,
            @Nullable final XdmNode namespaceContext, final SaxonProcessorDelegate matchDelegate,
            final SaxonProcessorDelegate nomatchDelegate)
    {
        return new MatchSaxonProcessorDelegate(new SaxonPatternMatcher(processor, pattern, namespaceContext),
                matchDelegate, nomatchDelegate);
    }

    private SaxonProcessorDelegates()
    {
        // No instantiation
    }
}

@@ -816,16 +816,39 @@
 saxon;%0A%0A
+import java.util.Set;%0A%0A
 import n
@@ -911,16 +911,55 @@
 dmNode;%0A
+import net.sf.saxon.s9api.XdmNodeKind;%0A
 import o
@@ -2339,16 +2339,988 @@
 %0A    %7D%0A%0A
+    /**%0A     * Creates a new $%7B@link MatchSaxonProcessorDelegate%7D that dispatches events%0A     * to the two given delegates based on the kind of the node (e.g.%0A     * %7B@link XdmNodeKind#ELEMENT%7D).%0A     * %0A     * @param nodeKinds%0A     *            The list of node kinds for which the events should be%0A     *            dispatched to %7B@code matchDelegate%7D.%0A     * @param matchDelegate%0A     *            The processor delegate called if the node is of one of the%0A     *            specified kinds.%0A     * @param nomatchDelegate%0A     *            The processor delegate called if the node is not of one of the%0A     *            specified kinds.%0A     */%0A    public static SaxonProcessorDelegate forNodeKinds(final Set%3CXdmNodeKind%3E nodeKinds,%0A            final SaxonProcessorDelegate matchDelegate, final SaxonProcessorDelegate nomatchDelegate)%0A    %7B%0A        return new MatchSaxonProcessorDelegate(SaxonPredicates.hasNodeKind(nodeKinds), matchDelegate, nomatchDelegate);%0A    %7D%0A%0A
     priv

Add SaxonProcessorDelegates.forNodeKinds()