scone.netobjects
Class NetNode

java.lang.Object
  extended by scone.netobjects.TableRecord
      extended by scone.netobjects.NetNode
All Implemented Interfaces:
Cacheable

public class NetNode
extends TableRecord

a NetNode represents a node from the Internet.
use the static methods provided by NetNodeCache class to obtain NetNode objects.

Author:
Harald Weinreich, Volkert Buchmann

Field Summary
static java.lang.String COPYRIGHT
           
static DBTableAdapter dbTable
           
protected  SimpleUri sUri
           
 
Fields inherited from class scone.netobjects.TableRecord
ctei, date, fieldValues, hasChanged, hasRecordInDB, persistent
 
Constructor Summary
protected NetNode()
          Creates an empty NetNodeCache set with no equivalent set in the scone database
Such an object may used to find out whether a corresponding set exists
  NetNode(java.sql.ResultSet results)
          Create Netnode to Result of DB-Query.
protected NetNode(SimpleUri sUri)
          Creates or reads a NetNodeCache set in the scone database
The corresponding set in the scone database is identified by the URI.
protected NetNode(java.lang.String id)
          Reads a NetNodeCache set in the scone database
The corresponding set in the scone database is identified by the nodeId which may have been obtained from other objects.
 
Method Summary
 void access()
          sets lastAccess to now and increments accessCounter
if the node is visted for the first time, the method sets firstAccess
 void computeType()
          Compute NetNode type.
 void fill(com.ibm.wbi.protocol.http.DocumentInfo documentInfo)
          fills the fields mimeType, size, and accessStatus from a DocumentInfo-object
 int getAccessCounter()
          Returns the times the node has been accessed by any scone-user
 java.lang.String getAccessStatus()
          Returns the status of the node, for example 200 or 404
if -1 is returned, the node has not yet been visited
 java.lang.String getExtension()
           
 java.lang.String getFile()
           
 long getFirstAccess()
          Returns the date of the first access of this node.
 java.lang.String getFragment()
           
 java.lang.String getHost()
           
 java.lang.Object getKey(int keyNo)
          returns the hashkey for this object (to be deprecated!)
 long getLastAccess()
          Returns the date of the last access of this node.
 long getLastModified()
          Returns the date of the last modification of the node (at the server)
 long getLastRobotAccess()
          Returns the date of the last robot-access of this node.
 java.lang.String getMainHost()
           
 java.lang.String getMimeType()
          Returns the mimeType of the node, for example text/html
 java.lang.String getNodeId()
          Returns the key for this database set
 java.lang.String getOpaquePart()
           
 java.lang.String getPath()
           
 java.lang.String getPort()
           
 java.lang.String getProtocol()
           
 java.lang.String getQuery()
           
 java.lang.String getRef()
           
 java.lang.String getSize()
          Returns the size of the node in bytes
 SimpleUri getSUri()
          Returns the parsed URI of the node
 int getType()
          returns the NetNode type bitfield parameter
 java.lang.String getUri()
          Returns the URI of the node
protected  void incAccessCounter()
          Increases the accessCounter.
protected  void setAccessCounter(int v)
          Sets the accesCounter to the specified value.
 void setAccessStatus(java.lang.String v)
          Sets the status of the node, if the status has been -1 and is now changed, firstAccess is set
protected  void setLastAccess(long v)
          Sets the date of the last access (the current access!)
 void setLastModified(long time)
          Sets the date of the last modification of the node (at the server)
 void setLastModifiedString(java.lang.String lastModifiedString)
          Sets the date of the last modification of the node (at the server).
 void setLastRobotAccess(long v)
          Sets the date of the last robot-access (the current access!)
 void setMimeType(java.lang.String v)
          Sets the mimeType of the node
 void setSize(java.lang.String size)
          Sets the size of this node in bytes.
 void setType(int t)
          sets the type parameter
 void store()
          Writes the content of the object into the scone database if it has been changed.
 java.lang.String toDocString()
           
 java.lang.String toHostString()
           
 java.lang.String toString()
           
 
Methods inherited from class scone.netobjects.TableRecord
isPersistent, now, setCacheTableEntryInterface, setChanged, setPersistent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

dbTable

public static DBTableAdapter dbTable

sUri

protected SimpleUri sUri
Constructor Detail

NetNode

protected NetNode()
Creates an empty NetNodeCache set with no equivalent set in the scone database
Such an object may used to find out whether a corresponding set exists

Parameters:
sUri - the parsed URI of the node

NetNode

protected NetNode(SimpleUri sUri)
Creates or reads a NetNodeCache set in the scone database
The corresponding set in the scone database is identified by the URI. If such a set already exists, the values are read from the database. Else a set is created.

Parameters:
sUri - the parsed URI of the node

NetNode

protected NetNode(java.lang.String id)
Reads a NetNodeCache set in the scone database
The corresponding set in the scone database is identified by the nodeId which may have been obtained from other objects. If such a set already exists, the values are read from the database. Else, hasRecordInDB is set to false

Parameters:
id - the code>nodeId of the desired node

NetNode

public NetNode(java.sql.ResultSet results)
Create Netnode to Result of DB-Query.

Parameters:
results - the ResultSet returnetd by the query.
Method Detail

access

public void access()
sets lastAccess to now and increments accessCounter
if the node is visted for the first time, the method sets firstAccess


getNodeId

public java.lang.String getNodeId()
Returns the key for this database set

Returns:
nodeId

getUri

public java.lang.String getUri()
Returns the URI of the node

Returns:
the URI

getSize

public java.lang.String getSize()
Returns the size of the node in bytes

Returns:
the size in bytes

setSize

public void setSize(java.lang.String size)
Sets the size of this node in bytes.

Parameters:
size - the size in bytes

getLastModified

public long getLastModified()
Returns the date of the last modification of the node (at the server)

Returns:
the lastModified-date

setLastModifiedString

public void setLastModifiedString(java.lang.String lastModifiedString)
Sets the date of the last modification of the node (at the server). Use the string format "EEE, dd MMM yyyy HH:mm:ss z" as common for the "Last-Modified" parameter.

Parameters:
date - the lastModified-date

setLastModified

public void setLastModified(long time)
Sets the date of the last modification of the node (at the server)

Parameters:
date - the lastModified-date

getMimeType

public java.lang.String getMimeType()
Returns the mimeType of the node, for example text/html

Returns:
the mimeType

setMimeType

public void setMimeType(java.lang.String v)
Sets the mimeType of the node

Parameters:
v - the mimeType

getAccessStatus

public java.lang.String getAccessStatus()
Returns the status of the node, for example 200 or 404
if -1 is returned, the node has not yet been visited

Returns:
the status, or -1 if no status is available

setAccessStatus

public void setAccessStatus(java.lang.String v)
Sets the status of the node, if the status has been -1 and is now changed, firstAccess is set

Parameters:
v - the status

getType

public int getType()
returns the NetNode type bitfield parameter

Returns:
the typ parameter

setType

public void setType(int t)
sets the type parameter

Parameters:
t - the type parameter

getFirstAccess

public long getFirstAccess()
Returns the date of the first access of this node.
Be sure that this node has been accessed before this date is used!

Returns:
the date of the first access

getLastAccess

public long getLastAccess()
Returns the date of the last access of this node.
Be sure that this node has been accessed before this date is used!

Returns:
the date of the last access

setLastAccess

protected void setLastAccess(long v)
Sets the date of the last access (the current access!) of the node.
Use access() instead for consistency!

Parameters:
v - the date

getAccessCounter

public int getAccessCounter()
Returns the times the node has been accessed by any scone-user

Returns:
the times the node has been accessed

setAccessCounter

protected void setAccessCounter(int v)
Sets the accesCounter to the specified value.
Use incAccessCounter() instead for consistency!

Parameters:
v - the date

incAccessCounter

protected void incAccessCounter()
Increases the accessCounter.
Use access() instead for consistency!


getLastRobotAccess

public long getLastRobotAccess()
Returns the date of the last robot-access of this node.

Returns:
the date of the last robot-access

setLastRobotAccess

public void setLastRobotAccess(long v)
Sets the date of the last robot-access (the current access!) of the node.

Parameters:
v - the date

getSUri

public SimpleUri getSUri()
Returns the parsed URI of the node

Returns:
the parsed URI of the node

fill

public void fill(com.ibm.wbi.protocol.http.DocumentInfo documentInfo)
fills the fields mimeType, size, and accessStatus from a DocumentInfo-object

Parameters:
documentInfo - the DocumentInfo-object belonging to this node

computeType

public void computeType()
Compute NetNode type. Type information is stored in bits of an integer value. This data is provided to make database access to this kind of information easier and faster.

bit 0: Path: Path defined
bit 1: No Path: No path defined
bit 2: Filename: filename defined
bit 3: No Filename: no filename in URI
bit 4: Fragment: Fragment (#) defined
bit 5: No Fragment
bit 6: Query: Query GET-parameters defined
bit 7: No Query: Query GET-parameters not defined
bit 10: Homepage: Homepage of server

bit 14: HTTP: Prptpcol is http.
bit 15: Other protocol: Prptpcol is not http but mail, ftp etc.

bit 20: Mime type is HTML
bit 21: Mime type is NOT HTML
bit 22: Mime type: Text/*
bit 23: Mime type: Image/*


toDocString

public java.lang.String toDocString()

toHostString

public java.lang.String toHostString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getProtocol

public java.lang.String getProtocol()

getHost

public java.lang.String getHost()

getMainHost

public java.lang.String getMainHost()

getPort

public java.lang.String getPort()

getPath

public java.lang.String getPath()

getFile

public java.lang.String getFile()

getExtension

public java.lang.String getExtension()

getQuery

public java.lang.String getQuery()

getFragment

public java.lang.String getFragment()

getOpaquePart

public java.lang.String getOpaquePart()

getRef

public java.lang.String getRef()

store

public void store()
Writes the content of the object into the scone database if it has been changed.
This method will be called from time to time by the cache


getKey

public java.lang.Object getKey(int keyNo)
Description copied from interface: Cacheable
returns the hashkey for this object (to be deprecated!)

Specified by:
getKey in interface Cacheable
Specified by:
getKey in class TableRecord
Parameters:
the - number of the key
Returns:
key returns the key