1 package org.gffs.cache;
16 import java.util.Date;
18 class RoleBasedCacheNode<KeyType, DataType>
20 static public final int ROLE_LRU = 0;
21 static public final int ROLE_TIMEOUT = 1;
22 static private final int _NUM_ROLES = 2;
24 private Object[] _next;
25 private Object[] _previous;
28 private DataType _data;
30 private Date _invalidationDate;
32 public RoleBasedCacheNode(KeyType key, DataType data, Date invalidationDate)
34 _next =
new Object[_NUM_ROLES];
35 _previous =
new Object[_NUM_ROLES];
37 for (
int lcv = 0; lcv < _NUM_ROLES; lcv++) {
39 _previous[lcv] =
null;
44 _invalidationDate = invalidationDate;
47 public KeyType getKey()
52 public DataType getData()
57 public Date getInvalidationDate()
59 return _invalidationDate;
62 public void setInvalidationDate(
long millisecondsFromNow)
64 _invalidationDate =
new Date(System.currentTimeMillis() + millisecondsFromNow);
67 @SuppressWarnings(
"unchecked")
68 public RoleBasedCacheNode<KeyType, DataType> getPrevious(
int role)
70 return RoleBasedCacheNode.class.cast(_previous[role]);
73 @SuppressWarnings(
"unchecked")
74 public RoleBasedCacheNode<KeyType, DataType> getNext(
int role)
76 return RoleBasedCacheNode.class.cast(_next[role]);
79 public void setPrevious(
int role, RoleBasedCacheNode<KeyType, DataType> previous)
81 _previous[role] = previous;
84 public void setNext(
int role, RoleBasedCacheNode<KeyType, DataType> next)
89 public void clearLinks(
int role)
91 _previous[role] =
null;
95 public void clearLinks()
97 for (
int lcv = 0; lcv < _NUM_ROLES; lcv++)