Sha256: 022ab96648331faceee7a40cc10279fe53d90ca6d1caa9cd65448700de15689c

Contents?: true

Size: 1.15 KB

Versions: 63

Compression:

Stored size: 1.15 KB

Contents

package nokogiri.internals.c14n;

import nokogiri.XmlNode;
import nokogiri.internals.NokogiriHelpers;

import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.w3c.dom.Node;

public class CanonicalFilter {
    private final Block block;
    private final ThreadContext context;

    public CanonicalFilter(ThreadContext context, Block block) {
        this.context = context;
        this.block = block;
    }

    public boolean includeNodes(Node currentNode, Node parentNode) {
        if (block == null || !block.isGiven())
            return true;

        IRubyObject current = NokogiriHelpers.getCachedNodeOrCreate(context.getRuntime(), currentNode);
        IRubyObject parent = NokogiriHelpers.getCachedNodeOrCreate(context.getRuntime(), parentNode);

        if (parent.isNil()) {
            IRubyObject doc = ((XmlNode) current).document(context);
            boolean returnValue = block.call(context, current, doc).isTrue();
            block.call(context, doc, context.nil);
            return returnValue;
        }

        return block.call(context, current, parent).isTrue();
    }

}

Version data entries

63 entries across 63 versions & 3 rubygems

Version Path
nokogiri-backport-1.11.0 ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.0-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.0.rc4-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.0.rc3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.10-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.0.rc2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.9-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.8-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.11.0.rc1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.7-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.6-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.5-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.4-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.0-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.10.0.rc1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.9.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java