Search in sources :

Example 1 with NokogiriHelpers.nodeArrayToRubyArray

use of nokogiri.internals.NokogiriHelpers.nodeArrayToRubyArray in project nokogiri by sparklemotion.

the class XmlNode method element_children.

@JRubyMethod(name = { "element_children", "elements" })
public IRubyObject element_children(ThreadContext context) {
    List<Node> elementNodes = new ArrayList<Node>();
    addElements(node, elementNodes, false);
    if (elementNodes.size() == 0)
        return XmlNodeSet.newEmptyNodeSet(context);
    RubyArray array = NokogiriHelpers.nodeArrayToRubyArray(context.getRuntime(), elementNodes.toArray(new Node[0]));
    XmlNodeSet xmlNodeSet = XmlNodeSet.newXmlNodeSet(context, array);
    return xmlNodeSet;
}
Also used : RubyArray(org.jruby.RubyArray) NokogiriHelpers.nodeArrayToRubyArray(nokogiri.internals.NokogiriHelpers.nodeArrayToRubyArray) NokogiriHelpers.clearCachedNode(nokogiri.internals.NokogiriHelpers.clearCachedNode) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) JRubyMethod(org.jruby.anno.JRubyMethod)

Example 2 with NokogiriHelpers.nodeArrayToRubyArray

use of nokogiri.internals.NokogiriHelpers.nodeArrayToRubyArray in project gocd by gocd.

the class XmlNode method element_children.

@JRubyMethod(name = { "element_children", "elements" })
public IRubyObject element_children(ThreadContext context) {
    List<Node> elementNodes = new ArrayList<Node>();
    addElements(node, elementNodes, false);
    if (elementNodes.size() == 0)
        return XmlNodeSet.newEmptyNodeSet(context);
    RubyArray array = NokogiriHelpers.nodeArrayToRubyArray(context.getRuntime(), elementNodes.toArray(new Node[0]));
    XmlNodeSet xmlNodeSet = XmlNodeSet.newXmlNodeSet(context, array);
    return xmlNodeSet;
}
Also used : RubyArray(org.jruby.RubyArray) NokogiriHelpers.nodeArrayToRubyArray(nokogiri.internals.NokogiriHelpers.nodeArrayToRubyArray) Node(org.w3c.dom.Node) NokogiriHelpers.clearCachedNode(nokogiri.internals.NokogiriHelpers.clearCachedNode) ArrayList(java.util.ArrayList) JRubyMethod(org.jruby.anno.JRubyMethod)

Aggregations

ArrayList (java.util.ArrayList)2 NokogiriHelpers.clearCachedNode (nokogiri.internals.NokogiriHelpers.clearCachedNode)2 NokogiriHelpers.nodeArrayToRubyArray (nokogiri.internals.NokogiriHelpers.nodeArrayToRubyArray)2 RubyArray (org.jruby.RubyArray)2 JRubyMethod (org.jruby.anno.JRubyMethod)2 Node (org.w3c.dom.Node)2