org.jscience.net
Class URLTree

java.lang.Object
  extended by javax.swing.tree.DefaultTreeModel
      extended by org.jscience.net.URLTree
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class URLTree
extends javax.swing.tree.DefaultTreeModel
implements java.io.Serializable

URLTree represents the model of a tree where each node is made of a URL wrapped in a URLNode object. The tree is configurable in size by adding restrictions that determine whether a URLNode is included in the tree or not.
Note that changing parameters of the CrawlerSetting used by the URL tree without recalculating the tree may put the tree in an inconsistent state.

See Also:
URLNode, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
URLTree(java.net.URL root)
          calls URLTree(root, new SampleCrawlerSetting(), false)
URLTree(java.net.URL root, CrawlerSetting crawler, boolean singlePath)
           
 
Method Summary
 CrawlerSetting getCrawler()
          DOCUMENT ME!
 int getNumberOfNodes()
          DOCUMENT ME!
 boolean getSinglePath()
          if true, the URLTree allows every URL to only occur once in the tree
 void revalidate(boolean refresh)
          recalculates the entire tree recursively from the root based on the current settings; this should be done every time when parameters of the crawler changed, otherwise the tree could be in an inconsisten state
protected  void revalidateNode(URLNode node, boolean refresh)
          internally called by recalculate(); recalculates sub-tree recursively
 void setCrawler(CrawlerSetting crawler)
          on calling this method, the entire tree will be recalculated based on the settings of the new crawler
 void setRoot(javax.swing.tree.TreeNode root)
          overwritten to ensure proper immediate calculation of the entire new tree based on the new settings.
 void setRoot(java.net.URL root)
          DOCUMENT ME!
 void setSinglePath(boolean singlePath)
          if set to true, the URLTree allows every URL to only occur once in the tree; calling this function forces the entire tree to be revalidated from the root
 java.lang.String toString()
          DOCUMENT ME!
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getChild, getChildCount, getIndexOfChild, getListeners, getPathToRoot, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URLTree

public URLTree(java.net.URL root)
calls URLTree(root, new SampleCrawlerSetting(), false)


URLTree

public URLTree(java.net.URL root,
               CrawlerSetting crawler,
               boolean singlePath)
Parameters:
root - the root node of the tree
crawler - restrictions that define the content of the URLTree
singlePath - if true, the tree allows each URL to occur only once in the tree
Method Detail

setRoot

public void setRoot(java.net.URL root)
DOCUMENT ME!

Parameters:
root - DOCUMENT ME!

setRoot

public void setRoot(javax.swing.tree.TreeNode root)
overwritten to ensure proper immediate calculation of the entire new tree based on the new settings.

Overrides:
setRoot in class javax.swing.tree.DefaultTreeModel
Parameters:
root - DOCUMENT ME!
Throws:
java.lang.ClassCastException - if given node is not a URLNode

getCrawler

public CrawlerSetting getCrawler()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setCrawler

public void setCrawler(CrawlerSetting crawler)
on calling this method, the entire tree will be recalculated based on the settings of the new crawler

Parameters:
crawler - DOCUMENT ME!

getSinglePath

public boolean getSinglePath()
if true, the URLTree allows every URL to only occur once in the tree

Returns:
DOCUMENT ME!

setSinglePath

public void setSinglePath(boolean singlePath)
if set to true, the URLTree allows every URL to only occur once in the tree; calling this function forces the entire tree to be revalidated from the root

Parameters:
singlePath - DOCUMENT ME!

revalidate

public void revalidate(boolean refresh)
recalculates the entire tree recursively from the root based on the current settings; this should be done every time when parameters of the crawler changed, otherwise the tree could be in an inconsisten state

Parameters:
refresh - if true, each cached node contend is refreshed, i.e. reloaded from the net

revalidateNode

protected void revalidateNode(URLNode node,
                              boolean refresh)
internally called by recalculate(); recalculates sub-tree recursively

Parameters:
node - DOCUMENT ME!
refresh - DOCUMENT ME!

getNumberOfNodes

public int getNumberOfNodes()
DOCUMENT ME!

Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
DOCUMENT ME!

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!