@Override public Document clone() { Document clone = (Document) super.clone(); clone.outputSettings = this.outputSettings.clone(); return clone; }
@Override public WrapElement __clone(Environment environment, TraceInfo traceInfo) { return new WrapElement(environment, __wrappedObject.clone()); }
/** * Creates a deep copy of these elements. * @return a deep copy */ @Override public Elements clone() { Elements clone = new Elements(size()); for(Element e : this) clone.add(e.clone()); return clone; }
/** * Only document can be select * See: https://github.com/code4craft/webmagic/issues/113 * * @param elementIterator elementIterator * @return element element */ private Element checkElementAndConvert(ListIterator<Element> elementIterator) { Element element = elementIterator.next(); if (!(element instanceof Document)) { Document root = new Document(element.ownerDocument().baseUri()); Element clone = element.clone(); root.appendChild(clone); elementIterator.set(root); return root; } return element; }
@Override protected Element transform(Element elem, Element content) { return content.clone(); }
public Element clone() { return originElement.clone(); }
public Element toElement() { return renderedElement.clone(); }
@Override public Element transform(Element elem, ElementSetter content) { Element result = elem.clone(); content.set(result); return result; }
@Override protected Element transform(Element elem, Object content) { String logStr = logMessage + "( " + creationSiteInfo + " ):\n" + elem.toString(); logger.debug(logStr); // we have to clone a new element, which is how transformer works. Element newElem = elem.clone(); return newElem; }
/** * Replaces all {@code <br/>} tags with a newline in a copy of the input node, and * returns the resulting innter text. * This is necessary to ensure that manual linebreaks are supported in preformatted code. * * @param oinput Preformatted node to process * @return inner text of the node. */ private String getPreformattedText(Element oinput) { Element el = oinput.clone(); fixLineBreaks(el); return el.text(); }
@Override protected Element transform(Element elem, Renderer content) { Element result = elem.clone(); // add a dummy parent so that the result element can be replaced by the // sub renderer. GroupNode wrapper = new GroupNode(); wrapper.appendChild(result); RenderUtil.apply(result, content); return wrapper; }
/** * Only document can be select * See: https://github.com/code4craft/webmagic/issues/113 * * @param elementIterator elementIterator * @return element element */ private Element checkElementAndConvert(ListIterator<Element> elementIterator) { Element element = elementIterator.next(); if (!(element instanceof Document)) { Document root = new Document(element.ownerDocument().baseUri()); Element clone = element.clone(); root.appendChild(clone); elementIterator.set(root); return root; } return element; }
/** * Only document can be select * See: https://github.com/code4craft/webmagic/issues/113 * * @param elementIterator elementIterator * @return element element */ private Element checkElementAndConvert(ListIterator<Element> elementIterator) { Element element = elementIterator.next(); if (!(element instanceof Document)) { Document root = new Document(element.ownerDocument().baseUri()); Element clone = element.clone(); root.appendChild(clone); elementIterator.set(root); return root; } return element; }
element.replaceWith(replacementElem.clone());
element.replaceWith(replacementElem.clone());
element.replaceWith(replacementElem.clone());
public void fixFigrefListItem(Element element) { Node next = element.nextSibling(); String trailingTxt; if (next != null && next instanceof TextNode) { trailingTxt = ((TextNode) next).getWholeText(); } else if (next != null && next instanceof Element) { trailingTxt = ((Element) next).text(); } else { return; } if (trailingTxt.matches("^(, |,? and )")) { next = element.nextSibling().nextSibling(); if (next.nodeName().toLowerCase().equals("b")) { String containedTxt = ((TextNode) next.childNode(0)).getWholeText(); if (containedTxt.matches("[0-9]{1,2}[A-z]?")) { Element newEl = element.clone(); newEl.attr("id", "FR-" + Strings.padStart(containedTxt, 4, '0')); newEl.attr("idref", ReferenceTagger.createFigId(containedTxt)); newEl.tagName("a"); newEl.addClass("figref"); newEl.text(containedTxt); next.replaceWith(newEl); fixFigrefListItem(newEl); } } } }
return; Element indexLink = findFirstElement(Selector.TOC_HEADING_2).clone(); String fileExtension = ".htm"; Node ankerNode = null;
private static Almanax gatheringOnlineData(Language lg, String date) throws IOException { LOG.info("connecting to " + Translator.getLabel(lg, "almanax.url") + date + " ..."); Document doc = JSoupManager.getDocument(Translator.getLabel(lg, "almanax.url") + date); String bonus = doc.getElementsByClass("more").first() .clone().getElementsByClass("more-infos").empty().parents().first().text(); String quest = doc.getElementsByClass("more-infos").first().child(0).text(); String ressourceURL = doc.getElementsByClass("more-infos-content").first().children().attr("src"); String offrande = doc.getElementsByClass("fleft").get(3).text(); return new Almanax(bonus, offrande, date, quest, ressourceURL); }