jautil.avatar
Class AvatarCacheDescriptor

java.lang.Object
  extended by jautil.avatar.AvatarCacheDescriptor

public class AvatarCacheDescriptor
extends java.lang.Object

An in-memory copy of a descriptor entry from an avatar definitions cache of the kind managed by an AvatarsCacheHandler.


Constructor Summary
AvatarCacheDescriptor(java.lang.String av, java.lang.String avurl, long tstamp, int len)
          Constructs a new descriptor with the given avatar name, original avatar data URL, cache data URL, time stamp and data length.
 
Method Summary
 java.lang.String avatar()
          Returns the name of the avatar to which this descriptor refers.
 int dataLength()
          Returns the length of the data file for the avatar to which this desriptor refers.
static AvatarCacheDescriptor 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: avatar name, original data URL, cache data URL, time stamp, data length.
 boolean matches(AvatarCacheDescriptor acd)
          Indicates whether this descriptor matches and is in synch with the given one -- specifically whether their associated time stamps, data lengths, avatar names and original data URLs are the same.
 boolean matchesAvatarAndURL(java.lang.String av, java.lang.String aurl)
          Indicates whether the given avatar 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 avatar to which this descriptor refers.
 boolean matchesURL(java.lang.String avurl)
          Indicates whether the given avatar URL is the same as the original data URL for the avatar to which this descriptor refers.
static AvatarCacheDescriptor 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 avatar data URL for the avatar to which this descriptor refers.
 java.lang.String url()
          Returns the original avatar data URL for the avatar 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

AvatarCacheDescriptor

public AvatarCacheDescriptor(java.lang.String av,
                             java.lang.String avurl,
                             long tstamp,
                             int len)
Constructs a new descriptor with the given avatar name, original avatar data URL, cache data URL, time stamp and data length.

Method Detail

avatar

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


url

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


timeStamp

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


dataLength

public int dataLength()
Returns the length of the data file for the avatar to which this desriptor refers.


matches

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


matchesAvatarAndURL

public boolean matchesAvatarAndURL(java.lang.String av,
                                   java.lang.String aurl)
Indicates whether the given avatar name and original data URL are the same as those to which this descriptor refers.


matchesURL

public boolean matchesURL(java.lang.String avurl)
Indicates whether the given avatar URL is the same as the original data URL for the avatar 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 avatar 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: avatar name, original data URL, cache data URL, original time stamp, and original data length.


readDescriptor

public static AvatarCacheDescriptor 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 AvatarCacheDescriptor 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: avatar name, original data URL, cache data URL, time stamp, data length. Returns the new descriptor if successful, or null otherwise.