X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=kona%2Fsrc%2Forg%2Fgffs%2Fcache%2FRoleBasedCacheNode.java;fp=kona%2Fsrc%2Forg%2Fgffs%2Fcache%2FRoleBasedCacheNode.java;h=5168d14fc804cb064d78e0b8e1216d96ec8eb0a3;hb=13679382916f379ef7fc0cf02693f0186a905835;hp=0000000000000000000000000000000000000000;hpb=909697fd6009240b5bf2643d54b129b06b733953;p=feisty_meow.git diff --git a/kona/src/org/gffs/cache/RoleBasedCacheNode.java b/kona/src/org/gffs/cache/RoleBasedCacheNode.java new file mode 100644 index 00000000..5168d14f --- /dev/null +++ b/kona/src/org/gffs/cache/RoleBasedCacheNode.java @@ -0,0 +1,100 @@ +package org.gffs.cache; + +/* + * Copyright 2006 University of Virginia + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +import java.util.Date; + +class RoleBasedCacheNode +{ + static public final int ROLE_LRU = 0; + static public final int ROLE_TIMEOUT = 1; + static private final int _NUM_ROLES = 2; + + private Object[] _next; + private Object[] _previous; + + private KeyType _key; + private DataType _data; + + private Date _invalidationDate; + + public RoleBasedCacheNode(KeyType key, DataType data, Date invalidationDate) + { + _next = new Object[_NUM_ROLES]; + _previous = new Object[_NUM_ROLES]; + + for (int lcv = 0; lcv < _NUM_ROLES; lcv++) { + _next[lcv] = null; + _previous[lcv] = null; + } + + _key = key; + _data = data; + _invalidationDate = invalidationDate; + } + + public KeyType getKey() + { + return _key; + } + + public DataType getData() + { + return _data; + } + + public Date getInvalidationDate() + { + return _invalidationDate; + } + + public void setInvalidationDate(long millisecondsFromNow) + { + _invalidationDate = new Date(System.currentTimeMillis() + millisecondsFromNow); + } + + @SuppressWarnings("unchecked") + public RoleBasedCacheNode getPrevious(int role) + { + return RoleBasedCacheNode.class.cast(_previous[role]); + } + + @SuppressWarnings("unchecked") + public RoleBasedCacheNode getNext(int role) + { + return RoleBasedCacheNode.class.cast(_next[role]); + } + + public void setPrevious(int role, RoleBasedCacheNode previous) + { + _previous[role] = previous; + } + + public void setNext(int role, RoleBasedCacheNode next) + { + _next[role] = next; + } + + public void clearLinks(int role) + { + _previous[role] = null; + _next[role] = null; + } + + public void clearLinks() + { + for (int lcv = 0; lcv < _NUM_ROLES; lcv++) + clearLinks(lcv); + } +} \ No newline at end of file