001 /*
002 * Copyright 2001-2004 The Apache Software Foundation
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.apache.commons.cache;
017
018 import java.io.Serializable;
019
020 /**
021 * An abstract base {@link Stash} implementation,
022 * mapping the non-serialized versions of
023 * {@link #canStore} and {@link #store} to the
024 * serialized ones, and declaring {@link #wantsSerializedForm}
025 * to return <tt>false</tt>.
026 *
027 * @version $Id: BaseStash.java 155435 2005-02-26 13:17:27Z dirkv $
028 * @author Rodney Waldhoff
029 */
030 public abstract class BaseStash implements Stash {
031 /** Equivalent to {@link #canStore(java.io.Serializable,java.io.Serializable,java.lang.Long,java.lang.Long,java.io.Serializable,byte[]) <tt>canStore(<i>key</i>,<i>val</i>,<i>expiresAt</i>,<i>cost</i>,<i>group</i>,null)</tt>)}. */
032 public int canStore(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group) {
033 return canStore(key,val,expiresAt,cost,group,null);
034 }
035
036 /** Equivalent to {@link #store(java.io.Serializable,java.io.Serializable,java.lang.Long,java.lang.Long,java.io.Serializable,byte[]) <tt>canStore(<i>key</i>,<i>val</i>,<i>expiresAt</i>,<i>cost</i>,<i>group</i>,null)</tt>)}. */
037 public boolean store(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group) {
038 return store(key,val,expiresAt,cost,group,null);
039 }
040
041 /**
042 * Returns <tt>false</tt>.
043 * @return <tt>false</tt>.
044 */
045 public boolean wantsSerializedForm() {
046 return false;
047 }
048
049 public abstract int canStore(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group, byte[] serialized);
050 public abstract boolean store(Serializable key, Serializable val, Long expiresAt, Long cost, Serializable group, byte[] serialized);
051 public abstract Serializable retrieve(Serializable key);
052 public abstract boolean contains(Serializable key);
053 public abstract float capacity();
054 public abstract void clear(Serializable key);
055 public abstract void setCache(Cache c);
056 public abstract void unsetCache();
057
058 }