com.veriplace.client.store
Class FileTokenStore

java.lang.Object
  extended by com.veriplace.client.store.FileTokenStore
All Implemented Interfaces:
TokenStore

public class FileTokenStore
extends java.lang.Object
implements TokenStore

A file based implemention of TokenStore

This implementation maps the get, add, and remove operations to file operations, where each token is stored in a file with a name based on the value of Token.getToken().


Field Summary
static java.lang.String DEFAULT_DIRECTORY
          Default directory to store tokens.
static java.lang.String DEFAULT_FILE_BASE
          Default file base to store token data.
protected  java.lang.String directory
          Directory to store tokens.
protected  java.lang.String fileBase
          File base to store tokens.
 
Constructor Summary
FileTokenStore()
          Create a new file token store using default values.
FileTokenStore(java.lang.String fileBase)
          Create a new file token store using custom fileBase.
FileTokenStore(java.lang.String fileBase, java.lang.String directory)
          Create a new file token store using custom fileBase and directory.
 
Method Summary
 void add(Token token)
          Add a token to this store.
 Token get(java.lang.String token)
          Get a token by value.
protected  java.io.File getFile(java.lang.String token)
          Get the File for this token.
 java.lang.String getFileBase()
           
 java.lang.String getPath()
           
 void remove(Token token)
          Remove a token from this store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DIRECTORY

public static final java.lang.String DEFAULT_DIRECTORY
Default directory to store tokens. (/tmp)


DEFAULT_FILE_BASE

public static final java.lang.String DEFAULT_FILE_BASE
Default file base to store token data. (token)

See Also:
Constant Field Values

directory

protected final java.lang.String directory
Directory to store tokens.


fileBase

protected final java.lang.String fileBase
File base to store tokens.

Constructor Detail

FileTokenStore

public FileTokenStore()
Create a new file token store using default values.


FileTokenStore

public FileTokenStore(java.lang.String fileBase)
Create a new file token store using custom fileBase.

Parameters:
fileBase - the file base for storing tokens

FileTokenStore

public FileTokenStore(java.lang.String fileBase,
                      java.lang.String directory)
Create a new file token store using custom fileBase and directory.

Parameters:
fileBase - the file base for storing tokens
directory - the directory for storing tokens
Method Detail

getFileBase

public java.lang.String getFileBase()

getPath

public java.lang.String getPath()

get

public Token get(java.lang.String token)
Get a token by value.

Specified by:
get in interface TokenStore
Returns:
a token where Token.getToken() equals the given value.

add

public void add(Token token)
         throws java.io.IOException
Add a token to this store.

Specified by:
add in interface TokenStore
Throws:
java.io.IOException

remove

public void remove(Token token)
Remove a token from this store.

Specified by:
remove in interface TokenStore

getFile

protected java.io.File getFile(java.lang.String token)
Get the File for this token.