Caching
Class CacheBuffer

java.lang.Object
  |
  +--Caching.CacheBuffer

public class CacheBuffer
extends java.lang.Object

This class is used to create and manage a buffer of information about the pages which we have cached
There is no constructor for this class because you shoudn't ever need to make a NEW instance of this class. This class is designed to make an instance of itself only once when using the getInstance command (see the method for more info)

Whenever you need to use this object you need to make an instance of it as follows:
CacheBuffer cb = CacheBuffer.getInstance();


Field Summary
 Caching.CacheTreeNode Tree
           
 
Method Summary
 boolean addToBuffer(BufferEntry entry)
          Add an entry to the cache buffer
 void addURLToBuffer(java.lang.String URL, HTTPClient.HTTPResponse rsp)
          Add a URL to the buffer.
 boolean deleteBufferEntry(BufferEntry entry)
          Delete an entry from the cache buffer
 boolean deleteBufferEntry(java.lang.String URL)
          Delete the URL from the Cache Buffer.
 BufferEntry getBufferEntry(java.lang.String URL)
          Get the buffer structure associated with a URL.
 java.util.Date getExpiration(java.lang.String URL)
          Get the expired field of a certain URL.
static CacheBuffer getInstance()
          Get an instance of this buffer.
 java.util.Date getLastModified(java.lang.String URL)
          Get the date last modified field of a certain URL.
 java.util.Date getRetrieved(java.lang.String URL)
          Get the date retrieved field of a certain URL.
 java.util.Hashtable giveBuffer()
          Give the contents of the buffer
 boolean isInBuffer(BufferEntry entry)
          See if an entry is in the cache buffer
 void printBuffer()
          Print out the contents of the buffer
 boolean updateBuffer(BufferEntry old, BufferEntry new_entry)
          Update an entry in the cache buffer
 boolean updateBuffer(java.lang.String url_to_update, BufferEntry new_entry)
          Update an entry in the cache Buffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Tree

public Caching.CacheTreeNode Tree
Method Detail

getInstance

public static CacheBuffer getInstance()
Get an instance of this buffer.
Since we want this buffer to be global everyone needs to create an instance of this object before making any modifications to any part of it. If the object doesn't exist it will be made anew and a reference to the new instance will be returned

printBuffer

public void printBuffer()
Print out the contents of the buffer

addURLToBuffer

public void addURLToBuffer(java.lang.String URL,
                           HTTPClient.HTTPResponse rsp)
Add a URL to the buffer.
This procedure basically takes a URL and an object of type HTTPResponse and extract the headers from the HTTP response. The headers it currently extract are:
(1) Date of Expiration
(2) Date when the URL was obtained
(3) Date when the URL was last-modified on the server

giveBuffer

public java.util.Hashtable giveBuffer()
Give the contents of the buffer

isInBuffer

public boolean isInBuffer(BufferEntry entry)
See if an entry is in the cache buffer

updateBuffer

public boolean updateBuffer(java.lang.String url_to_update,
                            BufferEntry new_entry)
Update an entry in the cache Buffer

updateBuffer

public boolean updateBuffer(BufferEntry old,
                            BufferEntry new_entry)
Update an entry in the cache buffer

addToBuffer

public boolean addToBuffer(BufferEntry entry)
Add an entry to the cache buffer

deleteBufferEntry

public boolean deleteBufferEntry(BufferEntry entry)
Delete an entry from the cache buffer

getBufferEntry

public BufferEntry getBufferEntry(java.lang.String URL)
Get the buffer structure associated with a URL.
returns null if the URL is not present in the Buffer

deleteBufferEntry

public boolean deleteBufferEntry(java.lang.String URL)
Delete the URL from the Cache Buffer.
returns true if the deletion was successfull, false otherwise

getExpiration

public java.util.Date getExpiration(java.lang.String URL)
Get the expired field of a certain URL.
returns the Date Object (@see java.util.Date)

getRetrieved

public java.util.Date getRetrieved(java.lang.String URL)
Get the date retrieved field of a certain URL.
returns the Date Object (@see java.util.Date)

getLastModified

public java.util.Date getLastModified(java.lang.String URL)
Get the date last modified field of a certain URL.
returns the Date Object (@see java.util.Date)