Method called to create a new context for iterating all
contents of the current structured value (JSON array or object)
@return a cursor over the children of this node
430213
public final HoconNodeCursor iterateChildren() {
    	ConfigValue n = currentNode();
        if (n == null) throw new IllegalStateException("No current node");
        boolean numericallyIndexed = isNumericallyIndexed(n);
        if (!numericallyIndexed) {
            if (isArray(n)) { // false since we have already returned START_ARRAY
                return new Array(n, this);
            }
            if (isObject(n)) {
                return new Object(n, this);
            }
        } else {
            return new NumericallyIndexedObjectBackedArray(n, this);
        }
        throw new IllegalStateException("Current node of type "+n.getClass().getName());
    }
769842
@Override
    public Iterator<Tree> iterator() {
        return new Iterator<Tree>() {
            @Override
            public boolean hasNext() {
                return next != null;
            }

            @Override
            public Tree next() {
                Tree t = next.leaf;
                next = next.parent;
                return t;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }

            private TreePath next = TreePath.this;
        };
    }
317556
public static TreeNode nodeFor(Object object) {
    TreeNode node = getTreeNode(object);
    return node == null ? null : new ContextAwareTreeNode(node, object);
  }
1054108
@SuppressWarnings("unchecked")
	public JSONNavi<T> object() {
		if (failure)
			return this;
		if (current == null && readonly)
			failure("Can not create Object child in readonly", null);
		if (current != null) {
			if (isObject())
				return this;
			if (isArray())
				failure("can not use Object feature on Array.", null);
			failure("Can not use current possition as Object", null);
		} else {
			current = mapper.createObject();
		}
		if (root == null)
			root = (T) current;
		else
			store();
		return this;
	}
1284631
public Context createChild(){
        Context c = new Context();
        c.memoryHeap = memoryHeap;
        c.parent = this;
        this.children.add(c);
        return c;
    }
821957
function buildElementsTree(contexts) {

	contexts = contexts || [document];

	var queriesArray = Object.keys(queries).map(function(key) {
		return queries[key];
	});

	var selector = queriesArray.map(function(query) {
		return query._selector;
	}).join(',');

	var elements = [];
	contexts.forEach(function(context) {
		for (var node = context.parentNode; node; node = node.parentNode) {
			// Skip nested contexts
			if (contexts.indexOf(node) !== -1) {
				return;
			}
		}
		if (context !== document && elementMatchesSelector(context, selector)) {
			elements.push(context);
		}
		elements.push.apply(elements, arrayFrom(context.querySelectorAll(selector)));
	});

	var tree = [];
	var treeCache = createCacheMap();

	elements.forEach(function(element) {

		if (element === documentElement) {
			return;
		}

		var treeNode = {
			_element: element,
			_children: [],
			_queries: [],
			_changes: [],
			_done: false,
		};

		var children = tree;
		for (var node = element.parentNode; node; node = node.parentNode) {
			if (treeCache.get(node)) {
				children = treeCache.get(node)._children;
				break;
			}
		}

		treeCache.set(element, treeNode);

		children.push(treeNode);

		queriesArray.forEach(function(query) {
			if (elementMatchesSelector(element, query._selector)) {
				treeNode._queries.push(query);
			}
		});

	});

	return tree;

}
306952
private static JSONArray parseChildShapesRecursive(ArrayList<Shape> childShapes) throws JSONException {
        if (childShapes != null) {
            JSONArray childShapesArray = new JSONArray();

            for (Shape childShape : childShapes) {
                JSONObject childShapeObject = new JSONObject();

                childShapeObject.put("resourceId",
                                     childShape.getResourceId().toString());
                childShapeObject.put("properties",
                                     parseProperties(childShape.getProperties()));
                childShapeObject.put("stencil",
                                     parseStencil(childShape.getStencilId()));
                childShapeObject.put("childShapes",
                                     parseChildShapesRecursive(childShape.getChildShapes()));
                childShapeObject.put("outgoing",
                                     parseOutgoings(childShape.getOutgoings()));
                childShapeObject.put("bounds",
                                     parseBounds(childShape.getBounds()));
                childShapeObject.put("dockers",
                                     parseDockers(childShape.getDockers()));

                if (childShape.getTarget() != null) {
                    childShapeObject.put("target",
                                         parseTarget(childShape.getTarget()));
                }

                childShapesArray.put(childShapeObject);
            }

            return childShapesArray;
        }

        return new JSONArray();
    }
16410
public JSONObject getJson() throws JSONException {
        JSONObject json = create();
        json.put("processInstance", processInstance.getJson());
        if (!children.isEmpty()) {
            JSONArray childrenArr = new JSONArray();
            for (LinkedProcessInstance child : children) {
                childrenArr.put(child.getJson());
            }
            json.put("children", childrenArr);
        }
        return json;
    }
482938
public ObjectNode toJson() {
		ObjectMapper mapper = new ObjectMapper();
		ObjectNode node = mapper.createObjectNode();
		ObjectNode attributeNode = mapper.createObjectNode();

		node.put(attribute.getCode(), attributeNode);
		attributeNode.put("op", operation.getOp());

		return node;
	}
1100618
public String beginArray() throws IOException {
      String name = null;
      if (currentValue.getKey() == NAME) {
         name = currentValue.getValue().asString();
         consume();
      }
      if (currentValue.getKey() == BEGIN_ARRAY) {
         consume();
      } else if (readStack.peek() != BEGIN_ARRAY) {
         throw new IOException("Expecting BEGIN_ARRAY, but found " + jsonTokenToStructuredElement(null));
      }
      return name;
   }
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;
    }
1154211
@SuppressWarnings("unchecked")
	public JSONNavi<T> array() {
		if (failure)
			return this;
		if (current == null && readonly)
			failure("Can not create Array child in readonly", null);
		if (current != null) {
			if (isArray())
				return this;
			if (isObject())
				failure("can not use Object feature on Array.", null);
			failure("Can not use current possition as Object", null);
		} else {
			current = mapper.createArray();
		}
		if (root == null)
			root = (T) current;
		else
			store();
		return this;
	}
807098
function() {
			if (this.parent) {
				var ix = this.parent.children.indexOf(this);
				if (~ix) {
					this.parent.children.splice(ix, 1);
				}
			}
			
			return this;
		}
1081356
protected static final Object copyChildren(String parentName, Node source, LinkedHashMap<String, Object> map) {

		// Node name
		LinkedList<Object> array = null;
		boolean isArray = isArray(source);
		String name = source.getNodeName();
		if (name != null && !parentName.equals(name)) {
			map.put("_name", name);
		}

		// Copy attributes
		NamedNodeMap attributes = source.getAttributes();
		if (attributes != null) {
			int max = attributes.getLength();
			for (int i = 0; i < max; i++) {
				Node attribute = attributes.item(i);
				name = attribute.getNodeName();
				String value = attribute.getNodeValue();
				if (name != null && value != null) {
					map.put('@' + name, value);
				}
			}
		}

		// JSON array?
		if (isArray) {
			array = new LinkedList<>();
			if (hasProperties(source)) {
				map.put("_items", array);
			}
		}

		// Loop on children
		NodeList children = source.getChildNodes();
		if (children != null) {
			int max = children.getLength();
			for (int i = 0; i < max; i++) {
				Node child = children.item(i);
				if (child.getNodeType() != Node.ELEMENT_NODE) {
					continue;
				}
				String value = getTextValue(child);
				if (value != null && !hasProperties(child)) {

					// Property
					name = child.getNodeName();
					if (name != null) {
						if (isArray) {
							putWithType(null, array, name, value);
						} else {
							putWithType(map, null, name, value);
						}
					}

				} else {

					// Substructure
					LinkedHashMap<String, Object> subTree = new LinkedHashMap<>();
					if (isArray) {
						name = "";
						array.add(subTree);
					} else {
						name = child.getNodeName();
						map.put(name, subTree);
					}
					String text = getTextValue(child);
					if (text != null && !text.isEmpty()) {
						subTree.put("_text", text);
					}

					// Recursive copy
					Object result = copyChildren(name, child, subTree);
					if (result != subTree) {
						map.put(name, result);
					}
				}
			}
		}
		return map.isEmpty() && array != null ? array : map;
	}
1039736
static String[] getChildElementTextArr(Element parent, String name) {
        // Get all the elements
        List children = getChildElementsByName(parent, name);

        String str[] = new String[children.size()];

        for (int i = 0; i < children.size(); i++) {
            Node child = (Node) children.get(i);

            StringBuffer buf = new StringBuffer();

            NodeList nodes = child.getChildNodes();
            for (int j = 0; j < nodes.getLength(); j++) {
                Node node = nodes.item(j);
                if (node.getNodeType() == Node.TEXT_NODE ||
                        node.getNodeType() == Node.CDATA_SECTION_NODE) {
                    Text text = (Text) node;
                    buf.append(text.getData().trim());
                }
            }

            str[i] = buf.toString();
        }

        return str;
    }
585293
private JsonObject getPendingJSONObject() {
        for (Map.Entry<String, BoxJSONObject> entry : this.children.entrySet()) {
            BoxJSONObject child = entry.getValue();
            JsonObject jsonObject = child.getPendingJSONObject();
            if (jsonObject != null) {
                if (this.pendingChanges == null) {
                    this.pendingChanges = new JsonObject();
                }

                this.pendingChanges.set(entry.getKey(), jsonObject);
            }
        }
        return this.pendingChanges;
    }
1169969
protected JTree newTree()
	{
		JTree tree = new JTree();

		tree.setModel(newTreeModel(getModel()));
		tree.setEditable(true);
		tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

		tree.addMouseListener(new MouseAdapter()
		{
			@Override
			public void mousePressed(MouseEvent e)
			{
				int selRow = tree.getRowForLocation(e.getX(), e.getY());
				if (selRow != -1)
				{
					if (e.getClickCount() == 1)
					{
						onSingleClick(e);
					}
					else if (e.getClickCount() == 2)
					{
						onDoubleClick(e);
					}
				}
			}
		});

		return tree;
	}