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-1.6.8.rc1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.7.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.7-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.7.rc4-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.6.4-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.6.3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.7.rc3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.7.rc2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.6.2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.6.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.5-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.4.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.4-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.3.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.3.rc3-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.3.rc2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.3.rc1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.2.1-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java
nokogiri-1.6.2-java ext/java/nokogiri/internals/c14n/CanonicalFilter.java