org.apache.myfaces.trinidadinternal.util
Class TokenCache

java.lang.Object
  extended by org.apache.myfaces.trinidadinternal.util.TokenCache
All Implemented Interfaces:
java.io.Serializable

public class TokenCache
extends java.lang.Object
implements java.io.Serializable

A simple tokenized cache

Author:
The Oracle ADF Faces Team
See Also:
Serialized Form

Field Summary
static char SEPARATOR_CHAR
          Character guaranteed to not be used in tokens
 
Constructor Summary
TokenCache()
          For serialization only
TokenCache(int size)
          Create a TokenCache that will store the last "size" entries.
TokenCache(int size, int seed)
           
 
Method Summary
 java.lang.String addNewEntry(java.lang.Object value, java.util.Map<java.lang.String,java.lang.Object> targetStore)
          Create a new token; and use that token to store a value into a target Map.
 void clear(java.util.Map<java.lang.String,java.lang.Object> targetStore)
          Clear a cache, without resetting the token.
static TokenCache getTokenCacheFromSession(javax.faces.context.FacesContext context, java.lang.String cacheName, boolean createIfNeeded, int defaultSize)
          Gets a TokenCache from the session, creating it if needed.
 boolean isAvailable(java.lang.String token)
          Returns true if an entry is still available.
 java.lang.Object removeOldEntry(java.lang.String token, java.util.Map<java.lang.String,java.lang.Object> targetStore)
          Removes a value from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR_CHAR

public static char SEPARATOR_CHAR
Character guaranteed to not be used in tokens

Constructor Detail

TokenCache

public TokenCache()
For serialization only


TokenCache

public TokenCache(int size)
Create a TokenCache that will store the last "size" entries.


TokenCache

public TokenCache(int size,
                  int seed)
Method Detail

getTokenCacheFromSession

public static TokenCache getTokenCacheFromSession(javax.faces.context.FacesContext context,
                                                  java.lang.String cacheName,
                                                  boolean createIfNeeded,
                                                  int defaultSize)
Gets a TokenCache from the session, creating it if needed.


addNewEntry

public java.lang.String addNewEntry(java.lang.Object value,
                                    java.util.Map<java.lang.String,java.lang.Object> targetStore)
Create a new token; and use that token to store a value into a target Map.


isAvailable

public boolean isAvailable(java.lang.String token)
Returns true if an entry is still available.


removeOldEntry

public java.lang.Object removeOldEntry(java.lang.String token,
                                       java.util.Map<java.lang.String,java.lang.Object> targetStore)
Removes a value from the cache.

Returns:
previous value associated with the token, if any

clear

public void clear(java.util.Map<java.lang.String,java.lang.Object> targetStore)
Clear a cache, without resetting the token.



Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.