/** * Add a webLinkedFile in the queue if it hasn't been already downloaded and if it respect the * good host or protocol * * @param uri the URI to add * @param depth the depth of the URI * @param parent the webHtmlFile parent */ public void addLinkedFile(URI uri, int depth, WebFile parent) { // creates the webLinkedFile according to the URI if (!isUriAlreadyDownloaded(uri)) { // verification if the depth is good if (depth <= maxDepth) { discoveredURI.add(Utils.getCompletePath(uri)); WebLinkedFile webLinkedFile = new WebLinkedFile(uri, depth, parent); String webFileHost = Utils.getCompleteHost(webLinkedFile.getURI()); // filter the linked files with the Filter RE r = new RE(regExp); if (r.match(webLinkedFile.getFileName())) { if (webFileHost.equals(defaultHost)) { linkedFileToDownload.add(webLinkedFile); // add the webHtmlFile in the treeModel DiscoveryTreeNode parentNode = (DiscoveryTreeNode) treeRoot.getChild(parent); DiscoveryTreeNode node = parentNode.add(webLinkedFile); treeModel.nodesWereInserted(parentNode, new int[] {parentNode.getIndex(node)}); // add the webHtmlFile in the detailledModel detailledModel.addElement(webLinkedFile); } else { // it is not the same web site or the same protocol System.err.println( webLinkedFile.getURI() + " / " + defaultHost + ": NOT THE SAME HOST OR THE SAME PROTOCOL"); } } } } }
/** * Add a webHtmlFile in the queue if it hasn't been already downloaded and if it respect the good * host or protocol * * @param uri the URI to add * @param depth the depth of the URI */ public void addHtmlFile(URI uri, int depth) { // creates the webHtmlFile according to the URI if (!isUriAlreadyDownloaded(uri)) { // verification if the depth is good if (depth <= maxDepth) { discoveredURI.add(Utils.getCompletePath(uri)); WebHtmlFile webHtmlFile = new WebHtmlFile(uri, depth); String webFileHost = Utils.getCompleteHost(webHtmlFile.getURI()); if (webFileHost.equals(defaultHost)) { htmlFileToDownload.add(webHtmlFile); // add the webHtmlFile in the treeModel DiscoveryTreeNode node = treeRoot.add(webHtmlFile); treeModel.nodesWereInserted(treeRoot, new int[] {treeRoot.getIndex(node)}); if (tree.isRootVisible() && !tree.isExpanded(0)) { tree.expandRow(0); tree.setRootVisible(false); } // add the webHtmlFile in the detailledModel detailledModel.addElement(webHtmlFile); } else { // it is not the same web site or the same protocol System.err.println( webHtmlFile.getURI() + " / " + defaultHost + ": NOT THE SAME HOST OR THE SAME PROTOCOL"); } } } }