1 package org.gffs.cache;
4 * Copyright 2006 University of Virginia
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
7 * obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
13 * and limitations under the License.
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++)