Creates an ArrayNode from the given nodes. Returns an empty ArrayNode if no elements are provided and
fallbackToEmptyArray is true, null if false.
338159
public static ArrayNode createArray(boolean fallbackToEmptyArray, JsonNode... nodes) {
		ArrayNode array = null;
		for (JsonNode element: nodes) {
			if (element != null) {
				if (array == null) {
					array = new ArrayNode(JsonNodeFactory.instance);
				}
				array.add(element);
			}
		}
		if ((array == null) && fallbackToEmptyArray) {
			array = new ArrayNode(JsonNodeFactory.instance);
		}
		return array;
	}
585792
Collection<DatanodeDescriptor> getNodes(Block blk) {
    if (corruptReplicasMap.size() == 0)
      return null;
    return corruptReplicasMap.get(blk);
  }
1343286
public ClassNode makeArray() {
        if (redirect!=null) {
            ClassNode res = redirect().makeArray();
            res.componentType = this;
            return res;
        }
        ClassNode cn;
        if (clazz!=null) {
            Class ret = Array.newInstance(clazz,0).getClass();
            // don't use the ClassHelper here!
            cn = new ClassNode(ret,this);
        } else {
            cn = new ClassNode(this);
        }
        return cn;
    }
1158824
public static NodeList<Element> copyNodeList(NodeList<Element> oldNodes,
      NodeList<Element> newNodes, boolean create) {
    NodeList<Element> ret = oldNodes == null || create ? JsNodeArray.create()
        : oldNodes;
    JsCache idlist = JsCache.create();
    for (int i = 0; oldNodes != null && i < oldNodes.getLength(); i++) {
      Element e = oldNodes.getItem(i);
      idlist.put(e.hashCode(), 1);
      if (create) {
        ret.<JsNodeArray> cast().addNode(e, i);
      }
    }
    for (int i = 0, l = newNodes.getLength(), j = ret.getLength(); i < l; i++) {
      Element e = newNodes.getItem(i);
      if (!idlist.exists(e.hashCode())) {
        ret.<JsNodeArray> cast().addNode(newNodes.getItem(i), j++);
      }
    }
    return ret;
  }
686293
private static ArrayNode toJson(Iterable<? extends Change<?>> changes) {
        final ArrayNode changesNode = JsonNodeFactory.instance.arrayNode();
        changes.forEach(c -> {
            final ObjectNode changeNode = JsonNodeFactory.instance.objectNode();
            changeNode.put("path", c.path());
            changeNode.put("type", c.type().name());
            final Class<?> contentType = c.type().contentType();
            if (contentType == JsonNode.class) {
                changeNode.set("content", (JsonNode) c.content());
            } else if (contentType == String.class) {
                changeNode.put("content", (String) c.content());
            }
            changesNode.add(changeNode);
        });
        return changesNode;
    }
17149
function (xmlNode, nodeName) {

            var childs = xmlNode.childNodes;

            for (var i = 0; i < childs.length; ++i) {

                var item = childs.item(i);

                if (item.nodeType !== 1) {
                    continue;
                }

                if ((item.nodeName && !nodeName) || (nodeName && nodeName === item.nodeName)) {
                    return item;
                }
            }

            return null;
        }
1159305
private ObjectJS jsonTreeNode(CallTreeNode node, StringifierFactory jsonStringifierFactory) {
		final ObjectJS nodeJS = ObjectJS.create(node, jsonStringifierFactory);
		if (!node.getChildren().isEmpty()) {
			final ArrayJS childNodesJS=new ArrayJS(node.getChildren().size());
			for(CallTreeNode childNode:node.getChildren()) {
				childNodesJS.addElement(jsonTreeNode(childNode, jsonStringifierFactory));
			}
			nodeJS.setAttribute("children", childNodesJS);
		}
		return nodeJS;
	}
717667
private static Node[] _toNodeArray(Document doc, Object o) {
	if (o instanceof Node) return new Node[] { (Node) o };
	// Node[]
	if (o instanceof Node[]) return ((Node[]) o);
	// NamedNodeMap
	else if (o instanceof NamedNodeMap) {
	    NamedNodeMap map = (NamedNodeMap) o;
	    int len = map.getLength();
	    Node[] nodes = new Node[len];
	    for (int i = 0; i < len; i++) {
		nodes[i] = map.item(i);
	    }
	    return nodes;
	}
	// XMLAttributes
	else if (o instanceof XMLAttributes) {
	    return _toNodeArray(doc, ((XMLAttributes) o).toNamedNodeMap());
	}
	// NodeList
	else if (o instanceof NodeList) {
	    NodeList list = (NodeList) o;
	    int len = list.getLength();
	    Node[] nodes = new Node[len];
	    for (int i = 0; i < nodes.length; i++) {
		nodes[i] = list.item(i);
	    }
	    return nodes;
	}
	return null;
    }
883354
public Node createNode( Tree<Row> current ){
        Row row = current.getContent();
        Element output = row.getOutputElement();
        Element main = row.getMainElement();
        List<Element> input = row.getInputElement();
        Integer id = main.getId();
        Type type = main.getType();
        switch( type ) {
            case START:
                return null;
            case END:
                return null;
            case VALUE:
                String vAttribute = output.getString( 0 );
                Object value = main.getObject( 0 );
                return new SetAttributeActivity( id, vAttribute, value );
            case CALL:
                String cBean = main.getString( 0 );
                String cMethod = main.getString( 1 );
                InputMapping<?>[] cArgumentsMapping = ElementUtil.createArrayMapping( main.getObjectArray( 2 ) );
                OutputMapping cOutputMapping = ElementUtil.createOutputMapping( output );
                return new BeanCallActivity( id, cBean, cMethod, cArgumentsMapping, cOutputMapping );
            case CALL_ASYNC:
                String caBean = main.getString( 0 );
                String caMethod = main.getString( 1 );
                InputMapping<?>[] caArgumentsMapping = ElementUtil.createArrayMapping( main.getObjectArray( 2 ) );
                OutputMapping caOutputMapping = ElementUtil.createOutputMapping( output );
                return new BeanAsyncCallActivity( id, caBean, caMethod, caArgumentsMapping, caOutputMapping );
            case HUMAN_TASK:
                String role = main.getString( 0 );
                String user = main.getString( 1 );
                MapMapping htArgumentsMapping = ElementUtil.createMapMapping( input );
                OutputMapping htOutputMapping = ElementUtil.createOutputMapping( output );
                return new HumanTaskActivity( id, role, user, htArgumentsMapping, htOutputMapping );
            case WAIT_SIGNAL:
                String signal = main.getString( 0 );
                OutputMapping wsOutputMapping = ElementUtil.createOutputMapping( output );
                return new CatchSignal( id, signal, wsOutputMapping );
            case WAIT_TIMER:
                String due = main.getString( 0 );
                if( ElUtil.hasBrackets( due ) ){
                    return new CatchTimer( new ExpressionLanguageMapping<Long>( due ), id );
                }
                else{
                    long delayMillis = Long.valueOf( due );
                    return new CatchTimer( id, delayMillis );
                }
            case WAIT_UNTIL_DATE:
                String dueDate = main.getString( 0 );
                return new CatchTimer( id, new ExpressionLanguageMapping<Date>( dueDate ) );
            case CREATE_INSTANCE:
                String graphName = main.getString( 0 );
                InputMapping<String> nameMapping = ElUtil.hasBrackets( graphName ) ?
                        new ExpressionLanguageMapping<String>( graphName ) : ConstantMapping.of( graphName );

                Integer graphVersion = main.getInteger( 1 );
                InputMapping<Integer> versionMapping = ConstantMapping.of( graphVersion );

                String label1 = main.getString( 2 );
                InputMapping<String> label1Mapping = ElUtil.hasBrackets( label1 ) ?
                        new ExpressionLanguageMapping<String>( label1 ) : ConstantMapping.of( label1 );

                String label2 = main.getString( 3 );
                InputMapping<String> label2Mapping = ElUtil.hasBrackets( label2 ) ?
                        new ExpressionLanguageMapping<String>( label2 ) : ConstantMapping.of( label2 );

                MapMapping ciArgumentsMapping = ElementUtil.createMapMapping( input );

                return new CreateNewInstanceActivity( id, nameMapping, versionMapping, label1Mapping, label2Mapping, ciArgumentsMapping );
            case WHILE_DO_BEGIN:
                return new XorFork( id );
            case WHILE_DO_END:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case DO_WHILE_BEGIN:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case DO_WHILE_END:
                return new XorFork( id );
            case IF:
                return new XorFork( id );
            case ELSE_IF:
                return null;
            case ELSE:
                return null;
            case END_IF:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case SPLIT:
                boolean hasConditionalBranches = hasConditionalBranches( current );
                return hasConditionalBranches ? new OrFork( id ) : new AndFork( id );
            case BRANCH:
                return null;
            case JOIN_FIRST:
                id = -findPartnerNodeId( current, type );
                return new CancellingDiscriminator( id );
            case JOIN_ALL:
                id = -findPartnerNodeId( current, type );
                return new AndJoin( id );
            case ESCALATE:
                return new ThrowEscalation( id );
            case VALIDATE_INPUT_VARIABLE:
                String vivAttribute = main.getString( 0 );
                Class<?> vivType = (Class<?>)main.getObject( 1 );
                if( main.countArguments() == 2 ){
                    return new ValidateAttributeActivity( id, vivAttribute, vivType );
                }
                boolean vivIsRequired = (boolean)main.getObject( 2 );
                if( main.countArguments() == 3 ){
                    return new ValidateAttributeActivity( id, vivAttribute, vivType, vivIsRequired );
                }
                Object vivDefaultValue = main.getObject( 3 );
                return new ValidateAttributeActivity( id, vivAttribute, vivType, vivIsRequired, vivDefaultValue );
            default :
                throw new IllegalStateException( "Cannot create node for unknown main element type in row: " + row );
        }
    }
854602
private void addToArray(JsonNode j) {
        if (j instanceof ArrayNode) {
            for (Iterator<JsonNode> itr = ((ArrayNode) j).elements(); itr.hasNext();) {
                addToArray(itr.next());
            }
        } else {
            ((ArrayNode) node).add(j);
        }
    }
980771
Kam[] kams(KamNode... nodes) {
        List<Kam> kams = new ArrayList<Kam>(nodes.length);
        for (int i = 0; i < nodes.length; i++) {
            KamNode node = nodes[i];
            kams.add(node.getKam());
        }
        return kams.toArray(new Kam[0]);
    }
1007220
private Node getNode(Node nodeStart, String key, CreateMode createMode, boolean bReturnTextNode)
    {
        if (key.indexOf('/') != -1)
        {
            String strKeyParent = key.substring(0, key.indexOf('/'));
            CreateMode createModeParent = createMode;
            if (createModeParent == CreateMode.CREATE_NEW_NODE)
                createModeParent = CreateMode.CREATE_IF_NOT_FOUND;  // Only create a duplicate node at the leaf level.
            nodeStart = this.getNode(nodeStart, strKeyParent, createModeParent, false);
            if (nodeStart == null)
                return null;
            key = key.substring(key.indexOf('/') + 1);
            return this.getNode(nodeStart, key, createMode, bReturnTextNode);
        }
        if (nodeStart == null)
            nodeStart = this.getNode(true);

        int iIndex = Integer.MAX_VALUE;
        if (key.indexOf('[') != -1)
        {
            iIndex = Integer.parseInt(key.substring(key.indexOf('[') + 1, key.indexOf(']')));
            key = key.substring(0, key.indexOf('['));
        }
        key = Util.fixDOMElementName(key);
        Node node = null;
        NodeList nodeList = ((Element)nodeStart).getElementsByTagName(key);
        if (nodeList != null)
        {
            for (int i = 0; i < nodeList.getLength(); i++)
            {
                if (nodeList.item(i).getParentNode() == nodeStart)
                {
                    node = nodeList.item(i);    // Get the last child.
                    if (iIndex != Integer.MAX_VALUE)
                    {
                        if (--iIndex == 0)
                            break;  // This is the correct node
                        node = null;    // If you are looking for a specific node, and it doesn't exist, return null.
                    }
                }
            }
        }
        if (((node == null) && (createMode != CreateMode.DONT_CREATE))
                || (createMode == CreateMode.CREATE_NEW_NODE))
        {
        	Document doc = null;
        	if (m_data instanceof Document)
        		doc = (Document)m_data;
        	if (doc == null)
        		doc = ((Node)m_data).getOwnerDocument();
            node = doc.createElement(key);
            if (bReturnTextNode)
            {
                if (createMode != CreateMode.CREATE_CDATA_NODE)
                    node.appendChild(doc.createTextNode(Constant.BLANK));
                else
                    node.appendChild(doc.createCDATASection(Constant.BLANK));
            }
            nodeStart.appendChild(node);
        }
        if (node != null)
            if (bReturnTextNode)
                node = node.getFirstChild();
        return node;    // Return new node or null.
    }
1188026
function addToArrayByNode(node, code) {
  // node: the arr expression node
  // code: added as the last element of the array

  const multilines = node.loc.start.line !== node.loc.end.line;
  let insertPos = node.start + 1; // insert after '['

  if (node.elements.length) {
    const ele = _.last(node.elements);
    insertPos = ele.end;
  }

  let replacement;
  if (multilines) {
    const indent = _.repeat(' ', node.loc.end.column - 1);
    replacement = `\n${indent}  ${code}`;
    if (node.elements.length) {
      replacement = `,${replacement}`;
    } else {
      replacement = `${replacement},`;
    }
  } else {
    replacement = code;
    if (node.elements.length > 0) {
      replacement = `, ${code}`;
    }
  }
  return [
    {
      start: insertPos,
      end: insertPos,
      replacement,
    },
  ];
}
776601
function nodeListToArray (nodes) {
    if ($.env.name !== 'IE' || $.env.version > 9) {
      return prototypeSlice.call(nodes);
    }

    // IE 9 and below call use Array.prototype.slice.call against
    // a NodeList, hence the following
    var array = [];

    for (var i=0, num=nodes.length; i<num; ++i) {
      array.push(nodes[i]);
    }

    return array;
  }
816039
public static final NodeData createNodeData() {
		if (ndImpl == null) {
			try {
				@SuppressWarnings("unchecked")
				Class<? extends NodeData> clazz = (Class<? extends NodeData>) Class
						.forName(DEFAULT_NODE_DATA_IMPL);
				registerNodeDataInstance(clazz);
				log.debug("Registered {} as default NodeData instance.",
						DEFAULT_NODE_DATA_IMPL);
			} catch (Exception e) {
			}
		}

		try {
			return ndImpl.newInstance();
		} catch (Exception e) {
			throw new RuntimeException("No NodeData implementation registered");
		}
	}
244926
public static List<?> convertArrayOrList(JsonNode node) {
        if (node instanceof POJONode) {
            return convertArrayOrList(DPathUtils.extractValue((POJONode) node));
        }
        if (node instanceof ArrayNode) {
            List<JsonNode> result = new ArrayList<>();
            ArrayNode arrNode = (ArrayNode) node;
            for (JsonNode jNode : arrNode) {
                result.add(jNode);
            }
            return result;
        }
        return null;
    }
504333
private Node createNode(final Iterable<Range<C>> ranges) {
        Range<C> span = Iterables.getFirst(ranges, null);
        if (span == null) {
            return null;
        }
        for (Range<C> range : ranges) {
            checkNotNull(range, "ranges must not contain null ranges");
            span = range.span(span);
        }
        if (span.isEmpty()) {
            return null;
        }
        C center = Ranges.center(span);
        List<Range<C>> left = Lists.newArrayList();
        List<Range<C>> right = Lists.newArrayList();
        List<Range<C>> overlap = Lists.newArrayList();
        for (Range<C> range : ranges) {
            if (Ranges.isLessThan(range, center)) {
                left.add(range);
            }
            else if (Ranges.isGreaterThan(range, center)) {
                right.add(range);
            }
            else {
                overlap.add(range);
            }
        }
        return new Node(center, createNode(left), createNode(right), overlap);
    }