public Page getPage(int i) throws PdfException { int total = 0; for (final PageNode child : getChildNodes()) { final int count = child.getPageCount(); if (total + count > i) return child.getPage(i - total); total += count; } return null; }
Node addOrModifyPage(String url, String domain, String type, String content) { Node page = createPage(url); if (isNewlyCreatedPageNode(page)) { populateNewPageNode(page, url, domain, type, content); updatePageIndex(page); numberOfPageNodes.incrementAndGet(); logger.trace("Created page node: " + PageNode.toString(page)); reportProgress(); } else { // Sometimes pages are parsed after the corresponding node has been // created, e.g. // when the node was created as a link from another page earlier on. // In that case we need to update the page content because we did // not have it earlier. updatePageContent(page, content); } return page; }
@Override protected void initialize(Node created, Map<String, Object> properties) { PageNode.setUrl(created, (String) properties.get(INDEX_NAME)); }
@Override protected void updatePageIndex(Node page) { pageIndex.add(page, PageNode.URL_KEY, PageNode.getUrl(page)); pageIndex.add(page, PageNode.DOMAIN_KEY, PageNode.getDomain(page)); pageIndex.add(page, PageNode.TYPE_KEY, PageNode.getType(page)); }