/** * Iterator for the descendants of the supplied object. * * @param parent document or element whose descendants will be iterated */ DescendantIterator(Parent parent) { if (parent == null) { throw new IllegalArgumentException("parent parameter was null"); } this.iterator = parent.getContent().iterator(); }
@NotNull private static ProcessingInstruction getFormatInstruction( @NotNull Parent document ) { List<? extends ProcessingInstruction> processingInstructions = document.getContent( new PiFormatFilter() ); if ( processingInstructions.size() != 1 ) { throw new IllegalStateException( "No processing instructions found" ); } return processingInstructions.get( 0 ); }
private XMLNode createTreeNode(Content content) { XMLNode node = new XMLNode(content); if (content instanceof Parent) { Parent parent = (Parent) content; Iterator children = parent.getContent().iterator(); while (children.hasNext()) { Object child = children.next(); if (child instanceof Element) { node.add(createTreeNode((Content) child)); } else if (textSizeLimit != 0 && child instanceof Text) { Text text = (Text) child; if (!text.getTextNormalize().equals("")) { node.add(createTreeNode(text)); } } } } return node; } }
@SuppressWarnings("unchecked") private XMLNode createTreeNode(Content content) { XMLNode node = new XMLNode(content); if (content instanceof Parent) { Parent parent = (Parent) content; Iterator children = parent.getContent().iterator(); while (children.hasNext()) { Object child = children.next(); if (child instanceof Element) { node.add(createTreeNode((Content) child)); } else if (textSizeLimit != 0 && child instanceof Text) { Text text = (Text) child; if (!text.getTextNormalize().equals("")) { node.add(createTreeNode(text)); } } } } return node; } }