All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class Webcrawler.Crawler.LoadableNode

java.lang.Object
   |
   +----Webcrawler.Crawler.URLNode
           |
           +----Webcrawler.Crawler.LoadableNode

public class LoadableNode
extends URLNode
This class is derived from URLNode and contains additional info about a link that cn be loaded (like FTP or HTML). An URL that links to something loadable can be dead, malformed or recursive (=already downloaded before). The class java.net.URLConnection has a few methods for finding out more about a link, such as contentLength, date and contentType. Since a LoadableNode can be downloaded from the net onto the local harddrive, every one of those nodes stores the filename where it is stored locally.


Variable Index

 o contentLength
file-length in bytes
 o contentType
e.g: "text/html" or "image/gif"
 o date
file-creation date
 o dead
 o expiration
expiration date
 o interrupted
 o lastModified
date when file was last modified
 o localFile
fileName of locally stored file
 o malformed
 o normal
 o recursive
 o URLType
see static finals above (default: normal)

Constructor Index

 o LoadableNode()
 o LoadableNode(String)
 o LoadableNode(URL, String)

Method Index

 o canBeLoaded(URLConnection)
Says whether the URL of this node can be loaded/exists or not.
 o copy(LoadableNode)
copies all the URLConnection-info and the localFile-field.
 o getContentLength()
 o getContentType()
 o getDate()
 o getExpiration()
 o getLastModified()
 o getLocalFile()
 o getURLConnectionInfo()
If you don't have an URLConnection open (yet), use this method.
 o getURLConnectionInfo(URLConnection)
Sets the contentLength - lastModified fields of this node to whatever can be retreived from the URLConnection uc.
 o getURLType()
 o setLocalFile(String)
Controller often need to re-set the localfile attribute of a node.
 o setLocalFileInvalid()
Sets the localFile field back to an empty String.
 o toString()
In case this node has a malformed URL, the first word of the infoText is returned.

Variables

 o normal
 public static final int normal
 o dead
 public static final int dead
 o malformed
 public static final int malformed
 o recursive
 public static final int recursive
 o interrupted
 public static final int interrupted
 o URLType
 protected int URLType
see static finals above (default: normal)

 o contentLength
 protected int contentLength
file-length in bytes

 o contentType
 protected String contentType
e.g: "text/html" or "image/gif"

 o date
 protected long date
file-creation date

 o expiration
 protected long expiration
expiration date

 o lastModified
 protected long lastModified
date when file was last modified

 o localFile
 protected String localFile
fileName of locally stored file

Constructors

 o LoadableNode
 public LoadableNode()
See Also:
URLNode
 o LoadableNode
 public LoadableNode(String url) throws MalformedURLException
See Also:
URLNode
 o LoadableNode
 public LoadableNode(URL context,
                     String spec) throws MalformedURLException
See Also:
URLNode

Methods

 o copy
 public void copy(LoadableNode from)
copies all the URLConnection-info and the localFile-field.

 o getURLType
 public int getURLType()
Returns:
the URLType of this node (e.g. dead)
 o getContentLength
 public int getContentLength()
Returns:
the size of the URLs content in bytes
See Also:
URLConnection
 o getContentType
 public String getContentType()
Returns:
the content type
See Also:
URLConnection
 o getDate
 public long getDate()
Returns:
the date when the file was created
See Also:
URLConnection
 o getExpiration
 public long getExpiration()
Returns:
the date when the file expires
See Also:
URLConnection
 o getLastModified
 public long getLastModified()
Returns:
the date when the file was last modified
See Also:
URLConnection
 o getLocalFile
 public String getLocalFile()
Returns:
the filename of the locally stored file
 o setLocalFileInvalid
 public void setLocalFileInvalid()
Sets the localFile field back to an empty String. This method can e.g. be used by a Controller after the localFiles were deleted.

 o setLocalFile
 public void setLocalFile(String lf)
Controller often need to re-set the localfile attribute of a node.

 o toString
 public String toString()
In case this node has a malformed URL, the first word of the infoText is returned. Otherwise URLNode.toString() is called;

Returns:
a String-representation of the URL of this node
Overrides:
toString in class URLNode
 o canBeLoaded
 public boolean canBeLoaded(URLConnection uc)
Says whether the URL of this node can be loaded/exists or not. In case of an HTPP-url a HttpURLConnection is opened and the responseCode checked. The response-code must be < 300 to be ok. In case of a FILE-url or FTP-url a stream is opened and the IOException cought.

Parameters:
uc - Reuse an existing URLConnection!!
 o getURLConnectionInfo
 public void getURLConnectionInfo(URLConnection uc)
Sets the contentLength - lastModified fields of this node to whatever can be retreived from the URLConnection uc. Use this if you already have a URLConnection open.

 o getURLConnectionInfo
 public URLConnection getURLConnectionInfo()
If you don't have an URLConnection open (yet), use this method. It opens a Connection and calls getURLConnectionInfo(connection).

Returns:
The opened URLConnection for reuse!

All Packages  Class Hierarchy  This Package  Previous  Next  Index