/** * @param refNode The refNode to set. */ public void setRefNode(final ObjectGraphNode refNode) { this.refNode = refNode; setSize(OBJREF_SIZE); }
/** * For some types, we don't care about their internals, so just summarise the size. * * @param node the node to summarise. */ private void summariseNode(final ObjectGraphNode node) { int size = node.getSize(); node.removeAll(); node.setSize(size); }
/** * Adjusts the overhead of the given node, for types where not all data is output (e.g. Lists and Maps). * * @param node the node to adjust. */ private void adjustOverhead(final ObjectGraphNode node) { ObjectGraphNode[] originalChildren = new ObjectGraphNode[node.getChildCount()]; int dataSize = 0; for (int i = 0; i < node.getChildCount(); i++) { ObjectGraphNode childNode = (ObjectGraphNode) node.getChildAt(i); dataSize += childNode.getSize(); originalChildren[i] = childNode; } node.removeAll(); // Figure out the list overhead. // All the original children will be included refs, as they have already been visited. visitComplexType(node); node.setSize(node.getSize() - originalChildren.length * ObjectGraphNode.OBJREF_SIZE); // re-attach the old children node.removeAll(); for (int i = 0; i < originalChildren.length; i++) { node.add(originalChildren[i]); } }