jautil.cache
Class JACacheDescriptor

java.lang.Object
  extended by jautil.cache.JACacheDescriptor

public class JACacheDescriptor
extends java.lang.Object

An in-memory copy of a descriptor entry from a remote file cache of the kind managed by an JACacheHandler.


Constructor Summary
JACacheDescriptor(java.lang.String enm, java.lang.String durl, long tstamp, int len)
          Constructs a new descriptor with the given entry name, original data URL, time stamp and data length.
 
Method Summary
 int dataLength()
          Returns the length of the original data file for the entry to which this descriptor refers.
 java.lang.String entryName()
          Returns the name of the entry to which this descriptor refers.
static JACacheDescriptor makeDescriptor(java.lang.String[] dlines)
          Creates a new descriptor from the given array of data lines, which is expected to contain the following items, one per line, in order: entry name, original data URL, cache data URL, time stamp, data length.
 boolean matches(JACacheDescriptor cd)
          Indicates whether this descriptor matches and is in synch with the given one -- specifically whether their associated time stamps, data lengths, entry names and original data URLs are the same.
 boolean matchesNameAndURL(java.lang.String enm, java.lang.String durl)
          Indicates whether the given entry name and original data URL are the same as those to which this descriptor refers.
 boolean matchesTimeAndLength(long ts, int len)
          Indicates whether or not the given time stamp and and original URL data length are the same as those for the entry to which this descriptor refers.
 boolean matchesURL(java.lang.String durl)
          Indicates whether the given data URL is the same as the original data URL for the entry to which this descriptor refers.
static JACacheDescriptor readDescriptor(java.io.InputStream dins)
          Builds and returns a new descriptor based on the data obtained from the given stream, or returns null if there is an input error.
 long timeStamp()
          Returns the time stamp of the original data URL for the avatar to which this descriptor refers.
 java.lang.String url()
          Returns the original data URL for the entry to which this descriptor refers.
 void write(java.io.OutputStream outs)
          Writes the this descriptor's non-transient data to the given output stream, one item per line in the standard encoding (UTF-8).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JACacheDescriptor

public JACacheDescriptor(java.lang.String enm,
                         java.lang.String durl,
                         long tstamp,
                         int len)
Constructs a new descriptor with the given entry name, original data URL, time stamp and data length.

Method Detail

entryName

public java.lang.String entryName()
Returns the name of the entry to which this descriptor refers.


url

public java.lang.String url()
Returns the original data URL for the entry to which this descriptor refers.


timeStamp

public long timeStamp()
Returns the time stamp of the original data URL for the avatar to which this descriptor refers.


dataLength

public int dataLength()
Returns the length of the original data file for the entry to which this descriptor refers.


matches

public boolean matches(JACacheDescriptor cd)
Indicates whether this descriptor matches and is in synch with the given one -- specifically whether their associated time stamps, data lengths, entry names and original data URLs are the same.


matchesNameAndURL

public boolean matchesNameAndURL(java.lang.String enm,
                                 java.lang.String durl)
Indicates whether the given entry name and original data URL are the same as those to which this descriptor refers.


matchesURL

public boolean matchesURL(java.lang.String durl)
Indicates whether the given data URL is the same as the original data URL for the entry to which this descriptor refers.


matchesTimeAndLength

public boolean matchesTimeAndLength(long ts,
                                    int len)
Indicates whether or not the given time stamp and and original URL data length are the same as those for the entry to which this descriptor refers.


write

public void write(java.io.OutputStream outs)
Writes the this descriptor's non-transient data to the given output stream, one item per line in the standard encoding (UTF-8). Specifically, this writes these items in this order: entry name, original data URL, original time stamp, and original data length.


readDescriptor

public static JACacheDescriptor readDescriptor(java.io.InputStream dins)
Builds and returns a new descriptor based on the data obtained from the given stream, or returns null if there is an input error.


makeDescriptor

public static JACacheDescriptor makeDescriptor(java.lang.String[] dlines)
Creates a new descriptor from the given array of data lines, which is expected to contain the following items, one per line, in order: entry name, original data URL, cache data URL, time stamp, data length. Returns the new descriptor if successful, or null otherwise.